Skip to content

Commit 3631fc1

Browse files
committed
UX tweaks
1 parent f822f55 commit 3631fc1

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

web/src/app.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const refresh = (e:ServerEventMessage) => {
3232
var client:ServerEventsClient = null;
3333
const refreshUsers = async () => {
3434
var users = await client.getChannelSubscribers();
35-
users.sort((x,y) => x.userId.localeCompare(y.userId));
35+
users.sort((x,y) => y.userId.localeCompare(x.userId));
3636

3737
var usersMap = {};
3838
var userIds = Object.keys(usersMap);
@@ -44,7 +44,8 @@ const refreshUsers = async () => {
4444
const startListening = () => {
4545
BASEURL = $("#baseUrl").value;
4646
CHANNEL = $("#channel").value;
47-
if (client != null) client.stop();
47+
if (client != null)
48+
client.stop();
4849

4950
console.log(`Connecting to ${BASEURL} on channel ${CHANNEL}`);
5051
client = new ServerEventsClient(BASEURL, [CHANNEL], {
@@ -70,18 +71,8 @@ const startListening = () => {
7071
}
7172

7273
startListening();
73-
$("#btnChange").onclick = startListening;
74-
$$("input").forEach(x => x.onkeydown = e => e.keyCode == 13 ? startListening() : null);
75-
$("#btnSendChat").onclick = e => {
76-
let request = new PostChatToChannel();
77-
request.from = sub.id;
78-
request.channel = CHANNEL;
79-
request.selector = "cmd.chat";
80-
request.message = $("#txtChat").value;
81-
client.serviceClient.post(request);
82-
};
83-
$("#rawOptions").onchange = function(e) { $("#txtRaw").value = this.value; };
84-
$("#btnSendRaw").onclick = e => {
74+
75+
const sendChat = () => {
8576
var parts = splitOnFirst($("#txtRaw").value, " ");
8677
if (!parts[0].trim()) return;
8778
let request = new PostRawToChannel();
@@ -90,4 +81,20 @@ $("#btnSendRaw").onclick = e => {
9081
request.selector = parts[0].trim();
9182
request.message = parts.length == 2 ? parts[1].trim() : null;
9283
client.serviceClient.post(request);
93-
};
84+
};
85+
const sendRaw = () => {
86+
let request = new PostChatToChannel();
87+
request.from = sub.id;
88+
request.channel = CHANNEL;
89+
request.selector = "cmd.chat";
90+
request.message = $("#txtChat").value;
91+
client.serviceClient.post(request);
92+
};
93+
94+
$("#btnChange").onclick = startListening;
95+
$$("#baseUrl,#channel").forEach(x => x.onkeydown = e => e.keyCode == 13 ? startListening() : null);
96+
$("#btnSendChat").onclick = sendChat;
97+
$("#txtChat").onkeydown = e => e.keyCode == 13 ? sendChat() : null;
98+
$("#rawOptions").onchange = function(e) { $("#txtRaw").value = this.value; };
99+
$("#btnSendRaw").onclick = sendRaw;
100+
$("#txtChat").onkeydown = e => e.keyCode == 13 ? sendRaw() : null;

0 commit comments

Comments
 (0)