From 1bf119d68dff3493eb01997ae531ef6b16b65463 Mon Sep 17 00:00:00 2001 From: elijahr2411 Date: Tue, 31 Jan 2023 12:00:09 -0500 Subject: [PATCH] Add force vote functionality --- dist/index.html | 6 +++++- dist/style.css | 4 ++++ src/index.js | 11 ++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/dist/index.html b/dist/index.html index 090aa27..bef2901 100644 --- a/dist/index.html +++ b/dist/index.html @@ -75,7 +75,11 @@
diff --git a/dist/style.css b/dist/style.css index 1a4a8f5..5b6ca3e 100644 --- a/dist/style.css +++ b/dist/style.css @@ -81,4 +81,8 @@ #xssCheckboxContainer { display: none; +} + +#forceVotePanel { + display: none; } \ No newline at end of file diff --git a/src/index.js b/src/index.js index 5d43aab..5ea9dfd 100644 --- a/src/index.js +++ b/src/index.js @@ -27,6 +27,8 @@ const buttons = { qemuMonitorSend: window.document.getElementById("qemuMonitorSendBtn"), sendChat: window.document.getElementById("sendChatBtn"), ctrlAltDel: window.document.getElementById("ctrlAltDelBtn"), + forceVoteYes: window.document.getElementById("forceVoteYesBtn"), + forceVoteNo: window.document.getElementById("forceVoteNoBtn"), } var hasTurn = false; var vm; @@ -55,6 +57,7 @@ const qemuMonitorInput = document.getElementById("qemuMonitorInput"); const qemuMonitorOutput = document.getElementById("qemuMonitorOutput"); const xssCheckbox = document.getElementById("xssCheckbox"); const xssCheckboxContainer = document.getElementById("xssCheckboxContainer"); +const forceVotePanel = document.getElementById("forceVotePanel"); // needed to scroll to bottom const chatListDiv = document.querySelector(".chat-table"); @@ -353,6 +356,7 @@ class CollabVMClient { if ((config.xssImplementation === 2 && perms.xss) || (rank === 2 && config.xssImplementation === 1)) { xssCheckboxContainer.style.display = "inline-block"; } + if (perms.forcevote) forceVotePanel.style.display = "block"; users.forEach((u) => userModOptions(u.username, u.element, u.element.children[0])); break; case "19": @@ -532,7 +536,10 @@ class CollabVMClient { userXss: (user, msg) => { if (config.xssImplementation !== 2 || !users.find(u => u.username === user)) return; this.socket.send(guacutils.encode(["admin", "21", user, msg])); - } + }, + forceVote: (result) => { + this.socket.send(guacutils.encode(["admin", "13", result ? "1" : "0"])); + }, } } function multicollab(url) { @@ -741,6 +748,8 @@ buttons.reboot.addEventListener('click', () => vm.admin.reboot()); buttons.clearQueue.addEventListener('click', () => vm.admin.clearQueue()); buttons.bypassTurn.addEventListener('click', () => vm.admin.bypassTurn()); buttons.endTurn.addEventListener('click', () => vm.admin.endTurn(users[0])); +buttons.forceVoteYes.addEventListener('click', () => vm.admin.forceVote(true)); +buttons.forceVoteNo.addEventListener('click', () => vm.admin.forceVote(false)); // QEMU Monitor Shit function sendQEMUCommand() { if (!qemuMonitorInput.value) return;