aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkaotisk <kaotisk@arching-kaos.org>2024-11-12 07:44:56 +0200
committerkaotisk <kaotisk@arching-kaos.org>2024-11-12 07:44:56 +0200
commit130a30756962cc013e686e2671f92e97b88e7c1b (patch)
tree309cc7bd8a5ca6f205b2ffbd711f84b967e17546
parent073352cb2bec05be8898385b54d74122846886e0 (diff)
downloadarching-kaos-radio-130a30756962cc013e686e2671f92e97b88e7c1b.tar.gz
arching-kaos-radio-130a30756962cc013e686e2671f92e97b88e7c1b.tar.bz2
arching-kaos-radio-130a30756962cc013e686e2671f92e97b88e7c1b.zip
HTML migrated to Generator JSON format
-rw-r--r--client/index.html202
-rw-r--r--client/js/app.js50
-rw-r--r--client/js/arching-kaos-generator.js1
-rw-r--r--client/js/radio_emulator.js3
-rw-r--r--client/js/ui/footer.js16
-rw-r--r--client/js/ui/header.js23
-rw-r--r--client/js/ui/layout.js29
-rw-r--r--client/js/ui/main.js196
8 files changed, 317 insertions, 203 deletions
diff --git a/client/index.html b/client/index.html
index 426de56..c2b889e 100644
--- a/client/index.html
+++ b/client/index.html
@@ -7,209 +7,11 @@
<link rel="stylesheet preload" href="./css/styles.css" type="text/css" as="style"/>
</head>
<body>
- <div>
- <div class="header">
- <img class="logo" src="./img/logo.jpg"/>
- <div>
- <h1>Radio Station Emulator</h1>
- <em>by <a href="https://kaotisk-hund.com/" target="_blank">Kaotisk Hund</a>, for <a href="https://arching-kaos.org" target="_blank">Arching Kaos</a> and for everyone.</em>
- </div>
- </div>
- <div class="main">
- <div class="start-top">
- <div class="div-groups" style="flex-grow:1;">
- <div class="now-playing-details">
- <div class="div-groups-row">
- <img class="generated"/>
- <table>
- <tr>
- <th>Artist</th>
- <td class="artist"></td>
- </tr>
- <tr>
- <th>Title</th>
- <td class="title"></td>
- </tr>
- <tr>
- <th>Starts On (ms)</th>
- <td class="starts-on"></td>
- </tr>
- <tr>
- <th>Duration (s)</th>
- <td class="show-duration"></td>
- </tr>
- </table>
- </div>
- </div>
- <div class="enhanced-player">
- <div class="radio-player">
- <audio preload="auto" controls muted></audio>
- </div>
- <div class="div-row">
- <button onclick="start_radio()">Start!</button>
- <button onclick="sync_radio()">Sync!</button>
- </div>
- </div>
- </div>
- <div class="previously-played">
- </div>
- </div>
- <div class="more-details">
- <details>
- <summary>Progress details</summary>
- <div>
- <p>Download progress:</p>
- <progress class="dl-progress" max="100"></progress>
- </div>
- <div>
- <p>Live progress:</p>
- <progress class="play-progress"></progress>
- </div>
- <div class="div-inline">
- <div class="div-inline">
- <p>Listening at:</p>
- <p class="listening-at"></p>
- </div>
- <div class="div-inline">
- <p>Show playback: </p>
- <div class="no-break">
- <p class="relative-time"></p>
- <p>/</p>
- <p class="show-duration"></p>
- </div>
- </div>
- </div>
- </details>
- <details>
- <summary>Sync info</summary>
- <div class="groups">
- <table>
- <tr>
- <th>Time of visit (ms)</th>
- <td class="time-of-visit"></td>
- </tr>
- <tr>
- <th>Time elapsed since visited (s)</th>
- <td class="you-are-here"></td>
- </tr>
- <tr>
- <th>List started on (ms)</th>
- <td class="started-on"></td>
- </tr>
- <tr>
- <th>List duration (s)</th>
- <td class="list-duration"></td>
- </tr>
- </table>
- <h3>Calculations</h3>
- <table>
- <tr>
- <th>Times Fully Played</th>
- <td class="min-played"></td>
- </tr>
- <tr>
- <th>Times Played</th>
- <td class="max-played"></td>
- </tr>
- <tr>
- <th>Dt = TP - TFP</th>
- <td class="d-t"></td>
- </tr>
- <tr>
- <th>Delta time</th>
- <td class="delta-time"></td>
- </tr>
- <tr>
- <th>Initial "tune in" time (s)</th>
- <td class="current-time"></td>
- </tr>
- </table>
- </div>
- </details>
- <details >
- <summary>Info to get you started</summary>
- <h2>Notice</h2>
- <p>
- If you are visiting for the first time, you might need to
- "Allow Audio" first. Please do and refresh the page.
- </p>
- <h2>About</h2>
- <p>
- This is a "Radio Station Emulator". We create lists with
- shows to be played, but since we are not doing streaming of
- the playlists, we offer another way of "tuning in".
- </p>
- <p>
- Providing the time a list started playing and having
- pre-calculated the starting timestamps of each show relevant
- to the list start timestamp, we can calculate which show is
- on and what its current time of playing is.
- </p>
- <p>
- Ultimately, you are hearing what we would be streaming, as
- you would do for a regular radio station.
- </p>
- <h2>Steps</h2>
- <ol>
- <li>
- First, your browser is going to ask our server here,
- what is the current list that plays right now. It will
- get a response and will fetch that list.
- </li>
- <li>
- Based on properties of the list overall and the time of
- visit, your browser will start comparing each show's
- properties found in the list, to figure the relative
- time of yours on the list. A progress bar labeled "Live
- progress" will be indicating the correct time on the
- show.
- </li>
- <li>
- Having figured out the show that is playing, it will go
- and download the whole show. Progress of that would be
- observable via the "Download progress" bar below.
- </li>
- <li>
- Upon completion of the download, the "Sync" button is
- auto pressed and the player start playing the show from
- the calculated second it calculated previously.
- </li>
- </ol>
- <h2>Notes</h2>
- <ul>
- <li>
- Sometimes, you might need to press the "Sync" button
- more than once. That's mostly due to bandwidth
- capabilities of both the server and the client. The
- "tune" would be right if you press it multiple times and
- land near the same timespace over and over.
- </li>
- <li>
- Ideally, if "Listening at:" and "Show playback:" have
- the same value then you are in sync!
- </li>
- </ul>
- </details>
- <details>
- <summary>Data segments</summary>
- <h3>Hash of list</h3>
- <pre class="list-hash"></pre>
- <h3>List info (JSON)</h3>
- <pre class="list-info"></pre>
- <h3>Hash of current show</h3>
- <pre class="current-show-hash"></pre>
- <h3>Show info (JSON)</h3>
- <pre class="show-info"></pre>
- <div>
- <a href="./data.html" target="_blank">Data</a>
- </div>
- </details>
- </div>
- </div>
+ <div id="page-layout">
</div>
<script src="./js/arching-kaos-generator.js"></script>
<script src="./js/image_generator.js"></script>
- <script src="./js/app.js"></script>
<script src="./js/radio_emulator.js"></script>
+ <script src="./js/app.js"></script>
</body>
</html>
diff --git a/client/js/app.js b/client/js/app.js
index 8b13789..4f69265 100644
--- a/client/js/app.js
+++ b/client/js/app.js
@@ -1 +1,51 @@
+/* Arching Kaos Radio Station with Generator
+ *
+ * Kaotisk Hund - 2024
+ *
+ * @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
+ *
+ */
+var root = {
+ head: document.querySelector('head'),
+ body: document.querySelector('body'),
+ html: document.querySelector('html')
+};
+var html = [
+ {
+ element:"head",
+ innerHTML:[
+ {
+ element:"title",
+ innerText:"Arching Kaos Radio"
+ },
+ {
+ element:"meta",
+ name:"viewport",
+ content:"width=device-width, initial-scale=1"
+ },
+ {
+ element:"link",
+ rel:"stylesheet",
+ type:"text/css",
+ href:"./css/styles.css"
+ }
+ ]
+ },
+];
+
+makeUpSite(html, root.html);
+
+var scripts = [
+ {
+ element:"script",
+ src:"./js/ui/layout.js"
+ }
+];
+
+for ( var i = 0; i < scripts.length; i++ )
+{
+ makeElement(scripts[i], root.body);
+}
+
+// @license-end
diff --git a/client/js/arching-kaos-generator.js b/client/js/arching-kaos-generator.js
index 67ab351..a93199d 100644
--- a/client/js/arching-kaos-generator.js
+++ b/client/js/arching-kaos-generator.js
@@ -59,5 +59,4 @@ function makeUpSite(tree, root){
}
}
-
// @license-end
diff --git a/client/js/radio_emulator.js b/client/js/radio_emulator.js
index 13d874e..37bb163 100644
--- a/client/js/radio_emulator.js
+++ b/client/js/radio_emulator.js
@@ -39,9 +39,8 @@ const audioRequest = `${apiURL}${version}/audio/ogg/`
const documentTitle = "Radio Station Emulator";
const separator = " :: ";
-var audioElement = document.querySelector('audio');
-var placeholders = {
+placeholders = {
currentTime: document.querySelector('.current-time'),
listStarted: document.querySelector('.started-on'),
currentShowHash : document.querySelector('.current-show-hash'),
diff --git a/client/js/ui/footer.js b/client/js/ui/footer.js
new file mode 100644
index 0000000..9f6cb26
--- /dev/null
+++ b/client/js/ui/footer.js
@@ -0,0 +1,16 @@
+// Arching Kaos RSE ui/footer.js
+//
+// Kaotisk Hund - 2024
+//
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
+//
+var pageLayout = document.querySelector('#page-layout');
+
+var footer = {
+ element:"div",
+ className:"footer"
+};
+
+makeElement(footer, pageLayout);
+
+// @license-end
diff --git a/client/js/ui/header.js b/client/js/ui/header.js
new file mode 100644
index 0000000..fb0511c
--- /dev/null
+++ b/client/js/ui/header.js
@@ -0,0 +1,23 @@
+// Arching Kaos RSE ui/header.js
+//
+// Kaotisk Hund - 2024
+//
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
+//
+var pageLayout = document.querySelector('#page-layout');
+
+var header = {
+ element:"div",
+ className:"header",
+ innerHTML:[
+ {element:"img", className:"logo", src:"img/logo.jpg"},
+ {element:"div", innerHTML:[
+ {element:"h1", innerText:"Arching Kaos Radio"},
+ {element:"em", innerHTML:"by <a href=\"https://kaotisk-hund.com/\" target=\"_blank\">Kaotisk Hund</a>, for <a href=\"https://arching-kaos.org\" target=\"_blank\">Arching Kaos</a> and for everyone."}
+ ]}
+ ]
+};
+
+makeElement(header, pageLayout);
+
+// @license-end
diff --git a/client/js/ui/layout.js b/client/js/ui/layout.js
new file mode 100644
index 0000000..7cfffa0
--- /dev/null
+++ b/client/js/ui/layout.js
@@ -0,0 +1,29 @@
+// Arching Kaos RSE ui/layout.js
+//
+// Kaotisk Hund - 2024
+//
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
+//
+var body= document.querySelector('body');
+
+var scripts = [
+ {
+ element:"script",
+ src:"./js/ui/header.js"
+ },
+ {
+ element:"script",
+ src:"./js/ui/main.js"
+ },
+ {
+ element:"script",
+ src:"./js/ui/footer.js"
+ }
+];
+
+for ( var i = 0; i < scripts.length; i++ )
+{
+ makeElement(scripts[i], body);
+}
+
+// @license-end
diff --git a/client/js/ui/main.js b/client/js/ui/main.js
new file mode 100644
index 0000000..9a322e6
--- /dev/null
+++ b/client/js/ui/main.js
@@ -0,0 +1,196 @@
+// Arching Kaos RSE ui/main.js
+//
+// Kaotisk Hund - 2024
+//
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL v3.0
+//
+
+var pageLayout = document.querySelector('#page-layout');
+
+var main = {
+ element:"div",
+ className:"main",
+ innerHTML:[
+ {element:"div",className:"start-top",innerHTML:[
+ {element:"div",className:"div-groups",style:"flex-grow:1;",innerHTML:[
+ {element:"div",className:"now-playing-details",innerHTML:[
+ {element:"div",className:"div-groups-row",innerHTML:[
+ {element:"img", className:"generated"},
+ {element:"table", innerHTML:[
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Artist"},
+ {element:"td", className:"artist"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Title"},
+ {element:"td", className:"title"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Starts On (ms)"},
+ {element:"td", className:"starts-on"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Artist"},
+ {element:"td",className:"show-duration"}
+ ]}
+ ]}
+ ]}
+ ]},
+ {element:"div", className:"enhanced-player",innerHTML:[
+ {element:"div", className:"radio-player",innerHTML:[
+ {element:"audio", preload:"auto", controls:true, muted:true}
+ ]},
+ {element:"div", className:"div-row",innerHTML:[
+ {element:"button", id:"start-button",innerText:"Start!"},
+ {element:"button", id:"sync-button",innerText:"Sync"}
+ ]}
+ ]}
+ ]},
+ {element:"div",className:"previously-played"},
+ ]},
+ {element:"div", className:"more-details", innerHTML:[
+ {element:"details",id:"progress-details", innerHTML:[
+ {element:"summary", innerText:"Progress details"},
+ {element:"div",innerHTML:[
+ {element:"p", innerText:"Download progress:"},
+ {element:"progress",className:"dl-progress", max:"100"}
+ ]},
+ {element:"div",innerHTML:[
+ {element:"p", innerText:"Live progress:"},
+ {element:"progress",className:"play-progress"}
+ ]},
+ {element:"div", className:"div-inline",innerHTML:[
+ {element:"div", className:"div-inline",innerHTML:[
+ {element:"p", innerText:"Listening at:"},
+ {element:"p", className:"listening-at"},
+ ]},
+ {element:"div", className:"div-inline",innerHTML:[
+ {element:"p", innerText:"Show playback:"},
+ {element:"div", className:"no-break",innerHTML:[
+ {element:"p", className:"relative-time"},
+ {element:"p", innerText:"/"},
+ {element:"p", className:"show-duration"}
+ ]}
+ ]}
+ ]}
+ ]},
+ {element:"details",id:"sync-info", innerHTML:[
+ {element:"summary", innerText:"Progress details"},
+ {element:"div",className:"groups",innerHTML:[
+ {element:"h3", innerText:"Timings"},
+ {element:"table", innerHTML:[
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Time of visit (ms)"},
+ {element:"td", className:"time-of-visit"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Time elapsed since visited (s)"},
+ {element:"td", className:"you-are-here"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"List started on (ms)"},
+ {element:"td", className:"started-on"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"List duration (s)"},
+ {element:"td",className:"list-duration"}
+ ]}
+ ]},
+ {element:"h3", innerText:"Calculations"},
+ {element:"table", innerHTML:[
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Times Fully Played"},
+ {element:"td", className:"min-played"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Times Played"},
+ {element:"td", className:"max-played"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Dt = TP - TFP"},
+ {element:"td", className:"d-t"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Delta time"},
+ {element:"td",className:"delta-time"}
+ ]},
+ {element:"tr",innerHTML:[
+ {element:"th", innerText:"Initial \"tune in\" time (s)"},
+ {element:"td",className:"current-time"}
+ ]}
+
+ ]},
+ ]}
+ ]},
+ {element:"details",id:"about", innerHTML:[
+ {element:"summary",innerText:"Info to get you started"},
+ {element:"h2",innerText:"Notice"},
+ {element:"p",innerText:"If you are visiting for the first time, you might need to \"Allow Audio\" first. Please do and refresh the page."},
+ {element:"h2",innerText:"About"},
+ {element:"p",innerText:"This is a \"Radio Station Emulator\". We create lists with shows to be played, but since we are not doing streaming of the playlists, we offer another way of \"tuning in\"."},
+ {element:"p",innerText:"Providing the time a list started playing and having pre-calculated the starting timestamps of each show relevant to the list start timestamp, we can calculate which show is on and what its current time of playing is."},
+ {element:"p",innerText:"Ultimately, you are hearing what we would be streaming, as you would do for a regular radio station."},
+ {element:"h2",innerText:"Steps"},
+ {element:"ol",innerHTML:[
+ {element:"li",innerText:"First, your browser is going to ask our server here, what is the current list that plays right now. It will get a response and will fetch that list."},
+ {element:"li",innerText:"Based on properties of the list overall and the time of visit, your browser will start comparing each show's properties found in the list, to figure the relative time of yours on the list. A progress bar labeled \"Live progress\" will be indicating the correct time on the show."},
+ {element:"li",innerText:"Having figured out the show that is playing, it will go and download the whole show. Progress of that would be observable via the \"Download progress\" bar below."},
+ {element:"li",innerText:"Upon completion of the download, the \"Sync\" button is auto pressed and the player start playing the show from the calculated second it calculated previously."},
+ ]},
+ {element:"h2",innerText:"Notes"},
+ {element:"ul",innerHTML:[
+ {element:"li",innerText:"Sometimes, you might need to press the \"Sync\" button more than once. That's mostly due to bandwidth capabilities of both the server and the client. The \"tune\" would be right if you press it multiple times and land near the same timespace over and over."},
+ {element:"li",innerText:"Ideally, if \"Listening at:\" and \"Show playback:\" havea the same value then you are in sync!"}
+ ]}
+ ]},
+ {element:"details",id:"data", innerHTML:[
+ {element:"summary", innerText:"Data segments"},
+ {element:"h3",innerText:"Hash of list"},
+ {element:"pre", className:"list-hash"},
+ {element:"h3",innerText:"List info (JSON)"},
+ {element:"pre", className:"list-info"},
+ {element:"h3",innerText:"Hash of current show"},
+ {element:"pre", className:"current-show-hash"},
+ {element:"h3",innerText:"Show info (JSON)"},
+ {element:"pre", className:"show-info"},
+ {element:"div", innerHTML:[
+ {element:"a", href:"./data.html", target:"_blank",innerText:"Data"}
+ ]}
+ ]}
+ ]}
+ ]
+};
+
+makeElement(main, pageLayout);
+
+var audioElement = document.querySelector('audio');
+var placeholders = {
+ currentTime: document.querySelector('.current-time'),
+ listStarted: document.querySelector('.started-on'),
+ currentShowHash : document.querySelector('.current-show-hash'),
+ listHash : document.querySelector('.list-hash'),
+ artist: document.querySelector('.artist'),
+ title: document.querySelector('.title'),
+ radioPlayer: document.querySelector('.radio-player'),
+ youAreHere : document.querySelector('.you-are-here'),
+ playProgress: document.querySelector('.play-progress'),
+ startsOn: document.querySelector('.starts-on'),
+ showDuration: document.querySelectorAll('.show-duration'),
+ relativeTime: document.querySelector('.relative-time'),
+ listeningAt: document.querySelector('.listening-at'),
+ dlProgress: document.querySelector('.dl-progress'),
+ minTimesPlayed: document.querySelector('.min-played'),
+ maxTimesPlayed: document.querySelector('.max-played'),
+ listDuration: document.querySelector('.list-duration'),
+ previouslyPlayed: document.querySelector('.previously-played'),
+ showInfo: document.querySelector('.show-info'),
+ listInfo: document.querySelector('.list-info'),
+ dt: document.querySelector('.d-t'),
+ deltaTime: document.querySelector('.delta-time'),
+ timeOfVisit: document.querySelector('.time-of-visit')
+}
+
+document.querySelector("#start-button").addEventListener("click",()=>{start_radio();});
+document.querySelector("#sync-button").addEventListener("click",()=>{sync_radio();});
+
+// @license-end