-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
67 lines (61 loc) · 1.89 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// load Vue.js and font
await new Promise(async resolve => {
// determine current IP location to decide which sources to use
const m = document.cookie.match(/(?:^|;)\s*ipCountryCode=([^;]*)/)
if (m && m[1]) load({ countryCode: m[1] })
else {
try {
window._ipApiCallback = load
await loadScript(
"http://ip-api.com/json/?fields=2&callback=_ipApiCallback"
)
} catch (_) {
load()
}
}
async function load(o) {
if (o) document.cookie = "ipCountryCode=" + o.countryCode
const isChinaMainland = o ? o.countryCode === "CN" : false
await loadScript(
// currently CDNJS seems to work well enough both in and outside China
isChinaMainland
? "https://cdnjs.cloudflare.com/ajax/libs/vue/3.2.14/vue.global.prod.js"
: "https://cdnjs.cloudflare.com/ajax/libs/vue/3.2.14/vue.global.prod.js"
)
loadStyle(
`https://${
isChinaMainland ? "fonts.font.im" : "fonts.googleapis.com"
}/css2?family=Comfortaa:wght@300;700&display=swap`
)
resolve()
}
function loadScript(src) {
return new Promise((resolve, reject) => {
const e = document.createElement("script")
e.src = src
e.addEventListener("load", () => resolve())
e.addEventListener("error", () => reject())
document.head.appendChild(e)
})
}
function loadStyle(href) {
const e = document.createElement("link")
e.rel = "stylesheet"
e.href = href
document.head.appendChild(e)
}
})
import App from "./components/App.js"
let app = Vue.createApp(App, {
showAutomationNotice: true,
showUnicodeFirst: true,
showSources: false,
})
app.mount("#app")
function updateMusicOnly() {
if (location.hash === "#musiconly")
document.getElementById("app").classList.add("musiconly")
else document.getElementById("app").classList.remove("musiconly")
}
window.onhashchange = updateMusicOnly
updateMusicOnly()