-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
35 lines (30 loc) · 1006 Bytes
/
main.js
File metadata and controls
35 lines (30 loc) · 1006 Bytes
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
const PARSER = new DOMParser()
addEventListener("hashchange", loadContent)
addEventListener("load", loadContent, {passive:true, once: true})
document.getElementById("contact").addEventListener("mouseover", addContact, { once: true })
async function loadContent(ev = undefined) {
let content = location.hash?.slice(1) || "profile"
let data = await fetch(`pages/${content}.html`)
let dom = PARSER.parseFromString(await data.text(), "text/html")
document.title = dom.title
document.getElementById("content").replaceChildren(...dom.body.children)
}
function addContact(ev) {
let r = dec([114, 126, 127, 101, 112, 114, 101, 81, 127, 126, 114, 114, 100, 63, 112, 99, 101])
let m = dec([124, 112, 120, 125, 101, 126, 43])
ev.target.href = `${m}:${r}`
}
function enc(x) {
let o = []
for (c of x) {
o.push(c.charCodeAt() ^ 17)
}
return o
}
function dec(x) {
let o = ""
for (c of x) {
o += String.fromCharCode(c ^ 17)
}
return o
}