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 = {}; GET = {};
$.each(location.search.substr(1).split("&"),function(k,v){ $.each(location.search.substr(1).split("&"),function(k,v){
var prm = v.split("="); var prm = v.split("=");
GET[prm[0]] = prm[1]; GET[decodeURIComponent(prm[0])] = decodeURIComponent(prm[1]);
}); });
// Check is it possible to use manual mode // Check is it possible to use manual mode
@ -88,8 +88,16 @@
var man = prompt("Please type barcode below"); var man = prompt("Please type barcode below");
if(man){ if(man){
var url = GET.ret; var url = GET.ret;
if(url.indexOf("?") == -1) url = url + "?"; if (url.indexOf("{CODE}") == -1) {
url = url + "&{CODE}=" + man; // 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; location = url;
} }
}); });