parent
d122787e45
commit
0f0ecfd90f
|
@ -1 +0,0 @@
|
|||
(function(a){jQuery.fn.BarcodeListener=function(b,c){char0=new Array("§","32");char1=new Array("~","732");settings=new Array(char0,char1);if(b){jQuery.extend(settings,b)}a("body").append('<form id="29LLRUZk" style="opacity:0;"><input type="text" name="L3ZitQdL" id="L3ZitQdL" /></form>');a(document).keypress(function(d){if(d.which==settings[0][1]){if(settings.length-1>0){wlBUJTIw=1;xaWi4Y4y=true;while((wlBUJTIw<settings.length)&&(xaWi4Y4y==true)){a(document).keypress(function(f){if(f.which==settings[wlBUJTIw][1]){xaWi4Y4y=true}else{xaWi4Y4y=false}});wlBUJTIw++}if(xaWi4Y4y==true){a("#L3ZitQdL").val("").focus()}}else{a("#L3ZitQdL").val("").focus()}d.cancelBubble=true;d.returnValue=false;if(d.stopPropagation){d.stopPropagation();d.preventDefault()}}});a("#29LLRUZk").submit(function(){code=a("#L3ZitQdL").val();for(i=0;i<settings.length;i++){dUWThqjL=new RegExp(settings[i][0]);code=code.replace(dUWThqjL,"")}if(typeof(c)=="function"){c(code)}return false})}})(jQuery);
|
|
@ -1,79 +0,0 @@
|
|||
/* **************************************************************************************
|
||||
* BarcodeListener v 1.1 (jQuery plug-in) *
|
||||
* http://code.google.com/p/jquery-barcodelistener/ *
|
||||
* *
|
||||
* how to setup the plugin http://code.google.com/p/jquery-barcodelistener/wiki/setup *
|
||||
* *
|
||||
* made by Gregorio Pellegrino *
|
||||
* gregoriopellegrino.com *
|
||||
* mail@gregoriopellegrino.com *
|
||||
* *
|
||||
* relased under Apache License 2.0 (http://www.apache.org/licenses/LICENSE-2.0) *
|
||||
************************************************************************************** */
|
||||
|
||||
(function($) {
|
||||
jQuery.fn.BarcodeListener = function(options, callback) {
|
||||
|
||||
//inizializza le variabili
|
||||
char0 = new Array("§", "32");
|
||||
char1 = new Array("~", "732");
|
||||
settings = new Array(char0, char1);
|
||||
if(options) {
|
||||
jQuery.extend(settings,options);
|
||||
}
|
||||
|
||||
// appende form nascosto
|
||||
$("body").append("<form id=\"29LLRUZk\" style=\"opacity:0;\"><input type=\"text\" name=\"L3ZitQdL\" id=\"L3ZitQdL\" /></form>");
|
||||
|
||||
// intercetta barcode reader con sequenza di caratteri §~
|
||||
$(document).keypress(function(e) {
|
||||
if (e.which == settings[0][1]) {
|
||||
if(settings.length-1>0) {
|
||||
wlBUJTIw = 1;
|
||||
xaWi4Y4y = true;
|
||||
while ((wlBUJTIw < settings.length) && (xaWi4Y4y == true)) {
|
||||
$(document).keypress(function(e) {
|
||||
if (e.which == settings[wlBUJTIw][1]) {
|
||||
xaWi4Y4y = true;
|
||||
} else {
|
||||
xaWi4Y4y = false;
|
||||
}
|
||||
});
|
||||
wlBUJTIw++;
|
||||
}
|
||||
if (xaWi4Y4y == true) {
|
||||
$("#L3ZitQdL").val("").focus();
|
||||
}
|
||||
} else {
|
||||
$("#L3ZitQdL").val("").focus();
|
||||
}
|
||||
|
||||
// event propagation
|
||||
e.cancelBubble = true;
|
||||
e.returnValue = false;
|
||||
|
||||
if (e.stopPropagation) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// intercetta invio del form
|
||||
$("#29LLRUZk").submit(function() {
|
||||
code = $("#L3ZitQdL").val();
|
||||
for (i=0; i<settings.length; i++) {
|
||||
dUWThqjL = new RegExp(settings[i][0]);
|
||||
code = code.replace(dUWThqjL, "");
|
||||
}
|
||||
|
||||
//restituisce funzione con valore immesso
|
||||
if (typeof(callback) == "function") {
|
||||
callback(code);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
|
@ -1259,6 +1259,34 @@ openerp.point_of_sale = function(db) {
|
|||
});
|
||||
(this.shop.get('products')).reset(products);
|
||||
var self = this;
|
||||
// bind barcode reader event
|
||||
codeNumbers = []
|
||||
$('.openerp').keypress(function (e){
|
||||
console.log('keyup!!!')
|
||||
if (e.keyCode >= 48 && e.keyCode <= 57) {
|
||||
// a number
|
||||
if (codeNumbers.length==0) {
|
||||
codeNumbers.timeStamp = new Date().getTime()
|
||||
} else {
|
||||
if (codeNumbers.lastTimeStamp + 30 < new Date().getTime()) {
|
||||
// not a barcode reader
|
||||
console.log(e)
|
||||
codeNumbers = []
|
||||
codeNumbers.timeStamp = new Date().getTime()
|
||||
}
|
||||
}
|
||||
codeNumbers.push(e.keyCode - 48)
|
||||
codeNumbers.lastTimeStamp = new Date().getTime()
|
||||
if (codeNumbers.length == 13) {
|
||||
// a barcode reader
|
||||
console.log('barcode: ' + codeNumbers.join())
|
||||
codeNumbers = []
|
||||
}
|
||||
} else {
|
||||
// NaN
|
||||
codeNumbers = []
|
||||
}
|
||||
})
|
||||
$('.searchbox input').keyup(function() {
|
||||
var m, s;
|
||||
s = $(this).val().toLowerCase();
|
||||
|
@ -1323,15 +1351,9 @@ openerp.point_of_sale = function(db) {
|
|||
this.$element.find("#loggedas button").click(function() {
|
||||
self.try_close();
|
||||
});
|
||||
// TODO bind barcode reader event
|
||||
console.log('--------------------');
|
||||
|
||||
pos.app = new App(self.$element);
|
||||
|
||||
char0 = new Array("§", "32");
|
||||
char1 = new Array("˜", "732");
|
||||
characters = new Array(char0, char1);
|
||||
db.webclient.BarcodeListener(characters, function(code) {console.log('<<<<<<<<<<<<<<<');});
|
||||
|
||||
db.webclient.set_content_full_screen(true);
|
||||
|
||||
|
|
Loading…
Reference in New Issue