still-alive/assets/js/player.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

17 lines
No EOL
608 B
JavaScript

import { default as Player } from "./modules/StillAlivePlayer.mjs";
if(typeof BroadcastChannel !== "function" || !window.location.hash) {
close();
const page = window.location.pathname.split("/");
const url = window.location.href.replace(page[page.length - 1],"");
window.location.replace(url);
};
const name = window.location.hash.substring(1);
document.body.className = name;
const target = document.getElementById("player");
const player = new Player(target,name);
// Notify PlayerManager that I was closed
window.addEventListener("beforeunload",() => player.channel.postMessage("PLAYER_CLOSED"));