Add force vote functionality

This commit is contained in:
elijahr2411 2023-01-31 12:00:09 -05:00
parent 3c17e457d6
commit 1bf119d68d
3 changed files with 19 additions and 2 deletions

6
dist/index.html vendored
View file

@ -75,7 +75,11 @@
<div id="voteResetPanel" class="bg-dark text-light" style="display:none;"> <div id="voteResetPanel" class="bg-dark text-light" style="display:none;">
Do you want to reset the vm?<br/> Do you want to reset the vm?<br/>
<button class="btn btn-success" id="voteYesBtn"><i class="fa-solid fa-check"></i> Yes<span class="badge bg-secondary" id="voteYesLabel"></span></button> <button class="btn btn-danger" id="voteNoBtn"><i class="fa-solid fa-ban"></i> No<span class="badge bg-secondary" id="voteNoLabel"></span></button><br/> <button class="btn btn-success" id="voteYesBtn"><i class="fa-solid fa-check"></i> Yes<span class="badge bg-secondary" id="voteYesLabel"></span></button> <button class="btn btn-danger" id="voteNoBtn"><i class="fa-solid fa-ban"></i> No<span class="badge bg-secondary" id="voteNoLabel"></span></button><br/>
Vote ends in <span id="votetime"></span> seconds Vote ends in <span id="votetime"></span> seconds<br/>
<div id="forceVotePanel">
<button class="btn btn-info" id="forceVoteYesBtn"><i class="fa-solid fa-check"></i> Pass Vote</button>
<button class="btn btn-info" id="forceVoteNoBtn"><i class="fa-solid fa-ban"></i> Cancel Vote</button>
</div>
</div> </div>
<div id="btns"> <div id="btns">
<button class="btn btn-secondary" id="takeTurnBtn"><i class="fa-solid fa-computer-mouse"></i> Take Turn</button> <button class="btn btn-secondary" id="takeTurnBtn"><i class="fa-solid fa-computer-mouse"></i> Take Turn</button>

4
dist/style.css vendored
View file

@ -82,3 +82,7 @@
#xssCheckboxContainer { #xssCheckboxContainer {
display: none; display: none;
} }
#forceVotePanel {
display: none;
}

View file

@ -27,6 +27,8 @@ const buttons = {
qemuMonitorSend: window.document.getElementById("qemuMonitorSendBtn"), qemuMonitorSend: window.document.getElementById("qemuMonitorSendBtn"),
sendChat: window.document.getElementById("sendChatBtn"), sendChat: window.document.getElementById("sendChatBtn"),
ctrlAltDel: window.document.getElementById("ctrlAltDelBtn"), ctrlAltDel: window.document.getElementById("ctrlAltDelBtn"),
forceVoteYes: window.document.getElementById("forceVoteYesBtn"),
forceVoteNo: window.document.getElementById("forceVoteNoBtn"),
} }
var hasTurn = false; var hasTurn = false;
var vm; var vm;
@ -55,6 +57,7 @@ const qemuMonitorInput = document.getElementById("qemuMonitorInput");
const qemuMonitorOutput = document.getElementById("qemuMonitorOutput"); const qemuMonitorOutput = document.getElementById("qemuMonitorOutput");
const xssCheckbox = document.getElementById("xssCheckbox"); const xssCheckbox = document.getElementById("xssCheckbox");
const xssCheckboxContainer = document.getElementById("xssCheckboxContainer"); const xssCheckboxContainer = document.getElementById("xssCheckboxContainer");
const forceVotePanel = document.getElementById("forceVotePanel");
// needed to scroll to bottom // needed to scroll to bottom
const chatListDiv = document.querySelector(".chat-table"); const chatListDiv = document.querySelector(".chat-table");
@ -353,6 +356,7 @@ class CollabVMClient {
if ((config.xssImplementation === 2 && perms.xss) || (rank === 2 && config.xssImplementation === 1)) { if ((config.xssImplementation === 2 && perms.xss) || (rank === 2 && config.xssImplementation === 1)) {
xssCheckboxContainer.style.display = "inline-block"; xssCheckboxContainer.style.display = "inline-block";
} }
if (perms.forcevote) forceVotePanel.style.display = "block";
users.forEach((u) => userModOptions(u.username, u.element, u.element.children[0])); users.forEach((u) => userModOptions(u.username, u.element, u.element.children[0]));
break; break;
case "19": case "19":
@ -532,7 +536,10 @@ class CollabVMClient {
userXss: (user, msg) => { userXss: (user, msg) => {
if (config.xssImplementation !== 2 || !users.find(u => u.username === user)) return; if (config.xssImplementation !== 2 || !users.find(u => u.username === user)) return;
this.socket.send(guacutils.encode(["admin", "21", user, msg])); this.socket.send(guacutils.encode(["admin", "21", user, msg]));
} },
forceVote: (result) => {
this.socket.send(guacutils.encode(["admin", "13", result ? "1" : "0"]));
},
} }
} }
function multicollab(url) { function multicollab(url) {
@ -741,6 +748,8 @@ buttons.reboot.addEventListener('click', () => vm.admin.reboot());
buttons.clearQueue.addEventListener('click', () => vm.admin.clearQueue()); buttons.clearQueue.addEventListener('click', () => vm.admin.clearQueue());
buttons.bypassTurn.addEventListener('click', () => vm.admin.bypassTurn()); buttons.bypassTurn.addEventListener('click', () => vm.admin.bypassTurn());
buttons.endTurn.addEventListener('click', () => vm.admin.endTurn(users[0])); 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 // QEMU Monitor Shit
function sendQEMUCommand() { function sendQEMUCommand() {
if (!qemuMonitorInput.value) return; if (!qemuMonitorInput.value) return;