;(function( $, window, document, undefined ) {
"use strict";
// cross browser request animation frame
if ( !window.requestAnimationFrame ) {
window.requestAnimationFrame = ( function() {
return window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element ) {
window.setTimeout( callback, 1000 / 60 );
};
} )();
}
var qrr, // our qrcode reader singletone instance
QRCodeReader = function() {};
$.qrCodeReader = {
jsQRpath: "../libs/qrcode-reader/js/jsQR.js",
beepPath: "../libs/qrcode-reader/audio/beep.mp3",
instance: null,
defaults: {
// single read or multiple readings/
multiple: false,
// only triggers for QRCodes matching the regexp
qrcodeRegexp: /./,
// play "Beep!" sound when reading qrcode successfully
audioFeedback: true,
// in case of multiple readings, after a successful reading,
// wait for repeatTimeout milliseconds before trying for the next lookup.
// Set to 0 to disable automatic re-tries: in such case user will have to
// click on the webcam canvas to trigger a new reading tentative
repeatTimeout: 1500,
// target input element to fill in with the readings in case of successful reading
// (newline separated in case of multiple readings).
// Such element can be specified as jQuery object or as string identifier, e.g. "#target-input"
target: null,
// in case of multiple readings, skip duplicate readings
skipDuplicates: true,
// color of the lines highlighting the QRCode in the image when found
lineColor: "#FF3B58",
// In case of multiple readings, function to call when pressing the OK button (or Enter),
// in such case read QRCodes are passed as an array.
// In case of single reading, call immediately after the successful reading
// (in the latter case the QRCode is passed as a single string value)
callback: function(code) {}
}
};
QRCodeReader.prototype = {
constructor: QRCodeReader,
init: function () {
// build the HTML
qrr.buildHTML();
qrr.scriptLoaded = false;
qrr.isOpen = false;
// load the script performing the actual QRCode reading
$.getScript( $.qrCodeReader.jsQRpath, function( data, textStatus, jqxhr ) {
if ( jqxhr.status == 200) {
qrr.scriptLoaded = true;
} else {
console.error("Erreur lors du chargement du script d'analyse QRCode");
};
});
},
// build the HTML interface of the widget
buildHTML: function() {
qrr.bgOverlay = $('