-
Notifications
You must be signed in to change notification settings - Fork 331
/
index.js
57 lines (29 loc) · 1.01 KB
/
index.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* Frank Poth 2020-01-03 */
(() => {
const main_container = document.getElementById('main');
const clearMainContainer = function() {
while(main_container.firstChild) main_container.removeChild(main_container.firstChild);
};
const fillMainContainer = function(markup) {
var fragment = document.createRange().createContextualFragment(markup);
while(fragment.firstElementChild) main_container.appendChild(fragment.firstElementChild);
};
const getLocationHashValue = function() {
return window.location.hash.slice(1, window.location.hash.length);
};
const loadPage = function(url) {
if (url == '') {
window.location.hash = '/pages/home/home.js';
return;
}
import(url).then(module => {
clearMainContainer();
module.Page.getHTML(fillMainContainer);
});
};
window.addEventListener('hashchange', event => {
event.preventDefault();
loadPage(getLocationHashValue());
});
loadPage(getLocationHashValue());
})();