-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
51 lines (40 loc) · 1.13 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
/**
* Entry of NeoHC++, sets up UI.
*/
import { updateInputSize, updateTitle } from "./ui-utils.js"
import { inputActionsHandler } from "./input.js"
import { frontPage } from "./frontpage.js"
import $ref from "./ref.ts"
myChannel = location.search.replace(/^\?/, "").split('@', 1)[0]
window.addEventListener("scroll", () => {
if (isAtBottom()) {
updateTitle()
}
})
updateInputSize()
input.addEventListener('input', updateInputSize)
input.addEventListener('keydown', inputActionsHandler)
//https://github.com/hack-chat/main/pull/184
//select "chatinput" on "/"
document.addEventListener("keydown", (e) => {
if (e.key === '/' && input != document.activeElement) {
e.preventDefault()
input.focus()
}
})
;(async () => {
if (myChannel) {
await engine.connect()
myNick = prompt("Nickname:", localStorageGet("myNick"))
if (!myNick) {
engine.close()
} else {
localStorageSet("myNick", myNick)
$onlineUsers = new $ref([])
await engine.join(myChannel, myNick)
}
} else {
footer.classList.add('hidden')
pushMessage({ text: frontPage() }, { renderMode: "allowHTML" })
}
})()