-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (45 loc) · 1.07 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
import Nav from './components/nav.html';
const DEFAULT_PAGE = 'home';
let current = null;
function getPageHash() {
return window.location.hash.substring(1) || DEFAULT_PAGE;
}
/**
* The page loader, uses steal.import (similar to systemjs.import) to
* gather progressively loaded page files
* @param {string} page the page to loadPage
*/
function loadPage(page) {
if (current) {
current.destroy();
current = null;
}
steal.import(`steal-svelte/pages/${page}.html`).then(function(module) {
current = new module.default({
target: document.body,
data: {}
});
});
}
window.onhashchange = function() {
loadPage(getPageHash());
}
const nav = new Nav({
target: document.body,
data: {
pages: [{
title: 'Home',
id: 'home'
}, {
title: 'Clock',
id: 'clock'
}, {
title: 'Data Entry',
id: 'crud'
}, {
title: 'Draw some circles',
id: 'circle'
}]
}
})
loadPage(getPageHash());