dev21w41a

This commit is contained in:
Victor Westerlund 2021-10-12 15:46:49 +02:00
parent 79d3841af4
commit c0faa59ca8
5 changed files with 149 additions and 0 deletions

60
assets/css/style.css Executable file
View file

@ -0,0 +1,60 @@
:root {
--color-background: 0,0,0;
--color-contrast: 255,255,255;
}
html,
body {
margin: 0;
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
background-color: rgb(var(--color-background));
color: rgba(var(--color-contrast));
font-family: "Courier New", Courier, monospace;
}
a {
text-decoration: none;
color: inherit;
}
#play {
display: inline-block;
background-color: rgb(var(--color-contrast));
color: rgba(var(--color-background));
padding: 20px;
font-size: 18px;
}
footer {
position: fixed;
box-sizing: border-box;
padding: 0 20px;
left: 0;
bottom: 0;
}
@media (pointer: fine) {
#play:not(.unsupported) {
cursor: pointer;
}
}
@media (hover: hover) {
#play:not(.unsupported) {
transition: 100ms background-color,100ms color;
cursor: pointer;
}
#play:not(.unsupported):hover {
background-color: rgba(var(--color-contrast),.15);
color: rgb(var(--color-contrast));
}
a:hover {
text-decoration: underline;
}
}

View file

@ -0,0 +1,40 @@
import { default as Monkeydo } from "./monkeydo/Monkeydo.mjs";
export default class WindowManager {
constructor() {
const self = this;
this.channels = {
lyrics: new BroadcastChannel("lyrics"),
credits: new BroadcastChannel("credits"),
art: new BroadcastChannel("art")
};
const methods = {
self: self,
pushText: (target,text) => {
const channels = self.channels[target];
for(const channel of channels) {
channel.postMessage(["PUSH_TEXT",text]);
}
}
}
this.player = new Monkeydo(methods);
}
spawnPlayer(type) {
if(!type in this.channels) {
throw new Error(`Inavlid player type "${type}"`);
}
// TODO
//const player = new PlayerWindow(type);
}
play() {
this.spawnPlayer("lyrics");
this.spawnPlayer("credits");
this.spawnPlayer("art");
}
}

16
assets/js/script.mjs Executable file
View file

@ -0,0 +1,16 @@
import { default as Player } from "./modules/WindowManager.mjs";
const play = document.getElementById("play");
const message = document.getElementById("message");
try {
if(typeof BroadcastChannel !== "function") {
throw new Error("BroadcastChannel API is not supported");
}
const player = new Player();
play.addEventListener("click",() => player.play());
} catch(error) {
play.classList.add("unsupported");
play.innerText = "Your browser can not play this demo";
message.innerText = error;
}

20
index.html Executable file
View file

@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Still Alive</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
<main>
<p id="play">Still Alive</p>
<p id="message"></p>
</main>
<footer>
<a href="https://github.com/VictorWesterlund/still-alive">Source on GitHub</p>
</footer>
<script type="module" src="assets/js/script.mjs"></script>
</body>
</html>

13
player.html Executable file
View file

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>&ZeroWidthSpace;</title>
<link rel="stylesheet" href="assets/css/style.css">
</head>
<body>
</body>
</html>