").append(m.parseHTML(a)).find(d):a)}).complete(c&&function(a,b){g.each(c,e||[a.responseText,b,a])}),this},m.each(["ajaxStart","ajaxStop","ajaxComplete","ajaxError","ajaxSuccess","ajaxSend"],function(a,b){m.fn[b]=function(a){return this.on(b,a)}}),m.expr.filters.animated=function(a){return m.grep(m.timers,function(b){return a===b.elem}).length};var cc=a.document.documentElement;function dc(a){return m.isWindow(a)?a:9===a.nodeType?a.defaultView||a.parentWindow:!1}m.offset={setOffset:function(a,b,c){var d,e,f,g,h,i,j,k=m.css(a,"position"),l=m(a),n={};"static"===k&&(a.style.position="relative"),h=l.offset(),f=m.css(a,"top"),i=m.css(a,"left"),j=("absolute"===k||"fixed"===k)&&m.inArray("auto",[f,i])>-1,j?(d=l.position(),g=d.top,e=d.left):(g=parseFloat(f)||0,e=parseFloat(i)||0),m.isFunction(b)&&(b=b.call(a,c,h)),null!=b.top&&(n.top=b.top-h.top+g),null!=b.left&&(n.left=b.left-h.left+e),"using"in b?b.using.call(a,n):l.css(n)}},m.fn.extend({offset:function(a){if(arguments.length)return void 0===a?this:this.each(function(b){m.offset.setOffset(this,a,b)});var b,c,d={top:0,left:0},e=this[0],f=e&&e.ownerDocument;if(f)return b=f.documentElement,m.contains(b,e)?(typeof e.getBoundingClientRect!==K&&(d=e.getBoundingClientRect()),c=dc(f),{top:d.top+(c.pageYOffset||b.scrollTop)-(b.clientTop||0),left:d.left+(c.pageXOffset||b.scrollLeft)-(b.clientLeft||0)}):d},position:function(){if(this[0]){var a,b,c={top:0,left:0},d=this[0];return"fixed"===m.css(d,"position")?b=d.getBoundingClientRect():(a=this.offsetParent(),b=this.offset(),m.nodeName(a[0],"html")||(c=a.offset()),c.top+=m.css(a[0],"borderTopWidth",!0),c.left+=m.css(a[0],"borderLeftWidth",!0)),{top:b.top-c.top-m.css(d,"marginTop",!0),left:b.left-c.left-m.css(d,"marginLeft",!0)}}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||cc;while(a&&!m.nodeName(a,"html")&&"static"===m.css(a,"position"))a=a.offsetParent;return a||cc})}}),m.each({scrollLeft:"pageXOffset",scrollTop:"pageYOffset"},function(a,b){var c=/Y/.test(b);m.fn[a]=function(d){return V(this,function(a,d,e){var f=dc(a);return void 0===e?f?b in f?f[b]:f.document.documentElement[d]:a[d]:void(f?f.scrollTo(c?m(f).scrollLeft():e,c?e:m(f).scrollTop()):a[d]=e)},a,d,arguments.length,null)}}),m.each(["top","left"],function(a,b){m.cssHooks[b]=La(k.pixelPosition,function(a,c){return c?(c=Ja(a,b),Ha.test(c)?m(a).position()[b]+"px":c):void 0})}),m.each({Height:"height",Width:"width"},function(a,b){m.each({padding:"inner"+a,content:b,"":"outer"+a},function(c,d){m.fn[d]=function(d,e){var f=arguments.length&&(c||"boolean"!=typeof d),g=c||(d===!0||e===!0?"margin":"border");return V(this,function(b,c,d){var e;return m.isWindow(b)?b.document.documentElement["client"+a]:9===b.nodeType?(e=b.documentElement,Math.max(b.body["scroll"+a],e["scroll"+a],b.body["offset"+a],e["offset"+a],e["client"+a])):void 0===d?m.css(b,c,g):m.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),m.fn.size=function(){return this.length},m.fn.andSelf=m.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return m});var ec=a.jQuery,fc=a.$;return m.noConflict=function(b){return a.$===m&&(a.$=fc),b&&a.jQuery===m&&(a.jQuery=ec),m},typeof b===K&&(a.jQuery=a.$=m),m});
/*! jquery-dateformat 01-08-2019 */
var DateFormat = {};
!(function (e) {
var I = [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
],
O = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
v = [
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
],
w = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
],
a = {
Jan: "01",
Feb: "02",
Mar: "03",
Apr: "04",
May: "05",
Jun: "06",
Jul: "07",
Aug: "08",
Sep: "09",
Oct: "10",
Nov: "11",
Dec: "12",
},
u = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.?\d{0,3}[Z\-+]?(\d{2}:?\d{2})?/;
DateFormat.format = (function () {
function o(e) {
return a[e] || e;
}
function i(e) {
var a,
r,
t,
n,
s,
o = e,
i = "";
return (
-1 !== o.indexOf(".") &&
((o = (n = o.split("."))[0]), (i = n[n.length - 1])),
3 <= (s = o.split(":")).length
? ((a = s[0]),
(r = s[1]),
(t = s[2].replace(/\s.+/, "").replace(/[a-z]/gi, "")),
{
time: (o = o.replace(/\s.+/, "").replace(/[a-z]/gi, "")),
hour: a,
minute: r,
second: t,
millis: i,
})
: { time: "", hour: "", minute: "", second: "", millis: "" }
);
}
function D(e, a) {
for (var r = a - String(e).length, t = 0; t < r; t++) e = "0" + e;
return e;
}
return {
parseDate: function (e) {
var a,
r,
t = {
date: null,
year: null,
month: null,
dayOfMonth: null,
dayOfWeek: null,
time: null,
};
if ("number" == typeof e) return this.parseDate(new Date(e));
if ("function" == typeof e.getFullYear)
(t.year = String(e.getFullYear())),
(t.month = String(e.getMonth() + 1)),
(t.dayOfMonth = String(e.getDate())),
(t.time = i(e.toTimeString() + "." + e.getMilliseconds()));
else if (-1 != e.search(u))
(a = e.split(/[T\+-]/)),
(t.year = a[0]),
(t.month = a[1]),
(t.dayOfMonth = a[2]),
(t.time = i(a[3].split(".")[0]));
else
switch (
(6 === (a = e.split(" ")).length &&
isNaN(a[5]) &&
(a[a.length] = "()"),
a.length)
) {
case 6:
(t.year = a[5]),
(t.month = o(a[1])),
(t.dayOfMonth = a[2]),
(t.time = i(a[3]));
break;
case 2:
(r = a[0].split("-")),
(t.year = r[0]),
(t.month = r[1]),
(t.dayOfMonth = r[2]),
(t.time = i(a[1]));
break;
case 7:
case 9:
case 10:
t.year = a[3];
var n = parseInt(a[1]),
s = parseInt(a[2]);
n && !s
? ((t.month = o(a[2])), (t.dayOfMonth = a[1]))
: ((t.month = o(a[1])), (t.dayOfMonth = a[2])),
(t.time = i(a[4]));
break;
case 1:
(r = a[0].split("")),
(t.year = r[0] + r[1] + r[2] + r[3]),
(t.month = r[5] + r[6]),
(t.dayOfMonth = r[8] + r[9]),
(t.time = i(
r[13] + r[14] + r[15] + r[16] + r[17] + r[18] + r[19] + r[20]
));
break;
default:
return null;
}
return (
t.time
? (t.date = new Date(
t.year,
t.month - 1,
t.dayOfMonth,
t.time.hour,
t.time.minute,
t.time.second,
t.time.millis
))
: (t.date = new Date(t.year, t.month - 1, t.dayOfMonth)),
(t.dayOfWeek = String(t.date.getDay())),
t
);
},
date: function (a, e) {
try {
var r = this.parseDate(a);
if (null === r) return a;
for (
var t,
n = r.year,
s = r.month,
o = r.dayOfMonth,
i = r.dayOfWeek,
u = r.time,
c = "",
h = "",
l = "",
m = !1,
y = 0;
y < e.length;
y++
) {
var d = e.charAt(y),
f = e.charAt(y + 1);
if (m)
"'" == d
? ((h += "" === c ? "'" : c), (c = ""), (m = !1))
: (c += d);
else
switch (((l = ""), (c += d))) {
case "ddd":
(h += ((S = i), I[parseInt(S, 10)] || S)), (c = "");
break;
case "dd":
if ("d" === f) break;
(h += D(o, 2)), (c = "");
break;
case "d":
if ("d" === f) break;
(h += parseInt(o, 10)), (c = "");
break;
case "D":
(h += o =
1 == o || 21 == o || 31 == o
? parseInt(o, 10) + "st"
: 2 == o || 22 == o
? parseInt(o, 10) + "nd"
: 3 == o || 23 == o
? parseInt(o, 10) + "rd"
: parseInt(o, 10) + "th"),
(c = "");
break;
case "MMMM":
(h +=
((M = s), void 0, (g = parseInt(M, 10) - 1), w[g] || M)),
(c = "");
break;
case "MMM":
if ("M" === f) break;
(h +=
((k = s), void 0, (p = parseInt(k, 10) - 1), v[p] || k)),
(c = "");
break;
case "MM":
if ("M" === f) break;
(h += D(s, 2)), (c = "");
break;
case "M":
if ("M" === f) break;
(h += parseInt(s, 10)), (c = "");
break;
case "y":
case "yyy":
if ("y" === f) break;
(h += c), (c = "");
break;
case "yy":
if ("y" === f) break;
(h += String(n).slice(-2)), (c = "");
break;
case "yyyy":
(h += n), (c = "");
break;
case "HH":
(h += D(u.hour, 2)), (c = "");
break;
case "H":
if ("H" === f) break;
(h += parseInt(u.hour, 10)), (c = "");
break;
case "hh":
(h += D(
(t =
0 === parseInt(u.hour, 10)
? 12
: u.hour < 13
? u.hour
: u.hour - 12),
2
)),
(c = "");
break;
case "h":
if ("h" === f) break;
(t =
0 === parseInt(u.hour, 10)
? 12
: u.hour < 13
? u.hour
: u.hour - 12),
(h += parseInt(t, 10)),
(c = "");
break;
case "mm":
(h += D(u.minute, 2)), (c = "");
break;
case "m":
if ("m" === f) break;
(h += parseInt(u.minute, 10)), (c = "");
break;
case "ss":
(h += D(u.second.substring(0, 2), 2)), (c = "");
break;
case "s":
if ("s" === f) break;
(h += parseInt(u.second, 10)), (c = "");
break;
case "S":
case "SS":
if ("S" === f) break;
(h += c), (c = "");
break;
case "SSS":
(h += D(u.millis.substring(0, 3), 3)), (c = "");
break;
case "a":
(h += 12 <= u.hour ? "PM" : "AM"), (c = "");
break;
case "p":
(h += 12 <= u.hour ? "p.m." : "a.m."), (c = "");
break;
case "E":
(h += ((b = i), O[parseInt(b, 10)] || b)), (c = "");
break;
case "'":
(c = ""), (m = !0);
break;
default:
(h += d), (c = "");
}
}
return (h += l);
} catch (e) {
return console && console.log && console.log(e), a;
}
var b, k, p, M, g, S;
},
prettyDate: function (e) {
var a, r, t, n, s;
if (
(("string" != typeof e && "number" != typeof e) || (a = new Date(e)),
"object" == typeof e && (a = new Date(e.toString())),
(r = (new Date().getTime() - a.getTime()) / 1e3),
(t = Math.abs(r)),
(n = Math.floor(t / 86400)),
!isNaN(n))
)
return (
(s = r < 0 ? "from now" : "ago"),
t < 60
? 0 <= r
? "just now"
: "in a moment"
: t < 120
? "1 minute " + s
: t < 3600
? Math.floor(t / 60) + " minutes " + s
: t < 7200
? "1 hour " + s
: t < 86400
? Math.floor(t / 3600) + " hours " + s
: 1 === n
? 0 <= r
? "Yesterday"
: "Tomorrow"
: n < 7
? n + " days " + s
: 7 === n
? "1 week " + s
: n < 31
? Math.ceil(n / 7) + " weeks " + s
: "more than 5 weeks " + s
);
},
toBrowserTimeZone: function (e, a) {
return this.date(new Date(e), a || "MM/dd/yyyy HH:mm:ss");
},
};
})();
})(),
(jQuery.format = DateFormat.format);
WeblabClinical.printing = {
_printers: null,
module: WeblabClinical.localPrintingMethod.split(".")[0], // Split removes possible ".js" ending
getPrinters: function (callback) {
if (this._printers) {
callback(null, this._printers);
}
WeblabClinical.printing[WeblabClinical.printing.module].listWorkstationPrintQueues(function (err, printers) {
this._printers = printers;
callback(err, this._printers);
}.bind(this));
}.bind(WeblabClinical.printing),
noPrinterSelectionText: '[ EI VALITTU ]',
printersAtLocalStorage: 'nxprint-local-correspondings',
setCorrespondLocalPrinter: function (kernelDeviceName, localPrinterName) {
var devices = this._getLocalStorageObject(this.printersAtLocalStorage);
devices = (devices !== null && typeof devices === 'object') ? devices : {};
devices[this._stripSpaces(kernelDeviceName)] = localPrinterName;
this._setLocalStorageObject(this.printersAtLocalStorage, devices);
},
getCorrespondLocalPrinter: function (kernelDeviceName) {
var devices = this._getLocalStorageObject(this.printersAtLocalStorage);
if (!devices) {
return undefined;
}
return devices[this._stripSpaces(kernelDeviceName)];
},
_setLocalStorageObject: function (key, object) {
localStorage.setItem(key, JSON.stringify(object));
},
_getLocalStorageObject: function (key) {
return JSON.parse(localStorage.getItem(key));
},
_stripSpaces: function (str) {
return str.replace(" ", "");
},
getPrinterDetails: function (windowsDeviceName, onDetailsCallback) {
WeblabClinical.printing[WeblabClinical.printing.module].getPrinterDetails(windowsDeviceName, onDetailsCallback);
}
};
WeblabClinical.onAfterPrint = function (err, result) {
if (err && err.status !== 'success') {
var message = 'exit code: ' + err.exit_code + '\n';
message += 'status: ' + err.status + '\n';
message += 'stderr: ' + err.stderr + '\n';
message += 'stdout: ' + err.stdout + '\n';
alert("Tulostus ep�onnistui: /n" + message);
}
};
WeblabClinical.print = function (print) {
var printerName = WeblabClinical.printing.getCorrespondLocalPrinter(print.device);
if (print.localdevice) {
printerName = print.localdevice
}
if (!printerName || printerName === '-') {
WeblabClinical.clearFailedPrint(print, function () {
alert('Ty�asemalta ei l�ydy yhteensopivaa paikkallistulostinta. Tarkista asetukset toiminnossa K�ytt�j�/Tulostimet.');
});
return;
}
WeblabClinical.printing[WeblabClinical.printing.module].listWorkstationPrintQueues(function (err, printers) {
if (err) {
return; // by not returning false, NX displays the error to the use
}
var printerFound = false;
$.each(printers, function (key, value) {
if (printerName === value) {
printerFound = true;
return false; // Pys�ytt�� loopin
}
});
if (print.url) {
WeblabClinical.printing[WeblabClinical.printing.module].print_file_http(
printerName,
document.location.protocol + '//' + document.location.hostname + print.url,
'Weblab Clinical',
WeblabClinical.onAfterPrint,
function (err, response) { if (err) { return; } /* not interested in success */ }
);
return
}
if (print.data) {
WeblabClinical.printing[WeblabClinical.printing.module].print_file_stdin(
printerName,
print.data,
'Weblab Clinical',
WeblabClinical.onAfterPrint,
function (err, response) { if (err) { return; } /* not interested in success */ }
);
}
});
};
WeblabClinical.clearFailedPrint = function (print, onSuccess) {
$.ajax({
url: print.clearUrl,
success: onSuccess
});
};
WeblabClinical.printing.myPlusDevices = {
_workstationPrintQueues: [],
_loadWorkstationPrintQueues: function (onReadyCallback) {
$.ajax({
url: WeblabClinical._myPlusDevices_url_devices,
success: function (response) {
WeblabClinical.printing.myPlusDevices._workstationPrintQueues = response;
onReadyCallback();
},
});
},
_getWorkstationPrintQueuesAsNxFormat: function () {
var myPlusDevices = WeblabClinical.printing.myPlusDevices._workstationPrintQueues;
var printers = [];
for (var i = 0; i < myPlusDevices.length; i++) {
printers.push(myPlusDevices[i].printerName);
}
return printers;
},
listWorkstationPrintQueues: function (callback) {
WeblabClinical.printing.myPlusDevices._loadWorkstationPrintQueues(function () {
callback(
null,
WeblabClinical.printing.myPlusDevices._getWorkstationPrintQueuesAsNxFormat()
);
});
},
getPrinterDetails: function (windowsDeviceName, onDetailsCallback) {
var driverName = WeblabClinical.printing.myPlusDevices._getPrintQueueProperty(windowsDeviceName, 'printerDriverName');
var driver = {
stdout_json: {
driver_name: driverName
}
};
onDetailsCallback(false, driver);
},
_getPrintQueueProperty: function (printerName, propertyName) {
var myPlusDevices = WeblabClinical.printing.myPlusDevices._workstationPrintQueues;
var matches = myPlusDevices.filter(function (p) {
return p.printerName == printerName;
});
return matches[0][propertyName];
},
print_file_http: function (
printerName,
printUrl,
fileName,
onAfterPrint,
successCallback) {
var oReq = new XMLHttpRequest();
oReq.open("GET", printUrl, true);
oReq.responseType = "blob";
oReq.onload = function(oEvent) {
var blob = oReq.response;
WeblabClinical.printing.myPlusDevices._print(
printerName,
blob,
fileName,
function () {
onAfterPrint();
successCallback();
});
};
oReq.send();
},
print_file_stdin: function (
printerName,
printData,
fileName,
onAfterPrint,
successCallback) {
WeblabClinical.printing.myPlusDevices._print(
printerName,
printData,
fileName,
function () {
onAfterPrint();
successCallback();
});
},
_print: function (printerName, printData, fileName, onSuccessCallback) {
$.ajax({
url: WeblabClinical._myPlusDevices_url_print,
method: "POST",
contentType: false,
processData: false,
cache: false,
data: WeblabClinical.printing.myPlusDevices._toFormData(printerName, printData, fileName),
success: onSuccessCallback
});
},
_toFormData: function (printerName, printData, fileName) {
var formData = new FormData();
formData.append("printProperties", JSON.stringify({
printerName: printerName
}));
formData.append("fileProperties", JSON.stringify({
printFileType: "LABEL_RAW"
}));
formData.append("file", new Blob(
[printData],
{ type: "text/plain" },
fileName
));
return formData;
}
}
/* Native Extensions ("NX")
... is a technology that allows the browser to interact with native applications outside of the browser.
Example:
NX
.createApplicationContext('my-scanner-plugin')
.execute('scan-picture-to-web', ['http://url.to/receive-scanned-image'], function (){ ... });
Handling errors:
- Errors are first triggered on the execute() call. If you registered an error handler, it gets called.
- If above error handler does not return false, the error is broadcast in DOM
- If DOM event handler does not call .preventDefault(), internal UI dialog is shown to indicate the error. Error could be:
* NX is not installed
* The requested NX app ("plugin") is not installed
* The requested website has not been authorized to
Known issues:
- If NX server stops after handshake, it is not detected by this NX client. Will fix it later.
Request flow:
- Either call check() or indirectly call _send() (see code example above)
-