From 130a30756962cc013e686e2671f92e97b88e7c1b Mon Sep 17 00:00:00 2001 From: kaotisk Date: Tue, 12 Nov 2024 07:44:56 +0200 Subject: HTML migrated to Generator JSON format --- client/js/ui/footer.js | 16 ++++ client/js/ui/header.js | 23 ++++++ client/js/ui/layout.js | 29 ++++++++ client/js/ui/main.js | 196 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 264 insertions(+) create mode 100644 client/js/ui/footer.js create mode 100644 client/js/ui/header.js create mode 100644 client/js/ui/layout.js create mode 100644 client/js/ui/main.js (limited to 'client/js/ui') 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 Kaotisk Hund, for Arching Kaos 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 -- cgit v1.2.3