forked from NIH-ODSS/fhir-for-research
-
Notifications
You must be signed in to change notification settings - Fork 0
/
head.html
40 lines (35 loc) · 1.14 KB
/
head.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!-- head.html -->
<!-- any content in this file is inserted into <head></head> -->
<script src="/modules/mappings.js"></script>
<script>
// test if local storage is available and inititilize global variable store, code adapted from:
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
function initLocalStorage() {
let storage;
try {
storage = window["localStorage"];
const x = "__storage_test__";
storage.setItem(x, x);
storage.removeItem(x);
return storage;
} catch (e) {
console.log("Error: local storage unavailable.");
return (
e instanceof DOMException &&
// everything except Firefox
(e.code === 22 ||
// Firefox
e.code === 1014 ||
// test name field too, because code might not be present
// everything except Firefox
e.name === "QuotaExceededError" ||
// Firefox
e.name === "NS_ERROR_DOM_QUOTA_REACHED") &&
// acknowledge QuotaExceededError only if there's something already stored
storage &&
storage.length !== 0
);
}
}
var store = initLocalStorage();
</script>