</head>
<body>
-<article id="mainView" style="display: none">
+<article id="mainView" style="display: flex">
<section>
<table style="width: 100%"><tbody>
<tr>
<section>
<div class="row">
-<!--
- <input type="button" value="Play" onclick="javscript:Client.play_pause()" id="playBtn"/>
- <input type="button" value="Chan +" onclick="javscript:Client.chan_next()"/>
- <input type="button" value="Chan -" onclick="javscript:Client.chan_prev()"/>
- <input type="button" value="Enqueue" onclick="javscript:Client.enqueue()"/>
--->
- <input type="button" value="Play" onclick="javscript:UI.play_pause()" id="playBtn"/>
- <input type="button" value="Chan +" onclick="javscript:UI.chan_next()"/>
- <input type="button" value="Chan -" onclick="javscript:UI.chan_prev()"/>
- <input type="button" value="Enqueue" onclick="javscript:UI.select_file()"/>
-
+ <input type="button" value="Play" onclick="javascript:UI.play_pause()" id="playBtn"/>
+ <input type="button" value="Chan +" onclick="javascript:UI.chan_next()"/>
+ <input type="button" value="Chan -" onclick="javascript:UI.chan_prev()"/>
+ <input type="button" value="Enqueue" onclick="javascript:UI.select_file()"/>
</div>
</section>
<section class="grow">
<div style="width: 100%; text-align: center"><h2>Queued Videos</h2></div>
- <div id="queue" style="width: 100%; text-align: center;">The queue is currently empty</div>
+ <div id="queueList" style="width: 100%; text-align: center;">The queue is currently empty</div>
</section>
</article>
-<article id="browseView" style="display: flex">
+<article id="browseView" style="display: none">
<section>
<h1 style="text-align: center">Browse Media</h1>
<hr/>
<section>
<hr/>
- <div class="row"><input type="button" value="Cancel" onclick=""/></div>
+ <div class="row"><input type="button" value="Cancel" onclick="javascript:UI.cancel()"/></div>
</section>
</article>
showMain();
};
-
self.set_items = (new_items)=>{
items = new_items;
refreshItems();
playBtn.value = (playing ? "Pause" : "Play");
};
+
+
+
+ const refreshQueue = ()=>{
+ if (queue.length > 0) {
+ queueList.innerHTML = "";
+ for (const item of queue) {
+ const el = document.createElement("div");
+ el.innerText = item.path;
+ queueList.appendChild(el);
+ }
+ } else {
+ queueList.innerHTML = "The queue is currently empty";
+ }
+ };
+
+ const getLocalRoot = ()=>{
+ let root = items;
+ for (const dir of path) {
+ root = root[dir];
+ }
+ return root;
+ };
+
+ const linkDown = (dir)=>{
+ path.push(dir);
+ refreshItems();
+ };
+
+ const linkUp = ()=>{
+ path.slice(-1);
+ refreshItems();
+ };
+
+ const refreshItems = ()=>{
+ const dir = getLocalRoot();
+ itemList.innerText = "";
+ for (const item in dir) {
+ const el = document.createElement("div");
+ const link = document.createElement("a");
+ link.innerText = item;
+ link.href = '#';
+ if ('path' in dir[item]) {
+ link.onclick = ()=>{ self.enqueue(dir[item].path); };
+ } else {
+ link.onclick = ()=>{ linkDown(item); };
+ }
+ el.appendChild(link);
+ itemList.appendChild(el);
+ }
+ };
+
return self;
})();
console.log(data);
if (cmd.cmd === "items")
{
-// items = data["items"];
-// showItems();
UI.set_items( data.items );
}
else if (cmd.cmd === "queue")
{
-// showQueue(data.queue);
UI.set_queue(data.queue);
}
else
data["next"]["path"], // Up next
data.playing // Playing or paused
);
-
-// currVid.innerText = data["curr"]["path"]
-// nextVid.innerText = data["next"]["path"]
-// playBtn.value = (data["playing"] ? "Pause" : "Play");
}
});
-// Client.enqueue = (path)=>{
-// console.log(path)
-// Client.send("enqueue", { path: path });
-// path = [];
-// browseView.style.display = "none";
-// mainView.style.display = "flex";
-//// showItems();
-//// console.log("enqueue");
-//// Client.send("enqueue", { path: items[0]["path"] });
-// };
-//
-// const showQueueElement = (item) => {
-// const el = document.createElement("div");
-// el.innerText = item.path;
-// queue.appendChild(el);
-// }
-//
-// const showQueue = (data)=>{
-// if (data.length > 0) {
-// queue.innerHTML = "";
-// for (const item of data) {
-// showQueueElement(item);
-// }
-// } else {
-// queue.innerHTML = "The queue is currently empty";
-// }
-// };
-//
+
+
+
// const getLocalRoot = ()=>{
// let root = items;
// for (const dir of path) {
// for (const item in dir) {
// showItem(item, ('path' in dir[item]), dir[item]);
// }
- };
+// };
})();