mirror of
https://codeberg.org/vlw/still-alive.git
synced 2025-09-14 08:23:41 +02:00
dev21w41a
This commit is contained in:
parent
79d3841af4
commit
c0faa59ca8
5 changed files with 149 additions and 0 deletions
60
assets/css/style.css
Executable file
60
assets/css/style.css
Executable 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;
|
||||||
|
}
|
||||||
|
}
|
40
assets/js/modules/WindowManager.mjs
Executable file
40
assets/js/modules/WindowManager.mjs
Executable 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
16
assets/js/script.mjs
Executable 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
20
index.html
Executable 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
13
player.html
Executable 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>​</title>
|
||||||
|
<link rel="stylesheet" href="assets/css/style.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Reference in a new issue