-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·88 lines (83 loc) · 3.12 KB
/
index.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
83
84
85
86
87
88
<!DOCTYPE html>
<html prefix="og: https://ogp.me/ns#">
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<meta property="og:title" content="A Lojban Wordle clone" />
<meta property="og:type" content="web app" />
<meta property="og:url" content="https://la-lojban.github.io/valsr/" />
<meta
property="og:image"
content="https://la-lojban.github.io/valsr/valsr.jpg"
/>
<meta property="og:description" content="Guess the word in six tries." />
<link data-trunk rel="rust" data-bin="valsr" />
<link data-trunk rel="css" href="./static/styles.css" />
<link data-trunk rel="copy-file" href="static/valsr.jpg" />
<link data-trunk rel="copy-file" href="static/robots.txt" />
<link rel="apple-touch-icon" sizes="144x144" href="144.png" />
<link data-trunk rel="copy-file" href="static/144.png" />
<link data-trunk rel="copy-file" href="static/32.png" />
<link
data-trunk
rel="icon"
type="image/png"
sizes="32x32"
href="./static/32.png"
/>
<meta name="theme-color" content="#ffddcc" />
<title>A Lojban Wordle clone</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.1/socket.io.js"></script>
</head>
<body>
<script>
document.addEventListener("DOMContentLoaded", () => {
var socket1Chat_connected;
var socket1Chat = io("wss://jbotcan.org:9091", {
transports: ["polling", "websocket"],
});
// if (socket1Chat) {
socket1Chat.on("connect", function () {
console.log(socket1Chat);
socket1Chat_connected = true;
});
socket1Chat.on("connect_error", function () {
console.log("1chat connection error");
});
function trimSocketChunk(text) {
return text
.replace(/[\n\r]+$/gims, " ")
.replace(/<br *\/?>/gims, " ");
// .split('<')[0]
}
socket1Chat.on("sentFrom", function (data) {
if (!socket1Chat_connected) return;
const i = data.data;
const msg = {
d: trimSocketChunk(i.chunk),
s: i.channelId,
w: i.author,
};
const velsku = document.getElementById("velsku_sebenji");
velsku.innerHTML = `<img src="https://la-lojban.github.io/sutysisku/pixra/nunsku.svg" class="velsku_pixra"/> <span class="velsku_pamei">[${msg.s}] ${msg.w}: ${msg.d}</span>`;
});
socket1Chat.on("history", function (data) {
if (!socket1Chat_connected) return;
const i = data.slice(-1)[0];
if (!i) return;
const msg = {
d: trimSocketChunk(i.chunk),
s: i.channelId,
w: i.author,
};
const velsku = document.getElementById("velsku_sebenji");
velsku.innerHTML = `<img src="https://la-lojban.github.io/sutysisku/pixra/nunsku.svg" class="velsku_pixra"/> <span class="velsku_pamei">[${msg.s}] ${msg.w}: ${msg.d}</span>`;
});
// }
});
</script>
</body>
</html>