var QRCodeScanner = {
  canvas: document.getElementById("qr-canvas"),
  video: document.getElementById('v'),
  // photo: document.getElementById('p'),
  width: 320,
  height: 240,
  streaming: false,

  read: function scanner_read(txt) {
    // alert(txt);
    var msg = document.getElementById('message');
    msg.innerHTML = this.formatContent(txt);
  },

  formatContent: function scanner_format(txt) {
    if (txt.indexOf('http') === 0) {
      return '<a href="' + txt + '" target="_blank">' + txt + '</a>';
    } else {
      return txt;
    }
  },

  // imageData: null,
  context: null,
  init: function scanner_init() {
  	navigator.getMedia = ( navigator.getUserMedia ||
                         navigator.webkitGetUserMedia ||
                         navigator.mozGetUserMedia ||
                         navigator.msGetUserMedia);
  	var self = this;
  	navigator.getMedia(
      {
        video: true,
        audio: false
      },
      function(stream) {
        // if (navigator.mozGetUserMedia) {
        //   self.video.mozSrcObject = stream;
        // } else {
        var vendorURL = window.URL || window.webkitURL;
        self.video.src = vendorURL.createObjectURL(stream);
        // }
        self.video.play();
      },
        function(err) {
        console.log("An error occured! " + err);
      }
    );

    this.canvas.addEventListener("dragenter", this.dragenter, false);
    this.canvas.addEventListener("dragover", this.dragover, false);
    this.canvas.addEventListener("drop", this.drop.bind(this), false);

    qrcode.callback = this.read.bind(this);

    this.video.addEventListener('canplay', function(ev){
      if (!self.streaming) {
        // self.height = self.video.videoHeight / (self.video.videoWidth/self.width);
        self.video.setAttribute('width', self.width);
        self.video.setAttribute('height', self.height);
        self.canvas.setAttribute('width', self.width);
        self.canvas.setAttribute('height', self.height);
        self.streaming = true;
        // console.log('w:'+self.video.videoWidth+'/h:'+self.video.videoHeight);
        self.canvas.style.width = self.width + "px";
        self.canvas.style.height = self.height + "px";
        self.canvas.width = self.width;
        self.canvas.height = self.height;
        self.context = self.canvas.getContext("2d");
        self.context.clearRect(0, 0, self.width, self.height);
        // self.imageData = self.context.getImageData(0,0,
        //   self.video.videoWidth,self.video.videoHeight);
      }
    }, false);

    var capture = document.getElementById('capture');
    capture.addEventListener('click', function(ev){
      self.scanQRCode();
      ev.preventDefault();
    });
  },

  dragenter: function scanner_dragenter(e) {
    e.stopPropagation();
    e.preventDefault();
  },

  dragover: function scanner_dragover(e) {
    e.stopPropagation();
    e.preventDefault();
  },

  drop: function scanner_drop(e) {
    e.stopPropagation();
    e.preventDefault();

    var dt = e.dataTransfer;
    var files = dt.files;

    this.handleFiles(files);
  },

  handleFiles: function scanner_handleFiles(f) {
    var o=[];
    for(var i =0;i<f.length;i++)
    {
      var reader = new FileReader();

      reader.onload = (function(theFile) {
        return function(e) {
          qrcode.decode(e.target.result);
        };
      })(f[i]);

      // Read in the image file as a data URL.
      reader.readAsDataURL(f[i]);
    }
  },

  scanQRCode: function scanner_scanQRCode() {
    this.context.drawImage(this.video, 0, 0, this.width, this.height);
    var data = this.canvas.toDataURL('image/png');
    // this.photo.setAttribute('src', data);
  	qrcode.decode();
  },
}

window.addEventListener('load', function onload_scanner() {
  window.removeEventListener('load', onload_scanner);
  QRCodeScanner.init(); 
});
@@ -194,16 +194,59 @@
 false,%0A%0A
+  /**%0A   * Present content on screen%0A   */%0A
   read: 
@@ -289,24 +289,70 @@
 alert(txt);%0A
+    if (txt) %7B%0A      // this.video.pause();%0A  
     var msg 
@@ -385,24 +385,26 @@
 'message');%0A
+  
     msg.inne
@@ -436,16 +436,22 @@
 t(txt);%0A
+    %7D%0A
   %7D,%0A%0A  
@@ -685,16 +685,17 @@
 : null,%0A
+%0A
   init: 
@@ -3558,16 +3558,51 @@
 %7D%0A  %7D,%0A%0A
+  /**%0A   * Decode the QRCode%0A   */%0A
   scanQR
@@ -3635,24 +3635,50 @@
 nQRCode() %7B%0A
+    // this.video.play();%0A
     this.con

add jsdoc