still-alive/assets/js/script.mjs
Victor Westerlund 7a6ed67d92 Fix Monkeydo events and #3
Monkeydo events will now be executed through the Proxy created in 8b659066cc

This commit also implements a solution for #3 by having each window report to its PlayerManager when it has been closed.
2021-12-05 22:09:56 +01:00

25 lines
No EOL
669 B
JavaScript
Executable file

import { default as Player } from "./modules/PlayerManager.mjs";
const play = document.getElementById("play");
function info(text = "") {
const element = document.getElementById("message");
element.innerText = text;
}
if(typeof BroadcastChannel !== "function") {
play.classList.add("unsupported");
info("Your browser can not play this demo");
}
play.addEventListener("click",() => {
try {
info();
new Player();
}
catch(except) {
if(except.message === "WINDOW_OPEN_FAILED") return info("Yikes! Player windows could not be created. Allow this page to open pop-ups, it will be worth it!");
// Cannot handle this exception, rethrow
throw except;
}
});