This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
/
index.js
102 lines (85 loc) · 2.79 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
function setorder() {
var order = []
var apps = document.getElementsByClassName("app")
for (app in apps) {
if (apps[app].id) {
order.push(apps[app].id)
}
}
localStorage.setItem("order", JSON.stringify(order))
}
async function getapps() {
var appsjson = await fetch("./apps.json")
var apps = await appsjson.json()
var orderjson = await fetch("./order.json")
var order = await orderjson.json()
for (app in order) {
var appelm = document.createElement("div")
appelm.className = "app"
appelm.id = apps[app].id
appelm.setAttribute("onclick", 'new Nightmare({"id":' + apps[app].id + ', "title": "' + apps[app].title + '", "type": "' + apps[app].type + '", "' + apps[app].type + '": "' + apps[app][apps[app].type] + '", "width": 800, "height": 600, "theme": "dark"})')
var appimg = document.createElement("img")
appimg.className = "appimg"
appimg.src = apps[app].icon
appelm.appendChild(appimg)
var apptitle = document.createElement("div")
apptitle.className = "apptitle"
apptitle.innerText = apps[app].title
appelm.appendChild(apptitle)
/* whats this?
if (apps[app].click) {
appelm.addEventListener('click', function() {eval(apps[app].click)})
}
*/
document.getElementById("apps").appendChild(appelm)
}
}
async function getappslocal() {
var appsjson = await fetch("/apps.json")
var apps = await appsjson.json()
var order = JSON.parse(localStorage.getItem("order"))
for (app in order) {
var appelm = document.createElement("div")
appelm.className = "app"
appelm.id = apps[app].id
appelm.setAttribute("onclick", 'new Nightmare({"id":' + apps[order[app]].id + ', "title": "' + apps[order[app]].title + '", "type": "' + apps[app].type + '", "' + apps[app].type + '": "' + apps[order[app]][apps[app].type] + '", "width": 800, "height": 600})')
var appimg = document.createElement("img")
appimg.className = "appimg"
appimg.src = apps[order[app]].icon
appelm.appendChild(appimg)
var apptitle = document.createElement("div")
apptitle.className = "apptitle"
apptitle.innerText = apps[order[app]].title
appelm.appendChild(apptitle)
document.getElementById("apps").appendChild(appelm)
}
}
if (localStorage.getItem("order") !== null) {
getappslocal()
} else {
getapps()
}
window.onload = function() {
$("#apps").sortable({stop: function() {
setorder()
}});
}
window.addEventListener("load", function() {
setTimeout(() => {
document.getElementById("splash").style.display = 'none'
}, 2000)
})
function setTime() {
var today = new Date();
var hour = today.getHours() % 12 || 12;
var minute = today.getMinutes();
var period = today.toLocaleString([], { hour12: true});
period = period.split(" ")[2];
if (hour < 10) {hour = "0" + hour}
if (minute < 10) {minute = "0" + minute}
document.getElementById("navtime").innerText = hour + ":" + minute + " " + period
setTimeout(setTime, 1000);
}
window.onload = function() {
setTime()
}