-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstore.html
executable file
·82 lines (79 loc) · 2.17 KB
/
store.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
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
<style>
body {
background-color: #222;
color: #fff;
font-family: system-ui, sans-serif;
overflow-y: auto !important;
}
#apps {
display: flex;
scroll-snap-type: x mandatory;
overflow-x: scroll;
width: 99%;
height: auto;
}
app {
padding: 20px;
margin-right: 50px;
display: inline-block;
scroll-snap-align: center;
/* height: 10%; */
background-color: black;
width: 750px;
}
</style>
<div id="ctx"></div>
<link rel="stylesheet" href="style.css">
<script src="ctx.js" type="text/javascript" charset="utf-8"></script>
<main id="main">Loading...</main>
<script>
if (location.search == "") {
main.innerText=""
document.write(`<h1>${hmm.t("menu.apps-label")}</h1>
<div id=apps></div>`)
fetch("store/apps.json").then(e => e.text()).then(e => {
apps.innerText = ""
var a = JSON.parse(e)
Object.keys(a).forEach(h => {
var el = document.createElement("app")
el.innerText = a[h][hmm.storage.opts.lang] || a[h].en || h
el.setAttribute("appId", h)
el.onclick = () => {
location = "?" + h
}
apps.appendChild(el)
})
})
} else {
fetch("store/" + location.search.slice(1)).then(e => e.text()).then(str => {
main.innerText=""
const json = JSON.parse(str)
document.body.innerHTML += (`
<button onclick='location.search=""'>< ${hmm.t("apps.fe.goback")}</button>
<h1 id=title></h1><p id=desc></p><button id=dl default>${hmm.t("apps.store.download")}</button>
`)
function oc() {
if (location.search.slice(1) in hmm.storage.apps) {
dl.innerHTML = hmm.t("ui.delete")
dl.addEventListener('click', () => {
eval(json.ondelete)
eval('delete ' + hmm.pathToDot("/apps/" + location.search.slice(1)))
dl.innerHTML = hmm.t("apps.store.download")
hmm.setup()
oc()
},{once:true})
} else
dl.addEventListener('click',()=>{
eval(hmm.pathToDot("/apps/" + location.search.slice(1)) + "=json")
eval(json.ondownload)
dl.innerHTML = hmm.t("ui.delete")
hmm.setup()
oc()
},{once:true})
}
oc()
title.innerText = json.title[hmm.storage.opts.lang] || json.title.en || location.search.slice(1)
desc.innerText = json.description
})
}
</script>