You can now access a VM through url hash
This commit is contained in:
parent
bf43f2533d
commit
7d32a70f58
1 changed files with 20 additions and 9 deletions
29
src/index.js
29
src/index.js
|
@ -316,27 +316,33 @@ function multicollab(url) {
|
||||||
await vm.connect();
|
await vm.connect();
|
||||||
var list = await vm.list();
|
var list = await vm.list();
|
||||||
vm.disconnect();
|
vm.disconnect();
|
||||||
list.forEach(curr => {
|
for (var i = 0; i < list.length; i++) {
|
||||||
vms.push(curr);
|
var id = list[i].id;
|
||||||
|
var name = list[i].name;
|
||||||
|
if (id === window.location.hash.substring(1)) {
|
||||||
|
openVM(url, id);
|
||||||
|
res(false);
|
||||||
|
}
|
||||||
|
vms.push(list[i]);
|
||||||
var div = document.createElement("div");
|
var div = document.createElement("div");
|
||||||
div.classList = "col-sm-4";
|
div.classList = "col-sm-4";
|
||||||
var card = document.createElement("div");
|
var card = document.createElement("div");
|
||||||
card.classList = "card bg-dark text-light";
|
card.classList = "card bg-dark text-light";
|
||||||
card.addEventListener("click", () => openVM(curr.url, curr.id));
|
card.addEventListener("click", () => openVM(url, id));
|
||||||
var img = document.createElement("img");
|
var img = document.createElement("img");
|
||||||
img.src = "data:image/png;base64," + curr.thumb;
|
img.src = "data:image/png;base64," + list[i].thumb;
|
||||||
img.classList = "card-img-top";
|
img.classList = "card-img-top";
|
||||||
var bdy = document.createElement("div");
|
var bdy = document.createElement("div");
|
||||||
bdy.classList = "card-body";
|
bdy.classList = "card-body";
|
||||||
var desc = document.createElement("h5");
|
var desc = document.createElement("h5");
|
||||||
desc.innerHTML = curr.name;
|
desc.innerHTML = name;
|
||||||
bdy.appendChild(desc);
|
bdy.appendChild(desc);
|
||||||
card.appendChild(img);
|
card.appendChild(img);
|
||||||
card.appendChild(bdy);
|
card.appendChild(bdy);
|
||||||
div.appendChild(card);
|
div.appendChild(card);
|
||||||
vmlist.children[0].appendChild(div);
|
vmlist.children[0].appendChild(div);
|
||||||
});
|
}
|
||||||
res();
|
res(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function chatMessage(username, msg) {
|
function chatMessage(username, msg) {
|
||||||
|
@ -351,6 +357,7 @@ function chatMessage(username, msg) {
|
||||||
async function openVM(url, node) {
|
async function openVM(url, node) {
|
||||||
if (connected) return;
|
if (connected) return;
|
||||||
connected = true;
|
connected = true;
|
||||||
|
window.location.href = "#" + node;
|
||||||
vm = new CollabVMClient(url);
|
vm = new CollabVMClient(url);
|
||||||
await vm.connect();
|
await vm.connect();
|
||||||
connected = true;
|
connected = true;
|
||||||
|
@ -399,8 +406,12 @@ buttons.takeTurn.addEventListener('click', () => vm.turn());
|
||||||
buttons.voteReset.addEventListener('click', () => vm.voteReset(true));
|
buttons.voteReset.addEventListener('click', () => vm.voteReset(true));
|
||||||
voteyesbtn.addEventListener('click', () => vm.voteReset(true));
|
voteyesbtn.addEventListener('click', () => vm.voteReset(true));
|
||||||
votenobtn.addEventListener('click', () => vm.voteReset(false));
|
votenobtn.addEventListener('click', () => vm.voteReset(false));
|
||||||
config.serverAddresses.forEach(multicollab);
|
(async () => {
|
||||||
|
for (var i = 0; i < config.serverAddresses.length; i++) {
|
||||||
|
var x = await multicollab(config.serverAddresses[i]);
|
||||||
|
if (x === false) break;
|
||||||
|
}
|
||||||
|
})();
|
||||||
// Export some stuff
|
// Export some stuff
|
||||||
window.screenshotVM = screenshotVM;
|
window.screenshotVM = screenshotVM;
|
||||||
window.multicollab = multicollab;
|
window.multicollab = multicollab;
|
Loading…
Reference in a new issue