Fix manual code entry (HT lachezar)

This commit is contained in:
Sean Owen 2014-07-15 12:42:59 +01:00
parent 94825ef448
commit 583cff4221

View file

@ -63,7 +63,7 @@
GET = {};
$.each(location.search.substr(1).split("&"),function(k,v){
var prm = v.split("=");
GET[prm[0]] = prm[1];
GET[decodeURIComponent(prm[0])] = decodeURIComponent(prm[1]);
});
// Check is it possible to use manual mode
@ -88,8 +88,16 @@
var man = prompt("Please type barcode below");
if(man){
var url = GET.ret;
if(url.indexOf("?") == -1) url = url + "?";
url = url + "&{CODE}=" + man;
if (url.indexOf("{CODE}") == -1) {
// Return URL has no {CODE} place holder, so add a query parameter
if (url.indexOf("?") == -1)
url = url + "?" + encodeURIComponent("{CODE}") + "=" + encodeURIComponent(man);
else
url = url + "&" + encodeURIComponent("{CODE}") + "=" + encodeURIComponent(man);
} else {
// Replace the {CODE} placeholder in the return URL with the scanned code.
url = url.replace("{CODE}", encodeURIComponent(man));
}
location = url;
}
});