Selaa lähdekoodia

demo website uses shows

boyska 2 vuotta sitten
vanhempi
commit
d3fed0c424
2 muutettua tiedostoa jossa 26 lisäystä ja 0 poistoa
  1. 9 0
      index.html
  2. 17 0
      ui.js

+ 9 - 0
index.html

@@ -1,6 +1,9 @@
 <!doctype html>
 <html>
     <head>
+<style>
+#show-info {border: 1px solid gray; max-width: 20em; padding: 0.3em; font-family: monospace;}
+</style>
     </head>
     <body>
         Ciao
@@ -11,5 +14,11 @@
 	<audio controls>
 	</audio>
 	</div>
+    <div id="show-info">
+    </div>
+    <div id="shows">
+        <ul>
+        </ul>
+    </div>
     </body>
 </html>

+ 17 - 0
ui.js

@@ -17,6 +17,23 @@ async function fai () {
     console.log('src', srcEl, url)
     audioEl.appendChild(srcEl)
   })
+
+  const showList = document.querySelector('#shows > ul')
+  for (const show of radio.getShows()) {
+    const item = document.createElement('li')
+    const link = document.createElement('a')
+    link.dataset['show'] = show.getName()
+    link.textContent = show.getName()
+    link.setAttribute('href', show.getWebsite())
+    item.appendChild(link)
+    showList.appendChild(item)
+  }
+  showList.addEventListener('mouseenter', function (evt) {
+    if (evt.target.dataset['show'] === undefined)
+      return;
+    const info = document.querySelector('#show-info')
+    info.textContent = radio.getShowByName(evt.target.dataset['show']).getFeed()
+  }, true)
 }
 
 fai()