@olenbetong/appframe-core 2.10.2 → 2.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/af.common.js +131 -146
- package/dist/esm/af.common.legacy.js +137 -152
- package/dist/esm/af.common.legacy.min.js +1 -1
- package/dist/esm/af.common.legacy.min.js.map +4 -4
- package/dist/esm/af.common.min.js +2 -2
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +131 -146
- package/dist/iife/af.common.legacy.js +137 -152
- package/dist/iife/af.common.legacy.min.js +1 -1
- package/dist/iife/af.common.legacy.min.js.map +4 -4
- package/dist/iife/af.common.min.js +2 -2
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/SessionHandler.js +1 -3
- package/es/UserSession.js +33 -29
- package/es/date.d.ts +16 -0
- package/es/date.js +15 -3
- package/es/date.test.d.ts +1 -0
- package/es/date.test.js +23 -0
- package/es/downloadRequest.js +6 -11
- package/es/errorHandler.d.ts +1 -0
- package/es/errorHandler.js +5 -21
- package/es/expose.d.ts +1 -1
- package/es/expose.test.d.ts +10 -0
- package/es/expose.test.js +36 -0
- package/es/getUserImage.test.d.ts +1 -0
- package/es/getUserImage.test.js +30 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +2 -2
- package/es/invariant.test.d.ts +1 -0
- package/es/invariant.test.js +19 -0
- package/es/localStorage.js +1 -3
- package/es/parseFunc.js +1 -1
- package/es/parseFunc.test.d.ts +1 -0
- package/es/parseFunc.test.js +14 -0
- package/package.json +5 -3
- package/src/date.test.ts +27 -0
- package/src/date.ts +22 -3
- package/src/downloadRequest.ts +6 -12
- package/src/errorHandler.ts +6 -21
- package/src/expose.test.ts +59 -0
- package/src/expose.ts +1 -1
- package/src/getUserImage.test.ts +50 -0
- package/src/index.ts +1 -1
- package/src/invariant.test.ts +23 -0
- package/src/parseFunc.test.ts +17 -0
- package/src/parseFunc.ts +1 -1
|
@@ -65,6 +65,7 @@ af.common = (() => {
|
|
|
65
65
|
saveSettings: () => saveSettings,
|
|
66
66
|
startActivity: () => startActivity,
|
|
67
67
|
time: () => time,
|
|
68
|
+
toLocalDateTime: () => toLocalDateTime,
|
|
68
69
|
toLocalISODate: () => toLocalISODate,
|
|
69
70
|
toLocalISODateTime: () => toLocalISODateTime,
|
|
70
71
|
version: () => version,
|
|
@@ -185,29 +186,131 @@ af.common = (() => {
|
|
|
185
186
|
}
|
|
186
187
|
};
|
|
187
188
|
|
|
189
|
+
// src/log.ts
|
|
190
|
+
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
191
|
+
var _a2;
|
|
192
|
+
try {
|
|
193
|
+
let response = await fetch("/api/logging/log-activity", {
|
|
194
|
+
method: "POST",
|
|
195
|
+
body: JSON.stringify({
|
|
196
|
+
article: af.article.id,
|
|
197
|
+
timeElapsed,
|
|
198
|
+
action: activity,
|
|
199
|
+
parameters: __spreadProps(__spreadValues({}, parameters), {
|
|
200
|
+
_session: getSessionData()
|
|
201
|
+
})
|
|
202
|
+
}),
|
|
203
|
+
headers: { "Content-Type": "application/json", Accept: "application/json" }
|
|
204
|
+
});
|
|
205
|
+
if (!response.ok) {
|
|
206
|
+
if ((_a2 = response.headers.get("Content-Type")) == null ? void 0 : _a2.includes("application/json")) {
|
|
207
|
+
let data = await response.json();
|
|
208
|
+
console.error(data.error);
|
|
209
|
+
} else {
|
|
210
|
+
console.error("".concat(response.status, " ").concat(response.statusText));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
} catch (error) {
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
function startActivity(activity, startParameters = {}) {
|
|
217
|
+
let start = performance.now();
|
|
218
|
+
return (endParameters = {}) => logActivity(activity, __spreadValues(__spreadValues({}, startParameters), endParameters), performance.now() - start);
|
|
219
|
+
}
|
|
220
|
+
async function time(callback) {
|
|
221
|
+
let start = performance.now();
|
|
222
|
+
let returnValue = await callback();
|
|
223
|
+
return [returnValue, performance.now() - start];
|
|
224
|
+
}
|
|
225
|
+
async function logError(error) {
|
|
226
|
+
var _a2;
|
|
227
|
+
try {
|
|
228
|
+
if (!error)
|
|
229
|
+
return;
|
|
230
|
+
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
231
|
+
error: error.message,
|
|
232
|
+
stack: (_a2 = error.stack) != null ? _a2 : null
|
|
233
|
+
} : { error: error.toString() } : { error: "Unspecified error" };
|
|
234
|
+
console.error(error);
|
|
235
|
+
let result = await fetch("/data/Logger/LogError", {
|
|
236
|
+
method: "POST",
|
|
237
|
+
body: JSON.stringify(data),
|
|
238
|
+
headers: {
|
|
239
|
+
"Content-Type": "application/json; charset=utf-8"
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
if (result.ok) {
|
|
243
|
+
return await result.json();
|
|
244
|
+
}
|
|
245
|
+
console.error(Error("Failed to log error"));
|
|
246
|
+
} catch (e) {
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
function getSessionId() {
|
|
250
|
+
var _a2;
|
|
251
|
+
return (_a2 = crypto.randomUUID) == null ? void 0 : _a2.call(crypto);
|
|
252
|
+
}
|
|
253
|
+
var sessionStart = Date.now();
|
|
254
|
+
var sessionId = getSessionId();
|
|
255
|
+
var deviceId = "";
|
|
256
|
+
var browserSessionId = "";
|
|
257
|
+
if ("document" in window) {
|
|
258
|
+
let startSession = () => {
|
|
259
|
+
var _a2;
|
|
260
|
+
return logActivity("AfSessionInit", {
|
|
261
|
+
"appframe-core": af.common.version,
|
|
262
|
+
"appframe-data": (_a2 = af.data) == null ? void 0 : _a2.version,
|
|
263
|
+
"app-version": af.article.version
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
267
|
+
deviceId = localStorage.getItem("_afDeviceId");
|
|
268
|
+
browserSessionId = sessionStorage.getItem("_afSessionId");
|
|
269
|
+
if (!deviceId) {
|
|
270
|
+
deviceId = getSessionId();
|
|
271
|
+
localStorage.setItem("_afDeviceId", deviceId);
|
|
272
|
+
}
|
|
273
|
+
if (!browserSessionId) {
|
|
274
|
+
browserSessionId = sessionId;
|
|
275
|
+
sessionStorage.setItem("_afSessionId", browserSessionId);
|
|
276
|
+
}
|
|
277
|
+
startSession();
|
|
278
|
+
});
|
|
279
|
+
document.addEventListener("visibilitychange", function logData() {
|
|
280
|
+
if (document.visibilityState === "hidden") {
|
|
281
|
+
navigator.sendBeacon(
|
|
282
|
+
"/api/logging/log-activity",
|
|
283
|
+
JSON.stringify({
|
|
284
|
+
article: af.article.id,
|
|
285
|
+
action: "AfSessionEnd",
|
|
286
|
+
parameters: {
|
|
287
|
+
_session: getSessionData()
|
|
288
|
+
}
|
|
289
|
+
})
|
|
290
|
+
);
|
|
291
|
+
} else {
|
|
292
|
+
startSession();
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function getSessionData() {
|
|
297
|
+
return {
|
|
298
|
+
browserSessionId,
|
|
299
|
+
sessionStart,
|
|
300
|
+
sessionLength: Date.now() - sessionStart,
|
|
301
|
+
sessionId,
|
|
302
|
+
deviceId
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
|
|
188
306
|
// src/errorHandler.ts
|
|
189
307
|
var _a;
|
|
190
308
|
if (true) {
|
|
191
309
|
(_a = window.window) == null ? void 0 : _a.addEventListener("error", (event) => {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
file: event.filename,
|
|
197
|
-
line: (_d = event.lineno) != null ? _d : 0,
|
|
198
|
-
column: (_e = event.colno) != null ? _e : 0,
|
|
199
|
-
stack: (_g = (_f = event.error) == null ? void 0 : _f.stack) != null ? _g : null
|
|
200
|
-
};
|
|
201
|
-
fetch("/data/Logger/LogError", {
|
|
202
|
-
body: JSON.stringify(data),
|
|
203
|
-
headers: {
|
|
204
|
-
Accept: "application/json",
|
|
205
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
206
|
-
"X-Requested-With": "XMLHttpRequest"
|
|
207
|
-
},
|
|
208
|
-
method: "POST"
|
|
209
|
-
});
|
|
210
|
-
} catch (ex) {
|
|
310
|
+
if (typeof event === "object" && "error" in event) {
|
|
311
|
+
logError(event.error);
|
|
312
|
+
} else if (typeof event === "object" && "message" in event) {
|
|
313
|
+
logError(event);
|
|
211
314
|
}
|
|
212
315
|
});
|
|
213
316
|
}
|
|
@@ -256,13 +359,16 @@ af.common = (() => {
|
|
|
256
359
|
function toLocalISODate(date) {
|
|
257
360
|
return date ? toLocalISODateTime(date).substring(0, 10) : null;
|
|
258
361
|
}
|
|
259
|
-
function pad(num) {
|
|
260
|
-
return String(num).padStart(
|
|
362
|
+
function pad(num, digits = 2) {
|
|
363
|
+
return String(num).padStart(digits, "0");
|
|
261
364
|
}
|
|
262
365
|
function toLocalISODateTime(date) {
|
|
263
366
|
return date ? "".concat(date.getFullYear(), "-").concat(pad(date.getMonth() + 1), "-").concat(pad(date.getDate()), "T").concat(pad(date.getHours()), ":").concat(pad(
|
|
264
367
|
date.getMinutes()
|
|
265
|
-
), ":").concat(pad(date.getSeconds()), ".").concat(pad(date.getMilliseconds())) : null;
|
|
368
|
+
), ":").concat(pad(date.getSeconds()), ".").concat(pad(date.getMilliseconds(), 3)) : null;
|
|
369
|
+
}
|
|
370
|
+
function toLocalDateTime(date) {
|
|
371
|
+
return date ? date.toISOString().substring(0, 16) : "";
|
|
266
372
|
}
|
|
267
373
|
|
|
268
374
|
// src/downloadBlob.ts
|
|
@@ -299,13 +405,8 @@ af.common = (() => {
|
|
|
299
405
|
// src/downloadRequest.ts
|
|
300
406
|
async function downloadRequest(request, { fileName, signal, onProgress }) {
|
|
301
407
|
var _a2;
|
|
302
|
-
function reportProgress(progress) {
|
|
303
|
-
if (typeof onProgress === "function") {
|
|
304
|
-
onProgress(__spreadValues({}, progress));
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
408
|
let bytesReceived = 0;
|
|
308
|
-
|
|
409
|
+
onProgress == null ? void 0 : onProgress({ status: "requested" });
|
|
309
410
|
try {
|
|
310
411
|
let response = await fetch(request);
|
|
311
412
|
if (!response.ok || !response.body) {
|
|
@@ -326,7 +427,7 @@ af.common = (() => {
|
|
|
326
427
|
return;
|
|
327
428
|
}
|
|
328
429
|
bytesReceived += read.value.length;
|
|
329
|
-
|
|
430
|
+
onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloading" });
|
|
330
431
|
controller.enqueue(read.value);
|
|
331
432
|
return pump();
|
|
332
433
|
});
|
|
@@ -338,14 +439,14 @@ af.common = (() => {
|
|
|
338
439
|
} catch (error) {
|
|
339
440
|
}
|
|
340
441
|
const blob = await response.blob();
|
|
341
|
-
|
|
442
|
+
onProgress == null ? void 0 : onProgress({ bytesReceived, status: "downloaded" });
|
|
342
443
|
await downloadBlob(blob, fileName);
|
|
343
|
-
|
|
444
|
+
onProgress == null ? void 0 : onProgress({ bytesReceived, status: "completed" });
|
|
344
445
|
} catch (err) {
|
|
345
446
|
if (signal == null ? void 0 : signal.aborted) {
|
|
346
|
-
|
|
447
|
+
onProgress == null ? void 0 : onProgress({ status: "cancelled" });
|
|
347
448
|
} else {
|
|
348
|
-
|
|
449
|
+
onProgress == null ? void 0 : onProgress({ error: err.message, status: "error" });
|
|
349
450
|
}
|
|
350
451
|
}
|
|
351
452
|
}
|
|
@@ -358,9 +459,10 @@ af.common = (() => {
|
|
|
358
459
|
// src/parseFunc.ts
|
|
359
460
|
var funcRegex = /^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;
|
|
360
461
|
function parseFunc(func) {
|
|
462
|
+
var _a2;
|
|
361
463
|
var match = func.toString().match(funcRegex);
|
|
362
464
|
invariant(match, "Unable to parse function!");
|
|
363
|
-
return { name: match[1], args: match[2].split(","), body: match[3] };
|
|
465
|
+
return { name: (_a2 = func.name) != null ? _a2 : match[1], args: match[2].split(",").map((a) => a.trim()), body: match[3] };
|
|
364
466
|
}
|
|
365
467
|
|
|
366
468
|
// src/Namespace.ts
|
|
@@ -499,123 +601,6 @@ af.common = (() => {
|
|
|
499
601
|
return localized;
|
|
500
602
|
}
|
|
501
603
|
|
|
502
|
-
// src/log.ts
|
|
503
|
-
async function logActivity(activity, parameters = {}, timeElapsed = 0) {
|
|
504
|
-
var _a2;
|
|
505
|
-
try {
|
|
506
|
-
let response = await fetch("/api/logging/log-activity", {
|
|
507
|
-
method: "POST",
|
|
508
|
-
body: JSON.stringify({
|
|
509
|
-
article: af.article.id,
|
|
510
|
-
timeElapsed,
|
|
511
|
-
action: activity,
|
|
512
|
-
parameters: __spreadProps(__spreadValues({}, parameters), {
|
|
513
|
-
_session: getSessionData()
|
|
514
|
-
})
|
|
515
|
-
}),
|
|
516
|
-
headers: { "Content-Type": "application/json", Accept: "application/json" }
|
|
517
|
-
});
|
|
518
|
-
if (!response.ok) {
|
|
519
|
-
if ((_a2 = response.headers.get("Content-Type")) == null ? void 0 : _a2.includes("application/json")) {
|
|
520
|
-
let data = await response.json();
|
|
521
|
-
console.error(data.error);
|
|
522
|
-
} else {
|
|
523
|
-
console.error("".concat(response.status, " ").concat(response.statusText));
|
|
524
|
-
}
|
|
525
|
-
}
|
|
526
|
-
} catch (error) {
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
function startActivity(activity, startParameters = {}) {
|
|
530
|
-
let start = performance.now();
|
|
531
|
-
return (endParameters = {}) => logActivity(activity, __spreadValues(__spreadValues({}, startParameters), endParameters), performance.now() - start);
|
|
532
|
-
}
|
|
533
|
-
async function time(callback) {
|
|
534
|
-
let start = performance.now();
|
|
535
|
-
let returnValue = await callback();
|
|
536
|
-
return [returnValue, performance.now() - start];
|
|
537
|
-
}
|
|
538
|
-
async function logError(error) {
|
|
539
|
-
var _a2;
|
|
540
|
-
try {
|
|
541
|
-
if (!error)
|
|
542
|
-
return;
|
|
543
|
-
let data = typeof error === "string" ? { error } : typeof error === "object" ? "message" in error ? {
|
|
544
|
-
error: error.message,
|
|
545
|
-
stack: (_a2 = error.stack) != null ? _a2 : null
|
|
546
|
-
} : { error: error.toString() } : { error: "Unspecified error" };
|
|
547
|
-
console.error(error);
|
|
548
|
-
let result = await fetch("/data/Logger/LogError", {
|
|
549
|
-
method: "POST",
|
|
550
|
-
body: JSON.stringify(data),
|
|
551
|
-
headers: {
|
|
552
|
-
"Content-Type": "application/json; charset=utf-8"
|
|
553
|
-
}
|
|
554
|
-
});
|
|
555
|
-
if (result.ok) {
|
|
556
|
-
return await result.json();
|
|
557
|
-
}
|
|
558
|
-
console.error(Error("Failed to log error"));
|
|
559
|
-
} catch (e) {
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
function getSessionId() {
|
|
563
|
-
var _a2;
|
|
564
|
-
return (_a2 = crypto.randomUUID) == null ? void 0 : _a2.call(crypto);
|
|
565
|
-
}
|
|
566
|
-
var sessionStart = Date.now();
|
|
567
|
-
var sessionId = getSessionId();
|
|
568
|
-
var deviceId = "";
|
|
569
|
-
var browserSessionId = "";
|
|
570
|
-
if ("document" in window) {
|
|
571
|
-
let startSession = () => {
|
|
572
|
-
var _a2;
|
|
573
|
-
return logActivity("AfSessionInit", {
|
|
574
|
-
"appframe-core": af.common.version,
|
|
575
|
-
"appframe-data": (_a2 = af.data) == null ? void 0 : _a2.version,
|
|
576
|
-
"app-version": af.article.version
|
|
577
|
-
});
|
|
578
|
-
};
|
|
579
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
580
|
-
deviceId = localStorage.getItem("_afDeviceId");
|
|
581
|
-
browserSessionId = sessionStorage.getItem("_afSessionId");
|
|
582
|
-
if (!deviceId) {
|
|
583
|
-
deviceId = getSessionId();
|
|
584
|
-
localStorage.setItem("_afDeviceId", deviceId);
|
|
585
|
-
}
|
|
586
|
-
if (!browserSessionId) {
|
|
587
|
-
browserSessionId = sessionId;
|
|
588
|
-
sessionStorage.setItem("_afSessionId", browserSessionId);
|
|
589
|
-
}
|
|
590
|
-
startSession();
|
|
591
|
-
});
|
|
592
|
-
document.addEventListener("visibilitychange", function logData() {
|
|
593
|
-
if (document.visibilityState === "hidden") {
|
|
594
|
-
navigator.sendBeacon(
|
|
595
|
-
"/api/logging/log-activity",
|
|
596
|
-
JSON.stringify({
|
|
597
|
-
article: af.article.id,
|
|
598
|
-
action: "AfSessionEnd",
|
|
599
|
-
parameters: {
|
|
600
|
-
_session: getSessionData()
|
|
601
|
-
}
|
|
602
|
-
})
|
|
603
|
-
);
|
|
604
|
-
} else {
|
|
605
|
-
startSession();
|
|
606
|
-
}
|
|
607
|
-
});
|
|
608
|
-
}
|
|
609
|
-
function getSessionData() {
|
|
610
|
-
return {
|
|
611
|
-
browserSessionId,
|
|
612
|
-
sessionStart,
|
|
613
|
-
sessionLength: Date.now() - sessionStart,
|
|
614
|
-
sessionId,
|
|
615
|
-
deviceId
|
|
616
|
-
};
|
|
617
|
-
}
|
|
618
|
-
|
|
619
604
|
// src/settings.ts
|
|
620
605
|
function getKey(article) {
|
|
621
606
|
const articleKey = article || af.article.id;
|
|
@@ -748,6 +733,6 @@ af.common = (() => {
|
|
|
748
733
|
}
|
|
749
734
|
|
|
750
735
|
// src/index.ts
|
|
751
|
-
var version = "2.
|
|
736
|
+
var version = "2.11.1";
|
|
752
737
|
return __toCommonJS(src_exports);
|
|
753
738
|
})();
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var af=af||{};af.common=(()=>{var I=Object.defineProperty,de=Object.defineProperties,ge=Object.getOwnPropertyDescriptor,fe=Object.getOwnPropertyDescriptors,pe=Object.getOwnPropertyNames,q=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable;var N=(e,t,n)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,f=(e,t)=>{for(var n in t||(t={}))k.call(t,n)&&N(e,n,t[n]);if(q)for(var n of q(t))me.call(t,n)&&N(e,n,t[n]);return e},B=(e,t)=>de(e,fe(t));var ye=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},he=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of pe(t))!k.call(e,r)&&r!==n&&I(e,r,{get:()=>t[r],enumerable:!(o=ge(t,r))||o.enumerable});return e};var Se=e=>he(I({},"__esModule",{value:!0}),e);var s=(e,t,n)=>(N(e,typeof t!="symbol"?t+"":t,n),n);var De={};ye(De,{ConfirmButtons:()=>M,SessionHandler:()=>m,UserSession:()=>E,alert:()=>le,confirm:()=>se,downloadBlob:()=>T,downloadRequest:()=>Z,expose:()=>U,getLocalizedString:()=>d,getSessionData:()=>O,getSettings:()=>ie,getUserImage:()=>_,has:()=>h,invariant:()=>u,localStorage:()=>K,localize:()=>W,logActivity:()=>z,logError:()=>te,mitt:()=>L,openAlertDialog:()=>j,saveSettings:()=>ae,startActivity:()=>Q,time:()=>ee,toLocalISODate:()=>V,toLocalISODateTime:()=>$,version:()=>Ae,waitForDialog:()=>H});function L(e){return{all:e=e||new Map,on:function(t,n){var o=e.get(t);o?o.push(n):e.set(t,[n])},off:function(t,n){var o=e.get(t);o&&(n?o.splice(o.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var o=e.get(t);o&&o.slice().map(function(r){r(n)}),(o=e.get("*"))&&o.slice().map(function(r){r(t,n)})}}}var m=class{constructor(){s(this,"eventHandler",L())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,n){try{let o=new Promise(i=>{let a=()=>{this.eventHandler.off("onAuthenticated",a),t==null||t(),i()};this.eventHandler.on("onAuthenticated",a)}),r=document.querySelector("dialog.session-expired-dialog");if(r)await o;else{r=document.createElement("dialog"),r.className="session-expired-dialog",r.style.display="flex",r.style.padding="0",r.style.left="50%",r.style.transform="translateX(-50%)";let i="/login?ReturnUrl=%2fapi/sessionexpired/remove";n!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):i="/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove",r.innerHTML='<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="'.concat(i,'" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>'),document.body.append(r),r.showModal(),await o,r.remove()}}catch(o){window.location.href="/login?ReturnUrl=".concat(encodeURIComponent(window.location.pathname)).concat(encodeURIComponent(window.location.search))}}attachEvent(t,n){return this.eventHandler.on(t,n)}detachEvent(t,n){return this.eventHandler.off(t,n)}};var E=class extends m{constructor(n){super();s(this,"amDesignator","a.m.");s(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);s(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);s(this,"decimalSeparator",".");s(this,"domain","OB");s(this,"email");s(this,"formats");s(this,"groupSeparator",null);s(this,"integratedSecurity",!1);s(this,"isDeveloper",!1);s(this,"login","");s(this,"loginType");s(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);s(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);s(this,"name");s(this,"pmDesignator","p.m.");s(this,"shortDateFormat","dd.MM.yyyy");s(this,"culture","en-GB");s(this,"uiculture","en-GB");this.formats={},Object.assign(this,n)}};var F;(F=window.window)==null||F.addEventListener("error",e=>{var t,n,o,r,i,a,l;try{let p={error:(o=(n=(t=e.error)==null?void 0:t.message)!=null?n:e.message)!=null?o:null,file:e.filename,line:(r=e.lineno)!=null?r:0,column:(i=e.colno)!=null?i:0,stack:(l=(a=e.error)==null?void 0:a.stack)!=null?l:null};fetch("/data/Logger/LogError",{body:JSON.stringify(p),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch(p){}});function J(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var R=class{constructor(){s(this,"isPersisted",()=>!0)}getLocalStorageKey(t,n){return n?["common",t].join("."):J(t)}get(t,n,o){let r=this.getLocalStorageKey(t,o),i=localStorage.getItem(r);return i!==null?JSON.parse(i):n}set(t,n,o){localStorage.setItem(this.getLocalStorageKey(t,o),JSON.stringify(n))}remove(t,n){let o=this.getLocalStorageKey(t,n);return localStorage.getItem(o)!==null?(localStorage.removeItem(o),!0):!1}clear(){let t=J("");for(let n in localStorage)n.slice(0,t.length)===t&&localStorage.removeItem(n)}},K=new R;function V(e){return e?$(e).substring(0,10):null}function y(e){return String(e).padStart(2,"0")}function $(e){return e?"".concat(e.getFullYear(),"-").concat(y(e.getMonth()+1),"-").concat(y(e.getDate()),"T").concat(y(e.getHours()),":").concat(y(e.getMinutes()),":").concat(y(e.getSeconds()),".").concat(y(e.getMilliseconds())):null}function T(e,t){return new Promise(function(n,o){try{let r=URL.createObjectURL(e),i=document.body,a=document.createElement("a");a.setAttribute("download",t),a.href=r,i.append(a),a.click(),i.removeChild(a),setTimeout(function(){URL.revokeObjectURL(r),n()},250)}catch(r){o(r)}})}function u(e,t){if(e)return;let n=typeof t=="function"?t():t;throw new Error(n!=null?n:"Invariant failed")}async function Z(e,{fileName:t,signal:n,onProgress:o}){var a;function r(l){typeof o=="function"&&o(f({},l))}let i=0;r({status:"requested"});try{let l=await fetch(e);if(!l.ok||!l.body){if((a=l.headers.get("content-type"))!=null&&a.includes("application/json")){let g=await l.json();u(!g.error,g.error)}throw new Error("".concat(l.status," ").concat(l.statusText))}try{let g=l.body.getReader(),D=new ReadableStream({start:function(S){function c(){return g.read().then(function(x){if(x.done){S.close();return}return i+=x.value.length,r({bytesReceived:i,status:"downloading"}),S.enqueue(x.value),c()})}return c()}});l=new Response(D)}catch(g){}let p=await l.blob();r({bytesReceived:i,status:"downloaded"}),await T(p,t),r({bytesReceived:i,status:"completed"})}catch(l){n!=null&&n.aborted?r({status:"cancelled"}):r({error:l.message,status:"error"})}}function h(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var xe=/^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;function C(e){var t=e.toString().match(xe);return u(t,"Unable to parse function!"),{name:t[1],args:t[2].split(","),body:t[3]}}function X(){}X.prototype=Object.create(null);var Y=X;function P(e,t){if(typeof e=="object"){if(typeof t=="string"){let n=t.split(".");return P(e,n)}else if(Array.isArray(t)){let n=e;for(let o=0;o<t.length;o++)n=n[t[o]]=n[t[o]]||new Y;return n}}}function U(e,t,n={}){if(Array.isArray(t))for(let o of t){let{name:r}=C(o);u(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),U(e,o)}else{let o,r;if(typeof t=="function"&&(o=C(t).name),typeof e=="string"){let i=e.split(".");o||(o=i[i.length-1],i=i.slice(0,i.length-1)),r=P(window,i)}else o&&(typeof e=="object"||typeof e=="function")?r=e:u(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");h(r,o)&&(n==null?void 0:n.overwrite)!==!0?console.warn([e,o].join(".")+" is already defined!"):r[o]=t}}var be={xs:64,sm:128,md:256,lg:512,xl:void 0};function _(e,t,n,o="xs"){if(e&&typeof e=="object")return _(e.primKey,e.login,e.hash,e.size);if(!e||!n)return"";let r=be[o];return"/api/data/blob/EmployeesLookup/".concat(e,"/Image/").concat(encodeURIComponent(t!=null?t:"")).concat(t?".":"").concat(encodeURIComponent(n),".jpg").concat(r?"?width=".concat(r):"")}async function we(e){try{let t=await fetch("/api/user/localize/new/".concat(af.article.id),{body:JSON.stringify({text:e}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(t.ok)return await t.json()}catch(t){}return e}function d(e,t){var n,o;if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(((o=(n=window.af)==null?void 0:n.article)==null?void 0:o.i18n)!==void 0){if(!h(af.article.i18n,e)){af.article.i18n[e]=e;let r=we(e).then(i=>(af.article.i18n[e]=i,i));if(t)return r}return af.article.i18n[e]}else return e}function W(e,...t){u(Array.isArray(e)&&e.length===t.length+1,"Method 'localize' must be used as a tag function");let n=e.map((r,i)=>i===e.length-1?r:"".concat(r,"$").concat(i)).join(""),o=d(n);return t.forEach((r,i)=>{o=o.replace("$"+i,r)}),o}async function z(e,t={},n=0){var o;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:af.article.id,timeElapsed:n,action:e,parameters:B(f({},t),{_session:O()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((o=r.headers.get("Content-Type"))!=null&&o.includes("application/json")){let i=await r.json();console.error(i.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function Q(e,t={}){let n=performance.now();return(o={})=>z(e,f(f({},t),o),performance.now()-n)}async function ee(e){let t=performance.now();return[await e(),performance.now()-t]}async function te(e){var t;try{if(!e)return;let n=typeof e=="string"?{error:e}:typeof e=="object"?"message"in e?{error:e.message,stack:(t=e.stack)!=null?t:null}:{error:e.toString()}:{error:"Unspecified error"};console.error(e);let o=await fetch("/data/Logger/LogError",{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json; charset=utf-8"}});if(o.ok)return await o.json();console.error(Error("Failed to log error"))}catch(n){}}function ne(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var G=Date.now(),oe=ne(),w="",v="";if("document"in window){let e=()=>{var t;return z("AfSessionInit",{"appframe-core":af.common.version,"appframe-data":(t=af.data)==null?void 0:t.version,"app-version":af.article.version})};document.addEventListener("DOMContentLoaded",()=>{w=localStorage.getItem("_afDeviceId"),v=sessionStorage.getItem("_afSessionId"),w||(w=ne(),localStorage.setItem("_afDeviceId",w)),v||(v=oe,sessionStorage.setItem("_afSessionId",v)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:af.article.id,action:"AfSessionEnd",parameters:{_session:O()}})):e()})}function O(){return{browserSessionId:v,sessionStart:G,sessionLength:Date.now()-G,sessionId:oe,deviceId:w}}function re(e){let t=e||af.article.id;return"".concat(t,".").concat(af.userSession.login)}function ie(e,t){if(!(af!=null&&af.userSession))return null;let n=re(t),o=JSON.parse(localStorage.getItem(n)||"{}");return e?o[e]||null:o}function ae(e,t,n){if(!(af!=null&&af.userSession))return;let o=re(n),r=JSON.parse(localStorage.getItem(o)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(o,JSON.stringify(r))}var ve='\n <dialog class="alert-dialog">\n <form method="dialog">\n <article></article>\n <footer>\n <menu></menu>\n </footer>\n </form>\n </dialog>\n';if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=ve,document.body.append(e)}function H(e,t="No"){return new Promise(n=>{let o=new AbortController;e.addEventListener("close",()=>{n(e.returnValue),o.abort()},{signal:o.signal}),e.addEventListener("cancel",()=>{n(t),o.abort()},{signal:o.signal})})}var A=new Map;async function j({buttons:e,content:t,className:n,id:o,title:r}){var D,S;if(o&&A.has(o))return await A.get(o);let i=document.querySelector("#AlertDialogTemplate");if(!i)throw Error("No alert dialog template found");let a=(D=i.content.firstElementChild)==null?void 0:D.cloneNode(!0),l=a==null?void 0:a.querySelector("article"),p=a==null?void 0:a.querySelector("footer menu");if(!a||!l||!p)throw Error("Invalid alert dialog template");if(n&&n.split(/\s+/).forEach(c=>a==null?void 0:a.classList.add(c)),r){let c=document.createElement("header");c.append(r),(S=l.parentNode)==null||S.insertBefore(c,l)}l.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:c,value:x,primary:ce}of e){let ue=document.createElement("li"),b=document.createElement("button");b.value=x,ce&&b.classList.add("primary"),b.textContent=c,ue.appendChild(b),p.appendChild(b)}document.body.appendChild(a),a.showModal();let g=H(a).then(c=>(o&&A.has(o)&&A.delete(o),a&&document.body.removeChild(a),c));return o&&A.set(o,g),await g}var M=(n=>(n[n.YesNo=0]="YesNo",n[n.OkCancel=1]="OkCancel",n))(M||{});async function se(e,t={}){let{buttons:n=0,title:o}=t,r=n===1?[{label:d("OK"),value:"yes",primary:!0},{label:d("Cancel"),value:"no"}]:[{label:d("Yes"),value:"yes",primary:!0},{label:d("No"),value:"no"}];return await j({content:e,buttons:r,className:"alert-dialog-confirm",title:o})==="yes"}async function le(e,t={}){await j(f({content:e,className:"alert-dialog-alert",buttons:[{label:d("OK"),value:"ok",primary:!0}]},t))}var Ae="2.10.2";return Se(De);})();
|
|
1
|
+
var af=af||{};af.common=(()=>{var I=Object.defineProperty,fe=Object.defineProperties,me=Object.getOwnPropertyDescriptor,pe=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertyNames,k=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var N=(e,t,n)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))B.call(t,n)&&N(e,n,t[n]);if(k)for(var n of k(t))ye.call(t,n)&&N(e,n,t[n]);return e},F=(e,t)=>fe(e,pe(t));var he=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},Se=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of ge(t))!B.call(e,r)&&r!==n&&I(e,r,{get:()=>t[r],enumerable:!(o=me(t,r))||o.enumerable});return e};var be=e=>Se(I({},"__esModule",{value:!0}),e);var l=(e,t,n)=>(N(e,typeof t!="symbol"?t+"":t,n),n);var Ie={};he(Ie,{ConfirmButtons:()=>q,SessionHandler:()=>f,UserSession:()=>E,alert:()=>se,confirm:()=>le,downloadBlob:()=>O,downloadRequest:()=>ee,expose:()=>_,getLocalizedString:()=>u,getSessionData:()=>z,getSettings:()=>ie,getUserImage:()=>H,has:()=>y,invariant:()=>c,localStorage:()=>W,localize:()=>oe,logActivity:()=>T,logError:()=>w,mitt:()=>L,openAlertDialog:()=>j,saveSettings:()=>ae,startActivity:()=>K,time:()=>V,toLocalDateTime:()=>P,toLocalISODate:()=>Q,toLocalISODateTime:()=>$,version:()=>Ae,waitForDialog:()=>M});function L(e){return{all:e=e||new Map,on:function(t,n){var o=e.get(t);o?o.push(n):e.set(t,[n])},off:function(t,n){var o=e.get(t);o&&(n?o.splice(o.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var o=e.get(t);o&&o.slice().map(function(r){r(n)}),(o=e.get("*"))&&o.slice().map(function(r){r(t,n)})}}}var f=class{constructor(){l(this,"eventHandler",L())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(t,n){try{let o=new Promise(a=>{let i=()=>{this.eventHandler.off("onAuthenticated",i),t==null||t(),a()};this.eventHandler.on("onAuthenticated",i)}),r=document.querySelector("dialog.session-expired-dialog");if(r)await o;else{r=document.createElement("dialog"),r.className="session-expired-dialog",r.style.display="flex",r.style.padding="0",r.style.left="50%",r.style.transform="translateX(-50%)";let a="/login?ReturnUrl=%2fapi/sessionexpired/remove";n!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):a="/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove",r.innerHTML='<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="'.concat(a,'" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>'),document.body.append(r),r.showModal(),await o,r.remove()}}catch(o){window.location.href="/login?ReturnUrl=".concat(encodeURIComponent(window.location.pathname)).concat(encodeURIComponent(window.location.search))}}attachEvent(t,n){return this.eventHandler.on(t,n)}detachEvent(t,n){return this.eventHandler.off(t,n)}};var E=class extends f{constructor(n){super();l(this,"amDesignator","a.m.");l(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);l(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);l(this,"decimalSeparator",".");l(this,"domain","OB");l(this,"email");l(this,"formats");l(this,"groupSeparator",null);l(this,"integratedSecurity",!1);l(this,"isDeveloper",!1);l(this,"login","");l(this,"loginType");l(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);l(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);l(this,"name");l(this,"pmDesignator","p.m.");l(this,"shortDateFormat","dd.MM.yyyy");l(this,"culture","en-GB");l(this,"uiculture","en-GB");this.formats={},Object.assign(this,n)}};async function T(e,t={},n=0){var o;try{let r=await fetch("/api/logging/log-activity",{method:"POST",body:JSON.stringify({article:af.article.id,timeElapsed:n,action:e,parameters:F(p({},t),{_session:z()})}),headers:{"Content-Type":"application/json",Accept:"application/json"}});if(!r.ok)if((o=r.headers.get("Content-Type"))!=null&&o.includes("application/json")){let a=await r.json();console.error(a.error)}else console.error("".concat(r.status," ").concat(r.statusText))}catch(r){}}function K(e,t={}){let n=performance.now();return(o={})=>T(e,p(p({},t),o),performance.now()-n)}async function V(e){let t=performance.now();return[await e(),performance.now()-t]}async function w(e){var t;try{if(!e)return;let n=typeof e=="string"?{error:e}:typeof e=="object"?"message"in e?{error:e.message,stack:(t=e.stack)!=null?t:null}:{error:e.toString()}:{error:"Unspecified error"};console.error(e);let o=await fetch("/data/Logger/LogError",{method:"POST",body:JSON.stringify(n),headers:{"Content-Type":"application/json; charset=utf-8"}});if(o.ok)return await o.json();console.error(Error("Failed to log error"))}catch(n){}}function Z(){var e;return(e=crypto.randomUUID)==null?void 0:e.call(crypto)}var J=Date.now(),Y=Z(),x="",v="";if("document"in window){let e=()=>{var t;return T("AfSessionInit",{"appframe-core":af.common.version,"appframe-data":(t=af.data)==null?void 0:t.version,"app-version":af.article.version})};document.addEventListener("DOMContentLoaded",()=>{x=localStorage.getItem("_afDeviceId"),v=sessionStorage.getItem("_afSessionId"),x||(x=Z(),localStorage.setItem("_afDeviceId",x)),v||(v=Y,sessionStorage.setItem("_afSessionId",v)),e()}),document.addEventListener("visibilitychange",function(){document.visibilityState==="hidden"?navigator.sendBeacon("/api/logging/log-activity",JSON.stringify({article:af.article.id,action:"AfSessionEnd",parameters:{_session:z()}})):e()})}function z(){return{browserSessionId:v,sessionStart:J,sessionLength:Date.now()-J,sessionId:Y,deviceId:x}}var X;(X=window.window)==null||X.addEventListener("error",e=>{typeof e=="object"&&"error"in e?w(e.error):typeof e=="object"&&"message"in e&&w(e)});function G(e){var t;return[((t=af==null?void 0:af.article)==null?void 0:t.id)||"","common",e].join(".")}var R=class{constructor(){l(this,"isPersisted",()=>!0)}getLocalStorageKey(t,n){return n?["common",t].join("."):G(t)}get(t,n,o){let r=this.getLocalStorageKey(t,o),a=localStorage.getItem(r);return a!==null?JSON.parse(a):n}set(t,n,o){localStorage.setItem(this.getLocalStorageKey(t,o),JSON.stringify(n))}remove(t,n){let o=this.getLocalStorageKey(t,n);return localStorage.getItem(o)!==null?(localStorage.removeItem(o),!0):!1}clear(){let t=G("");for(let n in localStorage)n.slice(0,t.length)===t&&localStorage.removeItem(n)}},W=new R;function Q(e){return e?$(e).substring(0,10):null}function g(e,t=2){return String(e).padStart(t,"0")}function $(e){return e?"".concat(e.getFullYear(),"-").concat(g(e.getMonth()+1),"-").concat(g(e.getDate()),"T").concat(g(e.getHours()),":").concat(g(e.getMinutes()),":").concat(g(e.getSeconds()),".").concat(g(e.getMilliseconds(),3)):null}function P(e){return e?e.toISOString().substring(0,16):""}function O(e,t){return new Promise(function(n,o){try{let r=URL.createObjectURL(e),a=document.body,i=document.createElement("a");i.setAttribute("download",t),i.href=r,a.append(i),i.click(),a.removeChild(i),setTimeout(function(){URL.revokeObjectURL(r),n()},250)}catch(r){o(r)}})}function c(e,t){if(e)return;let n=typeof t=="function"?t():t;throw new Error(n!=null?n:"Invariant failed")}async function ee(e,{fileName:t,signal:n,onProgress:o}){var a;let r=0;o==null||o({status:"requested"});try{let i=await fetch(e);if(!i.ok||!i.body){if((a=i.headers.get("content-type"))!=null&&a.includes("application/json")){let d=await i.json();c(!d.error,d.error)}throw new Error("".concat(i.status," ").concat(i.statusText))}try{let d=i.body.getReader(),A=new ReadableStream({start:function(h){function S(){return d.read().then(function(s){if(s.done){h.close();return}return r+=s.value.length,o==null||o({bytesReceived:r,status:"downloading"}),h.enqueue(s.value),S()})}return S()}});i=new Response(A)}catch(d){}let m=await i.blob();o==null||o({bytesReceived:r,status:"downloaded"}),await O(m,t),o==null||o({bytesReceived:r,status:"completed"})}catch(i){n!=null&&n.aborted?o==null||o({status:"cancelled"}):o==null||o({error:i.message,status:"error"})}}function y(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var xe=/^function(?:\s+([a-zA-Z$_][a-zA-Z0-9$_]*))?\s*\(((?:(?:\s*[a-zA-Z$_][a-zA-Z0-9$_]*)(?:\s*,\s*[a-zA-Z$_][a-zA-Z0-9$_]*)*)?)\s*\)\s*\{((?:.|\n|\r)*)\}$/;function C(e){var n;var t=e.toString().match(xe);return c(t,"Unable to parse function!"),{name:(n=e.name)!=null?n:t[1],args:t[2].split(",").map(o=>o.trim()),body:t[3]}}function te(){}te.prototype=Object.create(null);var ne=te;function U(e,t){if(typeof e=="object"){if(typeof t=="string"){let n=t.split(".");return U(e,n)}else if(Array.isArray(t)){let n=e;for(let o=0;o<t.length;o++)n=n[t[o]]=n[t[o]]||new ne;return n}}}function _(e,t,n={}){if(Array.isArray(t))for(let o of t){let{name:r}=C(o);c(r,"Unable to detect name of function! Name it, or only supply one function and include name in first parameter."),_(e,o)}else{let o,r;if(typeof t=="function"&&(o=C(t).name),typeof e=="string"){let a=e.split(".");o||(o=a[a.length-1],a=a.slice(0,a.length-1)),r=U(window,a)}else o&&(typeof e=="object"||typeof e=="function")?r=e:c(!1,"Invalid typeof parameter 'name', or unable to parse pValue!");y(r,o)&&(n==null?void 0:n.overwrite)!==!0?console.warn([e,o].join(".")+" is already defined!"):r[o]=t}}var ve={xs:64,sm:128,md:256,lg:512,xl:void 0};function H(e,t,n,o="xs"){if(e&&typeof e=="object")return H(e.primKey,e.login,e.hash,e.size);if(!e||!n)return"";let r=ve[o];return"/api/data/blob/EmployeesLookup/".concat(e,"/Image/").concat(encodeURIComponent(t!=null?t:"")).concat(t?".":"").concat(encodeURIComponent(n),".jpg").concat(r?"?width=".concat(r):"")}async function we(e){try{let t=await fetch("/api/user/localize/new/".concat(af.article.id),{body:JSON.stringify({text:e}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(t.ok)return await t.json()}catch(t){}return e}function u(e,t){var n,o;if(typeof e=="string"&&e.trim().length===0)return e;if(!(e===void 0||e===""||e===null))if(((o=(n=window.af)==null?void 0:n.article)==null?void 0:o.i18n)!==void 0){if(!y(af.article.i18n,e)){af.article.i18n[e]=e;let r=we(e).then(a=>(af.article.i18n[e]=a,a));if(t)return r}return af.article.i18n[e]}else return e}function oe(e,...t){c(Array.isArray(e)&&e.length===t.length+1,"Method 'localize' must be used as a tag function");let n=e.map((r,a)=>a===e.length-1?r:"".concat(r,"$").concat(a)).join(""),o=u(n);return t.forEach((r,a)=>{o=o.replace("$"+a,r)}),o}function re(e){let t=e||af.article.id;return"".concat(t,".").concat(af.userSession.login)}function ie(e,t){if(!(af!=null&&af.userSession))return null;let n=re(t),o=JSON.parse(localStorage.getItem(n)||"{}");return e?o[e]||null:o}function ae(e,t,n){if(!(af!=null&&af.userSession))return;let o=re(n),r=JSON.parse(localStorage.getItem(o)||"{}");typeof t<"u"?r[e]=t:r=e,localStorage.setItem(o,JSON.stringify(r))}var De='\n <dialog class="alert-dialog">\n <form method="dialog">\n <article></article>\n <footer>\n <menu></menu>\n </footer>\n </form>\n </dialog>\n';if(window.document&&!document.querySelector("#AlertDialogTemplate")){let e=document.createElement("template");e.id="AlertDialogTemplate",e.innerHTML=De,document.body.append(e)}function M(e,t="No"){return new Promise(n=>{let o=new AbortController;e.addEventListener("close",()=>{n(e.returnValue),o.abort()},{signal:o.signal}),e.addEventListener("cancel",()=>{n(t),o.abort()},{signal:o.signal})})}var D=new Map;async function j({buttons:e,content:t,className:n,id:o,title:r}){var h,S;if(o&&D.has(o))return await D.get(o);let a=document.querySelector("#AlertDialogTemplate");if(!a)throw Error("No alert dialog template found");let i=(h=a.content.firstElementChild)==null?void 0:h.cloneNode(!0),m=i==null?void 0:i.querySelector("article"),d=i==null?void 0:i.querySelector("footer menu");if(!i||!m||!d)throw Error("Invalid alert dialog template");if(n&&n.split(/\s+/).forEach(s=>i==null?void 0:i.classList.add(s)),r){let s=document.createElement("header");s.append(r),(S=m.parentNode)==null||S.insertBefore(s,m)}m.appendChild(typeof t=="string"?document.createTextNode(t):t);for(let{label:s,value:ce,primary:ue}of e){let de=document.createElement("li"),b=document.createElement("button");b.value=ce,ue&&b.classList.add("primary"),b.textContent=s,de.appendChild(b),d.appendChild(b)}document.body.appendChild(i),i.showModal();let A=M(i).then(s=>(o&&D.has(o)&&D.delete(o),i&&document.body.removeChild(i),s));return o&&D.set(o,A),await A}var q=(n=>(n[n.YesNo=0]="YesNo",n[n.OkCancel=1]="OkCancel",n))(q||{});async function le(e,t={}){let{buttons:n=0,title:o}=t,r=n===1?[{label:u("OK"),value:"yes",primary:!0},{label:u("Cancel"),value:"no"}]:[{label:u("Yes"),value:"yes",primary:!0},{label:u("No"),value:"no"}];return await j({content:e,buttons:r,className:"alert-dialog-confirm",title:o})==="yes"}async function se(e,t={}){await j(p({content:e,className:"alert-dialog-alert",buttons:[{label:u("OK"),value:"ok",primary:!0}]},t))}var Ae="2.11.1";return be(Ie);})();
|
|
2
2
|
//# sourceMappingURL=af.common.legacy.min.js.map
|