@olenbetong/appframe-core 2.0.3 → 2.1.0
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 +115 -293
- package/dist/esm/af.common.legacy.js +119 -290
- package/dist/esm/af.common.legacy.min.js +1 -47
- package/dist/esm/af.common.legacy.min.js.map +4 -4
- package/dist/esm/af.common.min.js +1 -47
- package/dist/esm/af.common.min.js.map +4 -4
- package/dist/iife/af.common.js +118 -294
- package/dist/iife/af.common.legacy.js +122 -293
- package/dist/iife/af.common.legacy.min.js +1 -47
- package/dist/iife/af.common.legacy.min.js.map +4 -4
- package/dist/iife/af.common.min.js +1 -47
- package/dist/iife/af.common.min.js.map +4 -4
- package/es/SessionHandler.d.ts +2 -7
- package/es/SessionHandler.js +34 -135
- package/es/UserSession.d.ts +1 -2
- package/es/UserSession.js +1 -2
- package/es/downloadRequest.js +1 -4
- package/es/expose.d.ts +1 -1
- package/es/expose.js +4 -5
- package/es/getLocalizedString.d.ts +6 -7
- package/es/getLocalizedString.js +9 -82
- package/es/index.d.ts +3 -2
- package/es/index.js +4 -3
- package/es/localize.d.ts +14 -0
- package/es/localize.js +25 -0
- package/es/parseFunc.d.ts +1 -1
- package/es/parseFunc.js +1 -1
- package/es/requireNamespace.d.ts +1 -1
- package/es/requireNamespace.js +1 -7
- package/package.json +2 -2
- package/src/SessionHandler.ts +38 -156
- package/src/UserSession.ts +1 -2
- package/src/downloadRequest.ts +1 -4
- package/src/expose.ts +4 -5
- package/src/getLocalizedString.ts +22 -110
- package/src/index.ts +3 -2
- package/src/localize.ts +29 -0
- package/src/parseFunc.ts +1 -1
- package/src/requireNamespace.ts +1 -5
- package/es/warn.d.ts +0 -1
- package/es/warn.js +0 -4
- package/src/warn.ts +0 -4
|
@@ -6,7 +6,7 @@ af.common = (() => {
|
|
|
6
6
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj,
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
10
|
var __spreadValues = (a, b) => {
|
|
11
11
|
for (var prop in b || (b = {}))
|
|
12
12
|
if (__hasOwnProp.call(b, prop))
|
|
@@ -24,15 +24,15 @@ af.common = (() => {
|
|
|
24
24
|
};
|
|
25
25
|
var __copyProps = (to, from, except, desc) => {
|
|
26
26
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
27
|
-
for (let
|
|
28
|
-
if (!__hasOwnProp.call(to,
|
|
29
|
-
__defProp(to,
|
|
27
|
+
for (let key of __getOwnPropNames(from))
|
|
28
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
29
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
30
30
|
}
|
|
31
31
|
return to;
|
|
32
32
|
};
|
|
33
33
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
34
|
-
var __publicField = (obj,
|
|
35
|
-
__defNormalProp(obj, typeof
|
|
34
|
+
var __publicField = (obj, key, value) => {
|
|
35
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
36
36
|
return value;
|
|
37
37
|
};
|
|
38
38
|
|
|
@@ -48,6 +48,7 @@ af.common = (() => {
|
|
|
48
48
|
getSettings: () => getSettings,
|
|
49
49
|
has: () => has,
|
|
50
50
|
localStorage: () => localStorage_default,
|
|
51
|
+
localize: () => localize,
|
|
51
52
|
mitt: () => mitt_default,
|
|
52
53
|
saveSettings: () => saveSettings,
|
|
53
54
|
version: () => version
|
|
@@ -95,262 +96,44 @@ af.common = (() => {
|
|
|
95
96
|
} };
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
// src/has.ts
|
|
99
|
-
function has(obj, key2) {
|
|
100
|
-
return Object.prototype.hasOwnProperty.call(obj, key2);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// src/getLocalizedString.ts
|
|
104
|
-
async function getLocalizedStringAsync(text) {
|
|
105
|
-
try {
|
|
106
|
-
let response = await fetch(`/api/user/localize/new/${af.article.id}`, {
|
|
107
|
-
body: JSON.stringify({ text }),
|
|
108
|
-
headers: {
|
|
109
|
-
Accept: "application/json; */*",
|
|
110
|
-
"Content-Type": "application/json",
|
|
111
|
-
"X-Requested-With": "XMLHttpRequest"
|
|
112
|
-
},
|
|
113
|
-
method: "POST"
|
|
114
|
-
});
|
|
115
|
-
if (response.ok) {
|
|
116
|
-
return await response.json();
|
|
117
|
-
}
|
|
118
|
-
} catch (error) {
|
|
119
|
-
}
|
|
120
|
-
return text;
|
|
121
|
-
}
|
|
122
|
-
function afGetLocalizedString(string, wait) {
|
|
123
|
-
var _a;
|
|
124
|
-
if (typeof string === "string" && string.trim().length === 0) {
|
|
125
|
-
return string;
|
|
126
|
-
}
|
|
127
|
-
if (string === void 0 || string === "" || string === null) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.i18n) !== void 0) {
|
|
131
|
-
if (!has(af.article.i18n, string)) {
|
|
132
|
-
af.article.i18n[string] = string;
|
|
133
|
-
let promise = getLocalizedStringAsync(string).then((text) => {
|
|
134
|
-
af.article.i18n[string] = text;
|
|
135
|
-
return text;
|
|
136
|
-
});
|
|
137
|
-
if (wait) {
|
|
138
|
-
return promise;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return af.article.i18n[string];
|
|
142
|
-
} else {
|
|
143
|
-
return string;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
var key = "__UNLOCALIZED_STRINGS__";
|
|
147
|
-
var localizeSet = window[key] || /* @__PURE__ */ new Set();
|
|
148
|
-
if (!window[key]) {
|
|
149
|
-
window[key] = localizeSet;
|
|
150
|
-
}
|
|
151
|
-
function handleReadyStateChange() {
|
|
152
|
-
if (document.readyState !== "loading") {
|
|
153
|
-
addDeveloperUtils();
|
|
154
|
-
document.removeEventListener("readystatechange", handleReadyStateChange);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (document.readyState !== "loading") {
|
|
158
|
-
addDeveloperUtils();
|
|
159
|
-
} else {
|
|
160
|
-
document.addEventListener("readystatechange", handleReadyStateChange);
|
|
161
|
-
}
|
|
162
|
-
function isDeveloper() {
|
|
163
|
-
const { af: af2 } = window;
|
|
164
|
-
return af2 && af2.userSession && af2.userSession.isDeveloper;
|
|
165
|
-
}
|
|
166
|
-
function addDeveloperUtils() {
|
|
167
|
-
if (isDeveloper()) {
|
|
168
|
-
if (typeof window.__doNothingWithStrings === "function") {
|
|
169
|
-
const addedStrings = window.__doNothingWithStrings();
|
|
170
|
-
for (let string of Object.keys(addedStrings)) {
|
|
171
|
-
localizeSet.add(string);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
if (!window[key]) {
|
|
175
|
-
window[key] = localizeSet;
|
|
176
|
-
}
|
|
177
|
-
if (!window.__getUnlocalizedStrings) {
|
|
178
|
-
window.__getUnlocalizedStrings = function(forCustomRoute) {
|
|
179
|
-
const strings = [];
|
|
180
|
-
for (let string of localizeSet) {
|
|
181
|
-
if (string) {
|
|
182
|
-
const escaped = string.replace(/'/g, "\\'");
|
|
183
|
-
if (forCustomRoute) {
|
|
184
|
-
const localized = afGetLocalizedString(string).replaceAll(/'/g, "\\'");
|
|
185
|
-
strings.push(`'${escaped}': '${localized}',`);
|
|
186
|
-
} else {
|
|
187
|
-
strings.push(
|
|
188
|
-
`s['${escaped}'] = @Html(@context.AddLocalizableString("${string.replaceAll('"', '\\"')}"));`
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
if (forCustomRoute) {
|
|
194
|
-
return `// Localization hack, since it AddLocalizableString doesn't work properly when custom routes is used
|
|
195
|
-
if (af.userSession.uiculture === 'nb-NO') {
|
|
196
|
-
const strings = {
|
|
197
|
-
${strings.join("\n ")}
|
|
198
|
-
};
|
|
199
|
-
af.article.i18n = af.article.i18n || {};
|
|
200
|
-
Object.assign(af.article.i18n, strings);
|
|
201
|
-
}`;
|
|
202
|
-
}
|
|
203
|
-
return `<script type="text/javascript">
|
|
204
|
-
function __doNothingWithStrings() {
|
|
205
|
-
@{
|
|
206
|
-
var context = @Appframe.Web.Context.RequestContext.Current;
|
|
207
|
-
}
|
|
208
|
-
let s = {};
|
|
209
|
-
${strings.join("\n")}
|
|
210
|
-
return s;
|
|
211
|
-
}
|
|
212
|
-
<\/script>`;
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
function getLocalizedString(string) {
|
|
218
|
-
const localized = afGetLocalizedString(string);
|
|
219
|
-
if (localized === string && !localizeSet.has(string)) {
|
|
220
|
-
localizeSet.add(string);
|
|
221
|
-
}
|
|
222
|
-
return localized;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
99
|
// src/SessionHandler.ts
|
|
226
|
-
var
|
|
100
|
+
var SessionHandler = class {
|
|
227
101
|
constructor() {
|
|
228
102
|
__publicField(this, "eventHandler", mitt_default());
|
|
229
|
-
__publicField(this, "showingDialog", false);
|
|
230
|
-
__publicField(this, "dialog", null);
|
|
231
103
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
<div class="form-group">
|
|
258
|
-
<label for="password">${getLocalizedString("Password")}</label>
|
|
259
|
-
<input type="password" autocomplete="password" class="form-control" id="password" >
|
|
260
|
-
</div>
|
|
261
|
-
<div class="form-group">
|
|
262
|
-
<div>
|
|
263
|
-
<button type="submit" class="btn btn-default sign-in">
|
|
264
|
-
${getLocalizedString("Log in")}
|
|
265
|
-
</button>
|
|
266
|
-
</div>
|
|
267
|
-
</div>
|
|
268
|
-
</div>
|
|
269
|
-
</div>
|
|
270
|
-
<div class="row">
|
|
271
|
-
<div class="" style="display:none; margin: 0px 30px;">
|
|
272
|
-
<div class="alert alert-warning" role="alert" style="margin-top:10px;"></div>
|
|
273
|
-
</div>
|
|
274
|
-
</div>
|
|
275
|
-
</div>
|
|
276
|
-
`;
|
|
277
|
-
const message = af.userSession.login ? _SessionHandler.messages.relog : _SessionHandler.messages.login;
|
|
278
|
-
const messageElem = contentContainer.querySelector(".message");
|
|
279
|
-
const statusElem = contentContainer.querySelector(".alert-warning");
|
|
280
|
-
const userElem = contentContainer.querySelector("input[type=text]");
|
|
281
|
-
const signInElem = contentContainer.querySelector(".sign-in");
|
|
282
|
-
const passwordElem = contentContainer.querySelector("input[type=password]");
|
|
283
|
-
if (messageElem !== null && userElem !== null && statusElem !== null && userElem !== null && signInElem !== null && passwordElem !== null) {
|
|
284
|
-
messageElem.innerText = getLocalizedString(message);
|
|
285
|
-
userElem.value = af.userSession.login || "";
|
|
286
|
-
userElem.disabled = !!af.userSession.login;
|
|
287
|
-
userElem.readOnly = !!af.userSession.login;
|
|
288
|
-
document.body.appendChild(contentContainer);
|
|
289
|
-
const doLogin = async () => {
|
|
290
|
-
passwordElem.disabled = true;
|
|
291
|
-
const request = new Request("/login", {
|
|
292
|
-
body: JSON.stringify({
|
|
293
|
-
username: userElem.value,
|
|
294
|
-
password: passwordElem.value,
|
|
295
|
-
remember: false
|
|
296
|
-
}),
|
|
297
|
-
headers: {
|
|
298
|
-
Accept: "application/json",
|
|
299
|
-
"Content-Type": "application/json; charset=utf-8",
|
|
300
|
-
"X-Requested-With": "XMLHttpRequest"
|
|
301
|
-
},
|
|
302
|
-
method: "POST"
|
|
303
|
-
});
|
|
304
|
-
try {
|
|
305
|
-
const response = await fetch(request);
|
|
306
|
-
const json = await response.json();
|
|
307
|
-
if (json.success) {
|
|
308
|
-
document.body.removeChild(contentContainer);
|
|
309
|
-
this.showingDialog = false;
|
|
310
|
-
this.eventHandler.emit("onAuthenticated");
|
|
311
|
-
if (statusElem.parentNode) {
|
|
312
|
-
statusElem.parentNode.style.display = "none";
|
|
313
|
-
}
|
|
314
|
-
} else {
|
|
315
|
-
throw new Error(json.error);
|
|
316
|
-
}
|
|
317
|
-
} catch (err) {
|
|
318
|
-
if (err && typeof err === "object") {
|
|
319
|
-
let error = err;
|
|
320
|
-
passwordElem.disabled = false;
|
|
321
|
-
passwordElem.classList.toggle("invalid", true);
|
|
322
|
-
passwordElem.value = "";
|
|
323
|
-
passwordElem.focus();
|
|
324
|
-
statusElem.innerText = error.message ? error.message : String(error);
|
|
325
|
-
if (statusElem.parentNode) {
|
|
326
|
-
statusElem.parentNode.style.display = "initial";
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
};
|
|
331
|
-
signInElem.addEventListener("click", doLogin);
|
|
332
|
-
passwordElem.addEventListener("keyup", (evt) => {
|
|
333
|
-
if (evt.key === "Enter") {
|
|
334
|
-
doLogin();
|
|
335
|
-
}
|
|
336
|
-
});
|
|
337
|
-
passwordElem.addEventListener("change", (evt) => {
|
|
338
|
-
if (evt.key === "Enter") {
|
|
339
|
-
doLogin();
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
userElem.addEventListener("keyup", (evt) => {
|
|
343
|
-
if (evt.key === "Enter") {
|
|
344
|
-
doLogin();
|
|
345
|
-
}
|
|
346
|
-
});
|
|
347
|
-
userElem.addEventListener("change", (evt) => {
|
|
348
|
-
if (evt.key === "Enter") {
|
|
349
|
-
doLogin();
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
passwordElem.focus();
|
|
104
|
+
authenticated() {
|
|
105
|
+
this.eventHandler.emit("onAuthenticated");
|
|
106
|
+
}
|
|
107
|
+
async expired(callback, type) {
|
|
108
|
+
let authPromise = new Promise((resolve) => {
|
|
109
|
+
let eventHandler = () => {
|
|
110
|
+
this.eventHandler.off("onAuthenticated", eventHandler);
|
|
111
|
+
callback == null ? void 0 : callback();
|
|
112
|
+
resolve();
|
|
113
|
+
};
|
|
114
|
+
this.eventHandler.on("onAuthenticated", eventHandler);
|
|
115
|
+
});
|
|
116
|
+
let dialog = document.querySelector("dialog.session-expired-dialog");
|
|
117
|
+
if (!dialog) {
|
|
118
|
+
dialog = document.createElement("dialog");
|
|
119
|
+
dialog.className = "session-expired-dialog";
|
|
120
|
+
dialog.style.display = "flex";
|
|
121
|
+
dialog.style.padding = "0";
|
|
122
|
+
dialog.style.left = "50%";
|
|
123
|
+
dialog.style.transform = "translateX(-50%)";
|
|
124
|
+
let link = "/login?ReturnUrl=%2fapi/sessionexpired/remove";
|
|
125
|
+
if (type !== "RequireTwoFactor") {
|
|
126
|
+
await fetch("/logout", { method: "POST" });
|
|
127
|
+
} else {
|
|
128
|
+
link = "/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove";
|
|
353
129
|
}
|
|
130
|
+
dialog.innerHTML = `<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${link}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`;
|
|
131
|
+
document.body.append(dialog);
|
|
132
|
+
dialog.showModal();
|
|
133
|
+
await authPromise;
|
|
134
|
+
dialog.remove();
|
|
135
|
+
} else {
|
|
136
|
+
await authPromise;
|
|
354
137
|
}
|
|
355
138
|
}
|
|
356
139
|
attachEvent(eventName, handler) {
|
|
@@ -360,11 +143,6 @@ return s;
|
|
|
360
143
|
return this.eventHandler.off(eventName, handler);
|
|
361
144
|
}
|
|
362
145
|
};
|
|
363
|
-
var SessionHandler = _SessionHandler;
|
|
364
|
-
__publicField(SessionHandler, "messages", {
|
|
365
|
-
login: "Log in",
|
|
366
|
-
relog: "Session expired - log in"
|
|
367
|
-
});
|
|
368
146
|
|
|
369
147
|
// src/UserSession.ts
|
|
370
148
|
var UserSession = class extends SessionHandler {
|
|
@@ -389,7 +167,6 @@ return s;
|
|
|
389
167
|
__publicField(this, "shortDateFormat", "dd.MM.yyyy");
|
|
390
168
|
__publicField(this, "culture", "en-GB");
|
|
391
169
|
__publicField(this, "uiculture", "en-GB");
|
|
392
|
-
__publicField(this, "expired", () => null);
|
|
393
170
|
this.formats = {};
|
|
394
171
|
Object.assign(this, userData);
|
|
395
172
|
}
|
|
@@ -459,7 +236,6 @@ return s;
|
|
|
459
236
|
});
|
|
460
237
|
response = new Response(stream);
|
|
461
238
|
} catch (error) {
|
|
462
|
-
console.warn("Failed to replace response stream to log download progress.");
|
|
463
239
|
}
|
|
464
240
|
const blob = await response.blob();
|
|
465
241
|
reportProgress({ bytesReceived, status: "downloaded" });
|
|
@@ -474,6 +250,11 @@ return s;
|
|
|
474
250
|
}
|
|
475
251
|
}
|
|
476
252
|
|
|
253
|
+
// src/has.ts
|
|
254
|
+
function has(obj, key) {
|
|
255
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
256
|
+
}
|
|
257
|
+
|
|
477
258
|
// src/parseFunc.ts
|
|
478
259
|
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)*)\}$/;
|
|
479
260
|
function parseFunc(func) {
|
|
@@ -502,19 +283,10 @@ return s;
|
|
|
502
283
|
current = current[namespace[i]] = current[namespace[i]] || new Namespace_default();
|
|
503
284
|
}
|
|
504
285
|
return current;
|
|
505
|
-
} else {
|
|
506
|
-
throw new TypeError("Invalid type of parameter 'namespace'");
|
|
507
286
|
}
|
|
508
|
-
} else {
|
|
509
|
-
throw new TypeError("Invalid type of parameter 'root'");
|
|
510
287
|
}
|
|
511
288
|
}
|
|
512
289
|
|
|
513
|
-
// src/warn.ts
|
|
514
|
-
function warn(message, fallbackToAlert) {
|
|
515
|
-
console.warn(message);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
290
|
// src/expose.ts
|
|
519
291
|
function expose(name, value) {
|
|
520
292
|
if (arguments.length !== 2) {
|
|
@@ -550,38 +322,95 @@ return s;
|
|
|
550
322
|
throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");
|
|
551
323
|
}
|
|
552
324
|
if (has(namespace, keyName)) {
|
|
553
|
-
warn([name, keyName].join(".") + " is already defined!");
|
|
325
|
+
console.warn([name, keyName].join(".") + " is already defined!");
|
|
554
326
|
} else {
|
|
555
327
|
namespace[keyName] = value;
|
|
556
328
|
}
|
|
557
329
|
}
|
|
558
330
|
}
|
|
559
331
|
|
|
332
|
+
// src/getLocalizedString.ts
|
|
333
|
+
async function fetchLocalizedString(text) {
|
|
334
|
+
try {
|
|
335
|
+
let response = await fetch(`/api/user/localize/new/${af.article.id}`, {
|
|
336
|
+
body: JSON.stringify({ text }),
|
|
337
|
+
headers: {
|
|
338
|
+
Accept: "application/json; */*",
|
|
339
|
+
"Content-Type": "application/json",
|
|
340
|
+
"X-Requested-With": "XMLHttpRequest"
|
|
341
|
+
},
|
|
342
|
+
method: "POST"
|
|
343
|
+
});
|
|
344
|
+
if (response.ok) {
|
|
345
|
+
return await response.json();
|
|
346
|
+
}
|
|
347
|
+
} catch (error) {
|
|
348
|
+
}
|
|
349
|
+
return text;
|
|
350
|
+
}
|
|
351
|
+
function getLocalizedString(string, wait) {
|
|
352
|
+
var _a;
|
|
353
|
+
if (typeof string === "string" && string.trim().length === 0) {
|
|
354
|
+
return string;
|
|
355
|
+
}
|
|
356
|
+
if (string === void 0 || string === "" || string === null) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
if (((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.i18n) !== void 0) {
|
|
360
|
+
if (!has(af.article.i18n, string)) {
|
|
361
|
+
af.article.i18n[string] = string;
|
|
362
|
+
let promise = fetchLocalizedString(string).then((text) => {
|
|
363
|
+
af.article.i18n[string] = text;
|
|
364
|
+
return text;
|
|
365
|
+
});
|
|
366
|
+
if (wait) {
|
|
367
|
+
return promise;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
return af.article.i18n[string];
|
|
371
|
+
} else {
|
|
372
|
+
return string;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/localize.ts
|
|
377
|
+
function localize(stringParts, ...args) {
|
|
378
|
+
if (!Array.isArray(stringParts) || (stringParts == null ? void 0 : stringParts.length) || stringParts.length !== args.length + 1) {
|
|
379
|
+
throw TypeError("Method 'localize' must be used as a tag function");
|
|
380
|
+
}
|
|
381
|
+
let stringToLocalize = stringParts.map((s, i) => i === stringParts.length - 1 ? s : `${s}$${i}`).join("");
|
|
382
|
+
let localized = getLocalizedString(stringToLocalize);
|
|
383
|
+
args.forEach((arg, index) => {
|
|
384
|
+
localized = localized.replace("$" + index, arg);
|
|
385
|
+
});
|
|
386
|
+
return localized;
|
|
387
|
+
}
|
|
388
|
+
|
|
560
389
|
// src/localStorage.ts
|
|
561
|
-
function getLocalKey(
|
|
390
|
+
function getLocalKey(key) {
|
|
562
391
|
var _a;
|
|
563
|
-
return [((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.id) || "", "common",
|
|
392
|
+
return [((_a = af == null ? void 0 : af.article) == null ? void 0 : _a.id) || "", "common", key].join(".");
|
|
564
393
|
}
|
|
565
394
|
var LocalStorage = class {
|
|
566
395
|
isPersisted() {
|
|
567
396
|
return true;
|
|
568
397
|
}
|
|
569
|
-
getLocalStorageKey(
|
|
570
|
-
return global ? ["common",
|
|
398
|
+
getLocalStorageKey(key, global) {
|
|
399
|
+
return global ? ["common", key].join(".") : getLocalKey(key);
|
|
571
400
|
}
|
|
572
|
-
get(
|
|
573
|
-
const lsKey = this.getLocalStorageKey(
|
|
401
|
+
get(key, defaultValue, global) {
|
|
402
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
574
403
|
const value = localStorage.getItem(lsKey);
|
|
575
404
|
return value !== null ? JSON.parse(value) : defaultValue;
|
|
576
405
|
}
|
|
577
|
-
set(
|
|
406
|
+
set(key, value, global) {
|
|
578
407
|
localStorage.setItem(
|
|
579
|
-
this.getLocalStorageKey(
|
|
408
|
+
this.getLocalStorageKey(key, global),
|
|
580
409
|
JSON.stringify(value)
|
|
581
410
|
);
|
|
582
411
|
}
|
|
583
|
-
remove(
|
|
584
|
-
const lsKey = this.getLocalStorageKey(
|
|
412
|
+
remove(key, global) {
|
|
413
|
+
const lsKey = this.getLocalStorageKey(key, global);
|
|
585
414
|
if (localStorage.getItem(lsKey) !== null) {
|
|
586
415
|
localStorage.removeItem(lsKey);
|
|
587
416
|
return true;
|
|
@@ -591,9 +420,9 @@ return s;
|
|
|
591
420
|
}
|
|
592
421
|
clear() {
|
|
593
422
|
const baseKey = getLocalKey("");
|
|
594
|
-
for (let
|
|
595
|
-
if (
|
|
596
|
-
localStorage.removeItem(
|
|
423
|
+
for (let key in localStorage) {
|
|
424
|
+
if (key.slice(0, baseKey.length) === baseKey) {
|
|
425
|
+
localStorage.removeItem(key);
|
|
597
426
|
}
|
|
598
427
|
}
|
|
599
428
|
}
|
|
@@ -608,8 +437,8 @@ return s;
|
|
|
608
437
|
function getSettings(setting, article) {
|
|
609
438
|
if (!(af == null ? void 0 : af.userSession))
|
|
610
439
|
return null;
|
|
611
|
-
const
|
|
612
|
-
const settings = JSON.parse(localStorage.getItem(
|
|
440
|
+
const key = getKey(article);
|
|
441
|
+
const settings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
613
442
|
if (setting) {
|
|
614
443
|
return settings[setting] || null;
|
|
615
444
|
}
|
|
@@ -618,17 +447,17 @@ return s;
|
|
|
618
447
|
function saveSettings(setting, value, article) {
|
|
619
448
|
if (!(af == null ? void 0 : af.userSession))
|
|
620
449
|
return;
|
|
621
|
-
const
|
|
622
|
-
let userSettings = JSON.parse(localStorage.getItem(
|
|
450
|
+
const key = getKey(article);
|
|
451
|
+
let userSettings = JSON.parse(localStorage.getItem(key) || "{}");
|
|
623
452
|
if (typeof value !== "undefined") {
|
|
624
453
|
userSettings[setting] = value;
|
|
625
454
|
} else {
|
|
626
455
|
userSettings = setting;
|
|
627
456
|
}
|
|
628
|
-
localStorage.setItem(
|
|
457
|
+
localStorage.setItem(key, JSON.stringify(userSettings));
|
|
629
458
|
}
|
|
630
459
|
|
|
631
460
|
// src/index.ts
|
|
632
|
-
var version = "2.0
|
|
461
|
+
var version = "2.1.0";
|
|
633
462
|
return __toCommonJS(src_exports);
|
|
634
463
|
})();
|
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
var af=af||{};af.common=(()=>{var
|
|
2
|
-
if (af.userSession.uiculture === 'nb-NO') {
|
|
3
|
-
const strings = {
|
|
4
|
-
${e.join(`
|
|
5
|
-
`)}
|
|
6
|
-
};
|
|
7
|
-
af.article.i18n = af.article.i18n || {};
|
|
8
|
-
Object.assign(af.article.i18n, strings);
|
|
9
|
-
}`:`<script type="text/javascript">
|
|
10
|
-
function __doNothingWithStrings() {
|
|
11
|
-
@{
|
|
12
|
-
var context = @Appframe.Web.Context.RequestContext.Current;
|
|
13
|
-
}
|
|
14
|
-
let s = {};
|
|
15
|
-
${e.join(`
|
|
16
|
-
`)}
|
|
17
|
-
return s;
|
|
18
|
-
}
|
|
19
|
-
<\/script>`})}}function y(t){let e=I(t);return e===t&&!h.has(t)&&h.add(t),e}var E=class{constructor(){i(this,"eventHandler",x());i(this,"showingDialog",!1);i(this,"dialog",null)}expired(e){if(af.userSession=af.userSession||{login:null},typeof e!="function")throw new TypeError("Parameter pCallback passed to the expired function must be a function!");let n=()=>{this.detachEvent("onAuthenticated",n),e()};if(this.attachEvent("onAuthenticated",n),this.showingDialog!==!0){this.showingDialog=!0;let r=document.createElement("div");r.className="session-expired-container",r.innerHTML=`
|
|
20
|
-
<div class="session-expired-log-in" style="margin-top: 20px;">
|
|
21
|
-
<div class="row">
|
|
22
|
-
<div class="sessionExpired">
|
|
23
|
-
<h4 class="message">Frakoblet - tidsavbrudd</h4>
|
|
24
|
-
<div class="form-group">
|
|
25
|
-
<label for="username">${y("Username")}</label>
|
|
26
|
-
<input type="text" class="form-control" id="username" autofocus>
|
|
27
|
-
</div>
|
|
28
|
-
<div class="form-group">
|
|
29
|
-
<label for="password">${y("Password")}</label>
|
|
30
|
-
<input type="password" autocomplete="password" class="form-control" id="password" >
|
|
31
|
-
</div>
|
|
32
|
-
<div class="form-group">
|
|
33
|
-
<div>
|
|
34
|
-
<button type="submit" class="btn btn-default sign-in">
|
|
35
|
-
${y("Log in")}
|
|
36
|
-
</button>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
</div>
|
|
41
|
-
<div class="row">
|
|
42
|
-
<div class="" style="display:none; margin: 0px 30px;">
|
|
43
|
-
<div class="alert alert-warning" role="alert" style="margin-top:10px;"></div>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
`;let o=af.userSession.login?E.messages.relog:E.messages.login,l=r.querySelector(".message"),a=r.querySelector(".alert-warning"),s=r.querySelector("input[type=text]"),g=r.querySelector(".sign-in"),c=r.querySelector("input[type=password]");if(l!==null&&s!==null&&a!==null&&s!==null&&g!==null&&c!==null){l.innerText=y(o),s.value=af.userSession.login||"",s.disabled=!!af.userSession.login,s.readOnly=!!af.userSession.login,document.body.appendChild(r);let p=async()=>{c.disabled=!0;let d=new Request("/login",{body:JSON.stringify({username:s.value,password:c.value,remember:!1}),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"});try{let u=await(await fetch(d)).json();if(u.success)document.body.removeChild(r),this.showingDialog=!1,this.eventHandler.emit("onAuthenticated"),a.parentNode&&(a.parentNode.style.display="none");else throw new Error(u.error)}catch(m){if(m&&typeof m=="object"){let u=m;c.disabled=!1,c.classList.toggle("invalid",!0),c.value="",c.focus(),a.innerText=u.message?u.message:String(u),a.parentNode&&(a.parentNode.style.display="initial")}}};g.addEventListener("click",p),c.addEventListener("keyup",d=>{d.key==="Enter"&&p()}),c.addEventListener("change",d=>{d.key==="Enter"&&p()}),s.addEventListener("keyup",d=>{d.key==="Enter"&&p()}),s.addEventListener("change",d=>{d.key==="Enter"&&p()}),c.focus()}}}attachEvent(e,n){return this.eventHandler.on(e,n)}detachEvent(e,n){return this.eventHandler.off(e,n)}},f=E;i(f,"messages",{login:"Log in",relog:"Session expired - log in"});var b=class extends f{constructor(n){super();i(this,"amDesignator","a.m.");i(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);i(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);i(this,"decimalSeparator",".");i(this,"domain","OB");i(this,"email");i(this,"formats");i(this,"groupSeparator",null);i(this,"integratedSecurity",!1);i(this,"isDeveloper",!1);i(this,"login","");i(this,"loginType");i(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);i(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);i(this,"name");i(this,"pmDesignator","p.m.");i(this,"shortDateFormat","dd.MM.yyyy");i(this,"culture","en-GB");i(this,"uiculture","en-GB");i(this,"expired",()=>null);this.formats={},Object.assign(this,n)}};function L(t,e){return new Promise(function(n,r){try{let o=URL.createObjectURL(t),l=document.body,a=document.createElement("a");a.setAttribute("download",e),a.href=o,l.append(a),a.click(),l.removeChild(a),setTimeout(function(){URL.revokeObjectURL(o),n()},250)}catch(o){r(o)}})}async function X(t,{fileName:e,signal:n,onProgress:r}){var a;function o(s){typeof r=="function"&&r(z({},s))}let l=0;o({status:"requested"});try{let s=await fetch(t);if(!s.ok||!s.body){if((a=s.headers.get("content-type"))!=null&&a.includes("application/json")){let c=await s.json();if(c.error)throw new Error(c.error)}throw new Error(`${s.status} ${s.statusText}`)}try{let c=s.body.getReader(),p=new ReadableStream({start:function(d){function m(){return c.read().then(function(u){if(u.done){d.close();return}return l+=u.value.length,o({bytesReceived:l,status:"downloading"}),d.enqueue(u.value),m()})}return m()}});s=new Response(p)}catch(c){console.warn("Failed to replace response stream to log download progress.")}let g=await s.blob();o({bytesReceived:l,status:"downloaded"}),await L(g,e),o({bytesReceived:l,status:"completed"})}catch(s){n!=null&&n.aborted?o({status:"cancelled"}):o({error:s.message,status:"error"})}}var V=/^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 _(t){var e=t.toString().match(V);if(e===null)throw new TypeError("Unable to parse function!");return{name:e[1],args:e[2].split(","),body:e[3]}}function $(){}$.prototype=Object.create(null);var D=$;function A(t,e){if(typeof t=="object")if(typeof e=="string"){let n=e.split(".");return A(t,n)}else if(Array.isArray(e)){let n=t;for(let r=0;r<e.length;r++)n=n[e[r]]=n[e[r]]||new D;return n}else throw new TypeError("Invalid type of parameter 'namespace'");else throw new TypeError("Invalid type of parameter 'root'")}function T(t,e){console.warn(t)}function N(t,e){if(arguments.length!==2)throw new Error("Incorrect number of arguments passed to the expose function!");if(Array.isArray(e))for(let n of e){let{name:r}=_(n);if(r)N(t,n);else throw new Error("Unable to detect name of function! Name it, or only supply one function and include name in first parameter.")}else{let n,r;if(typeof e=="function"&&(n=_(e).name),typeof t=="string"){let o=t.split(".");n||(n=o[o.length-1],o=o.slice(0,o.length-1)),r=A(window,o)}else if(n&&(typeof t=="object"||typeof t=="function"))r=t;else throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");w(r,n)?T([t,n].join(".")+" is already defined!"):r[n]=e}}function C(t){var e;return[((e=af==null?void 0:af.article)==null?void 0:e.id)||"","common",t].join(".")}var R=class{isPersisted(){return!0}getLocalStorageKey(e,n){return n?["common",e].join("."):C(e)}get(e,n,r){let o=this.getLocalStorageKey(e,r),l=localStorage.getItem(o);return l!==null?JSON.parse(l):n}set(e,n,r){localStorage.setItem(this.getLocalStorageKey(e,r),JSON.stringify(n))}remove(e,n){let r=this.getLocalStorageKey(e,n);return localStorage.getItem(r)!==null?(localStorage.removeItem(r),!0):!1}clear(){let e=C("");for(let n in localStorage)n.slice(0,e.length)===e&&localStorage.removeItem(n)}},M=new R;function P(t){return`${t||af.article.id}.${af.userSession.login}`}function Q(t,e){if(!(af!=null&&af.userSession))return null;let n=P(e),r=JSON.parse(localStorage.getItem(n)||"{}");return t?r[t]||null:r}function Y(t,e,n){if(!(af!=null&&af.userSession))return;let r=P(n),o=JSON.parse(localStorage.getItem(r)||"{}");typeof e<"u"?o[t]=e:o=t,localStorage.setItem(r,JSON.stringify(o))}var ee="2.0.3";return B(te);})();
|
|
1
|
+
var af=af||{};af.common=(()=>{var g=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames,E=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var S=(t,e,r)=>e in t?g(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,R=(t,e)=>{for(var r in e||(e={}))z.call(e,r)&&S(t,r,e[r]);if(E)for(var r of E(e))K.call(e,r)&&S(t,r,e[r]);return t};var k=(t,e)=>{for(var r in e)g(t,r,{get:e[r],enumerable:!0})},M=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of D(e))!z.call(t,n)&&n!==r&&g(t,n,{get:()=>e[n],enumerable:!(o=I(e,n))||o.enumerable});return t};var F=t=>M(g({},"__esModule",{value:!0}),t);var a=(t,e,r)=>(S(t,typeof e!="symbol"?e+"":e,r),r);var X={};k(X,{SessionHandler:()=>c,UserSession:()=>m,downloadBlob:()=>y,downloadRequest:()=>P,expose:()=>v,getLocalizedString:()=>h,getSettings:()=>J,has:()=>d,localStorage:()=>_,localize:()=>O,mitt:()=>p,saveSettings:()=>C,version:()=>Z});window.addEventListener("error",t=>{var e,r,o,n,i,l,s;try{let f={error:(o=(r=(e=t.error)==null?void 0:e.message)!=null?r:t.message)!=null?o:null,file:t.filename,line:(n=t.lineno)!=null?n:0,column:(i=t.colno)!=null?i:0,stack:(s=(l=t.error)==null?void 0:l.stack)!=null?s:null};fetch("/data/Logger/LogError",{body:JSON.stringify(f),headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8","X-Requested-With":"XMLHttpRequest"},method:"POST"})}catch(f){}});function p(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(n){n(r)}),(o=t.get("*"))&&o.slice().map(function(n){n(e,r)})}}}var c=class{constructor(){a(this,"eventHandler",p())}authenticated(){this.eventHandler.emit("onAuthenticated")}async expired(e,r){let o=new Promise(i=>{let l=()=>{this.eventHandler.off("onAuthenticated",l),e==null||e(),i()};this.eventHandler.on("onAuthenticated",l)}),n=document.querySelector("dialog.session-expired-dialog");if(n)await o;else{n=document.createElement("dialog"),n.className="session-expired-dialog",n.style.display="flex",n.style.padding="0",n.style.left="50%",n.style.transform="translateX(-50%)";let i="/login?ReturnUrl=%2fapi/sessionexpired/remove";r!=="RequireTwoFactor"?await fetch("/logout",{method:"POST"}):i="/login?RequireTwoFactor=1&ReturnUrl=%2fapi/sessionexpired/remove",n.innerHTML=`<iframe sandbox="allow-same-origin allow-scripts allow-modals allow-top-navigation-by-user-activation allow-forms" src="${i}" style="border:0;width:min(500px,100vw);height:min(700px, 100vh);"></iframe>`,document.body.append(n),n.showModal(),await o,n.remove()}}attachEvent(e,r){return this.eventHandler.on(e,r)}detachEvent(e,r){return this.eventHandler.off(e,r)}};var m=class extends c{constructor(r){super();a(this,"amDesignator","a.m.");a(this,"dayNames",["sunday","monday","tuesday","wednesday","thursday","friday","saturday"]);a(this,"dayNamesShort",["sun","mon","tue","wed","thu","fri","sat"]);a(this,"decimalSeparator",".");a(this,"domain","OB");a(this,"email");a(this,"formats");a(this,"groupSeparator",null);a(this,"integratedSecurity",!1);a(this,"isDeveloper",!1);a(this,"login","");a(this,"loginType");a(this,"monthNames",["january","february","march","april","may","june","july","august","september","october","november","december",""]);a(this,"monthNamesShort",["jan","feb","mar","apr","may","jun","jul","augt","sep","oct","nov","dec",""]);a(this,"name");a(this,"pmDesignator","p.m.");a(this,"shortDateFormat","dd.MM.yyyy");a(this,"culture","en-GB");a(this,"uiculture","en-GB");this.formats={},Object.assign(this,r)}};function y(t,e){return new Promise(function(r,o){try{let n=URL.createObjectURL(t),i=document.body,l=document.createElement("a");l.setAttribute("download",e),l.href=n,i.append(l),l.click(),i.removeChild(l),setTimeout(function(){URL.revokeObjectURL(n),r()},250)}catch(n){o(n)}})}async function P(t,{fileName:e,signal:r,onProgress:o}){var l;function n(s){typeof o=="function"&&o(R({},s))}let i=0;n({status:"requested"});try{let s=await fetch(t);if(!s.ok||!s.body){if((l=s.headers.get("content-type"))!=null&&l.includes("application/json")){let u=await s.json();if(u.error)throw new Error(u.error)}throw new Error(`${s.status} ${s.statusText}`)}try{let u=s.body.getReader(),q=new ReadableStream({start:function(L){function j(){return u.read().then(function(w){if(w.done){L.close();return}return i+=w.value.length,n({bytesReceived:i,status:"downloading"}),L.enqueue(w.value),j()})}return j()}});s=new Response(q)}catch(u){}let f=await s.blob();n({bytesReceived:i,status:"downloaded"}),await y(f,e),n({bytesReceived:i,status:"completed"})}catch(s){r!=null&&r.aborted?n({status:"cancelled"}):n({error:s.message,status:"error"})}}function d(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var U=/^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 b(t){var e=t.toString().match(U);if(e===null)throw new TypeError("Unable to parse function!");return{name:e[1],args:e[2].split(","),body:e[3]}}function N(){}N.prototype=Object.create(null);var T=N;function x(t,e){if(typeof t=="object"){if(typeof e=="string"){let r=e.split(".");return x(t,r)}else if(Array.isArray(e)){let r=t;for(let o=0;o<e.length;o++)r=r[e[o]]=r[e[o]]||new T;return r}}}function v(t,e){if(arguments.length!==2)throw new Error("Incorrect number of arguments passed to the expose function!");if(Array.isArray(e))for(let r of e){let{name:o}=b(r);if(o)v(t,r);else throw new Error("Unable to detect name of function! Name it, or only supply one function and include name in first parameter.")}else{let r,o;if(typeof e=="function"&&(r=b(e).name),typeof t=="string"){let n=t.split(".");r||(r=n[n.length-1],n=n.slice(0,n.length-1)),o=x(window,n)}else if(r&&(typeof t=="object"||typeof t=="function"))o=t;else throw new TypeError("Invalid typeof parameter 'name', or unable to parse pValue!");d(o,r)?console.warn([t,r].join(".")+" is already defined!"):o[r]=e}}async function B(t){try{let e=await fetch(`/api/user/localize/new/${af.article.id}`,{body:JSON.stringify({text:t}),headers:{Accept:"application/json; */*","Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},method:"POST"});if(e.ok)return await e.json()}catch(e){}return t}function h(t,e){var r;if(typeof t=="string"&&t.trim().length===0)return t;if(!(t===void 0||t===""||t===null))if(((r=af==null?void 0:af.article)==null?void 0:r.i18n)!==void 0){if(!d(af.article.i18n,t)){af.article.i18n[t]=t;let o=B(t).then(n=>(af.article.i18n[t]=n,n));if(e)return o}return af.article.i18n[t]}else return t}function O(t,...e){if(!Array.isArray(t)||(t==null?void 0:t.length)||t.length!==e.length+1)throw TypeError("Method 'localize' must be used as a tag function");let r=t.map((n,i)=>i===t.length-1?n:`${n}$${i}`).join(""),o=h(r);return e.forEach((n,i)=>{o=o.replace("$"+i,n)}),o}function H(t){var e;return[((e=af==null?void 0:af.article)==null?void 0:e.id)||"","common",t].join(".")}var A=class{isPersisted(){return!0}getLocalStorageKey(e,r){return r?["common",e].join("."):H(e)}get(e,r,o){let n=this.getLocalStorageKey(e,o),i=localStorage.getItem(n);return i!==null?JSON.parse(i):r}set(e,r,o){localStorage.setItem(this.getLocalStorageKey(e,o),JSON.stringify(r))}remove(e,r){let o=this.getLocalStorageKey(e,r);return localStorage.getItem(o)!==null?(localStorage.removeItem(o),!0):!1}clear(){let e=H("");for(let r in localStorage)r.slice(0,e.length)===e&&localStorage.removeItem(r)}},_=new A;function $(t){return`${t||af.article.id}.${af.userSession.login}`}function J(t,e){if(!(af!=null&&af.userSession))return null;let r=$(e),o=JSON.parse(localStorage.getItem(r)||"{}");return t?o[t]||null:o}function C(t,e,r){if(!(af!=null&&af.userSession))return;let o=$(r),n=JSON.parse(localStorage.getItem(o)||"{}");typeof e<"u"?n[t]=e:n=t,localStorage.setItem(o,JSON.stringify(n))}var Z="2.1.0";return F(X);})();
|
|
48
2
|
//# sourceMappingURL=af.common.legacy.min.js.map
|