commit
af48aa7e19
2 changed files with 15 additions and 3 deletions
2
dist/index.html
vendored
2
dist/index.html
vendored
|
@ -54,7 +54,7 @@
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="#" class="nav-link active" aria-current="page"><i class="fa-solid fa-house"></i> Home</a>
|
<a id="homeBtn" href="#" class="nav-link active" aria-current="page"><i class="fa-solid fa-house"></i> Home</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a href="https://computernewb.com/collab-vm/faq/" class="nav-link"><i class="fa-solid fa-circle-question"></i> FAQ</a>
|
<a href="https://computernewb.com/collab-vm/faq/" class="nav-link"><i class="fa-solid fa-circle-question"></i> FAQ</a>
|
||||||
|
|
16
src/index.js
16
src/index.js
|
@ -14,6 +14,7 @@ var connected = false;
|
||||||
const vms = [];
|
const vms = [];
|
||||||
const users = [];
|
const users = [];
|
||||||
const buttons = {
|
const buttons = {
|
||||||
|
home: window.document.getElementById("homeBtn"),
|
||||||
takeTurn: window.document.getElementById("takeTurnBtn"),
|
takeTurn: window.document.getElementById("takeTurnBtn"),
|
||||||
changeUsername: window.document.getElementById("changeUsernameBtn"),
|
changeUsername: window.document.getElementById("changeUsernameBtn"),
|
||||||
voteReset: window.document.getElementById("voteResetButton"),
|
voteReset: window.document.getElementById("voteResetButton"),
|
||||||
|
@ -83,7 +84,8 @@ class CollabVMClient {
|
||||||
rej(e);
|
rej(e);
|
||||||
}
|
}
|
||||||
this.socket.addEventListener('message', (e) => this.#onMessage(e));
|
this.socket.addEventListener('message', (e) => this.#onMessage(e));
|
||||||
this.socket.addEventListener('open', () => res(), {once: true});
|
this.socket.addEventListener('open', () => res(true), {once: true});
|
||||||
|
this.socket.addEventListener('close', (e) => { if(!e.wasClean) res(false); }, {once: true});
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -602,7 +604,8 @@ class CollabVMClient {
|
||||||
function multicollab(url) {
|
function multicollab(url) {
|
||||||
return new Promise(async (res, rej) => {
|
return new Promise(async (res, rej) => {
|
||||||
var vm = new CollabVMClient(url, false);
|
var vm = new CollabVMClient(url, false);
|
||||||
await vm.connect();
|
var connected = await vm.connect();
|
||||||
|
if(!connected) return res(false);
|
||||||
var list = await vm.list();
|
var list = await vm.list();
|
||||||
vm.disconnect();
|
vm.disconnect();
|
||||||
list.forEach((curr) => {
|
list.forEach((curr) => {
|
||||||
|
@ -714,6 +717,14 @@ function addUserDropdownItem(ul, text, func) {
|
||||||
li.appendChild(a);
|
li.appendChild(a);
|
||||||
ul.appendChild(li);
|
ul.appendChild(li);
|
||||||
}
|
}
|
||||||
|
function returnToVMList() {
|
||||||
|
if(!connected) return;
|
||||||
|
connected = false;
|
||||||
|
vm.disconnect();
|
||||||
|
vmview.style.display = "none";
|
||||||
|
vmlist.style.display = "block";
|
||||||
|
}
|
||||||
|
|
||||||
async function openVM(url, node) {
|
async function openVM(url, node) {
|
||||||
if (connected) return;
|
if (connected) return;
|
||||||
connected = true;
|
connected = true;
|
||||||
|
@ -768,6 +779,7 @@ function cleanup() {
|
||||||
display.height = 0;
|
display.height = 0;
|
||||||
display.width = 0;
|
display.width = 0;
|
||||||
}
|
}
|
||||||
|
buttons.home.addEventListener('click', async () => returnToVMList());
|
||||||
buttons.screenshot.addEventListener('click', async () => {
|
buttons.screenshot.addEventListener('click', async () => {
|
||||||
var blob = await screenshotVM();
|
var blob = await screenshotVM();
|
||||||
var url = URL.createObjectURL(blob);
|
var url = URL.createObjectURL(blob);
|
||||||
|
|
Loading…
Reference in a new issue