-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.js
45 lines (34 loc) · 1015 Bytes
/
main.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
import Settings from './classes/app/Preferences.js';
import DB from './classes/app/Database.js';
import UI from './classes/app/UserInterface.js';
window.suppressReload = false;
function update() {
if (DB.locations.length === 0) return;
UI.update();
}
// INIT
async function startVerseTime() {
await DB.createDatabase();
DB.locations.sort((a, b) => a.NAME.localeCompare(b.NAME));
UI.populateLocationList();
UI.setupEventListeners();
checkHash();
Settings.load();
setInterval(update, 250);
update();
}
startVerseTime();
function checkHash() {
const hash = window.location.hash;
if (hash === '') return;
const hashParts = hash.replace('#', '').replaceAll('_', ' ').split('@');
const locationName = hashParts[0];
if (hashParts[1] !== undefined) {
UI.setCustomTime(hashParts[1], true);
}
UI.setMapLocation(locationName);
}
window.addEventListener('hashchange', () => {
if (window.suppressReload) return;
window.location.reload(true);
}, false);