</article>
<script type="text/javascript" src="client.js"></script>
+<script type="text/javascript" src="ui.js"></script>
<script>
-const UI = (()=>{
- const self = {};
-
- let queue = [];
- let items = {};
- let path = [];
-
- const showBrowser = ()=>{
- path = [];
- browseView.style.display = "flex";
- mainView.style.display = "none";
- };
-
- const showMain = ()=>{
- path = [];
- browseView.style.display = "none";
- mainView.style.display = "flex";
- };
-
- // Button handlers
- self.play_pause = ()=>{ Client.play_pause(); };
- self.chan_next = ()=>{ Client.chan_next(); };
- self.chan_prev = ()=>{ Client.chan_prev(); };
- self.skip = ()=>{ Client.skip(); };
- self.select_file = ()=>{ showBrowser(); };
- self.cancel = ()=>{ showMain(); };
-
- self.enqueue = (path)=>{
- console.log(path);
- Client.send("enqueue", { path: path });
- showMain();
- };
-
- self.set_items = (new_items)=>{
- items = new_items;
- refreshItems();
- };
-
- self.set_queue = (new_queue)=>{
- queue = new_queue;
- refreshQueue();
- };
-
- self.set_play_state = (up_now, up_next, playing)=>{
- currVid.innerText = up_now;
- nextVid.innerText = up_next;
- playBtn.value = (playing ? "Pause" : "Play");
- };
-
- self.browse_up = ()=>{
- path.pop();
- refreshItems();
- };
-
-
-
- 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 refreshItems = ()=>{
- const dir = getLocalRoot();
- currDir.innerText = (path[path.length - 1] || "Root");
-
- 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;
-})();
-
-
(()=>{
- let items = {}
- let path = [];
-
Client.connect((data)=>{
console.log(data);
if (cmd.cmd === "items")
);
}
});
-
-
-
-
-// const getLocalRoot = ()=>{
-// let root = items;
-// for (const dir of path) {
-// root = root[dir];
-// }
-// return root;
-// };
-//
-// const linkDown = (dir)=>{
-// path.push(dir);
-// showItems();
-// };
-//
-// const linkUp = ()=>{
-// path.slice(-1);
-// showItems();
-// };
-//
-// const showItem = (item, isFile, fileData) => {
-// const el = document.createElement("div");
-// const link = document.createElement("a");
-// link.innerText = item;
-// link.href = '#';
-// if (!isFile) {
-// link.onclick = ()=>{ linkDown(item); };
-// } else {
-// link.onclick = ()=>{ Client.enqueue(fileData.path); };
-// }
-// el.appendChild(link);
-// itemList.appendChild(el);
-// }
-//
-// const showItems = ()=>{
-// const dir = getLocalRoot();
-// itemList.innerText = "";
-// for (const item in dir) {
-// showItem(item, ('path' in dir[item]), dir[item]);
-// }
-// };
-
})();
</article>
<script type="text/javascript" src="client.js"></script>
+<script type="text/javascript" src="ui.js"></script>
<script>
-const UI = (()=>{
- const self = {};
-
- let queue = [];
- let items = {};
- let path = [];
-
- const showBrowser = ()=>{
- path = [];
- browseView.style.display = "flex";
- mainView.style.display = "none";
- };
-
- const showMain = ()=>{
- path = [];
- browseView.style.display = "none";
- mainView.style.display = "flex";
- };
-
- // Button handlers
- self.play_pause = ()=>{ Client.play_pause(); };
- self.chan_next = ()=>{ Client.chan_next(); };
- self.chan_prev = ()=>{ Client.chan_prev(); };
- self.select_file = ()=>{ showBrowser(); };
- self.cancel = ()=>{ showMain(); };
-
- self.enqueue = (path)=>{
- console.log(path);
- Client.send("enqueue", { path: path });
- showMain();
- };
-
- self.set_items = (new_items)=>{
- items = new_items;
- refreshItems();
- };
-
- self.set_queue = (new_queue)=>{
- queue = new_queue;
- refreshQueue();
- };
-
- self.set_play_state = (up_now, up_next, playing)=>{
- currVid.innerText = up_now;
- nextVid.innerText = up_next;
- };
-
- self.browse_up = ()=>{
- path.pop();
- refreshItems();
- };
-
- 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 refreshItems = ()=>{
- const dir = getLocalRoot();
- currDir.innerText = (path[path.length - 1] || "Root");
-
- itemList.innerText = "";
- for (const item in dir) {
- const el = document.createElement("div");
- el.innerText = item;
- if ('path' in dir[item]) {
- el.onclick = ()=>{ self.enqueue(dir[item].path); };
- } else {
- el.onclick = ()=>{ linkDown(item); };
- }
- itemList.appendChild(el);
-
-
-
-// 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;
-})();
-
-
(()=>{
- let items = {}
- let path = [];
-
Client.connect((data)=>{
console.log(data);
if (cmd.cmd === "items")
);
}
});
-
-
-
-
-// const getLocalRoot = ()=>{
-// let root = items;
-// for (const dir of path) {
-// root = root[dir];
-// }
-// return root;
-// };
-//
-// const linkDown = (dir)=>{
-// path.push(dir);
-// showItems();
-// };
-//
-// const linkUp = ()=>{
-// path.slice(-1);
-// showItems();
-// };
-//
-// const showItem = (item, isFile, fileData) => {
-// const el = document.createElement("div");
-// const link = document.createElement("a");
-// link.innerText = item;
-// link.href = '#';
-// if (!isFile) {
-// link.onclick = ()=>{ linkDown(item); };
-// } else {
-// link.onclick = ()=>{ Client.enqueue(fileData.path); };
-// }
-// el.appendChild(link);
-// itemList.appendChild(el);
-// }
-//
-// const showItems = ()=>{
-// const dir = getLocalRoot();
-// itemList.innerText = "";
-// for (const item in dir) {
-// showItem(item, ('path' in dir[item]), dir[item]);
-// }
-// };
-
})();
-
-
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
+ <link rel="stylesheet" href="style.css">
<style>
html, body {
- margin: 0;
- padding: 0;
- width: 100%;
- height: 100%;
- max-height: 100%;
background-color: #000;
- overflow: hidden;
- }
-
- .badge {
- position: absolute;
- bottom: 1em;
- color: white;
- font-family: sans-serif;
- background-color: black;
- }
-
- .badge span {
- display: block;
- width: 100%;
- text-align: center;
- }
-
- .channelBadge {
- position: absolute;
- top: 0em;
- color: white;
- font-family: sans-serif;
- font-size: 3em;
- background-color: black;
- width: 100%;
- text-align: center;
}
</style>
</head>
ws.onmessage = (event)=>{
const msg = JSON.parse(event.data);
+ if (msg["cmd"] != "queue")
{
console.log(msg);
const prev = current;
overflow: hidden;
}
+ .badge {
+ position: absolute;
+ bottom: 1em;
+ color: white;
+ font-family: sans-serif;
+ background-color: black;
+ }
+
+ .badge span {
+ display: block;
+ width: 100%;
+ text-align: center;
+ }
+
+ .channelBadge {
+ position: absolute;
+ top: 0em;
+ color: white;
+ font-family: sans-serif;
+ font-size: 3em;
+ background-color: black;
+ width: 100%;
+ text-align: center;
+ }
+
.table {
display: block;
}
--- /dev/null
+const UI = (()=>{
+ const self = {};
+
+ let queue = [];
+ let items = {};
+ let path = [];
+
+ const showBrowser = ()=>{
+ path = [];
+ browseView.style.display = "flex";
+ mainView.style.display = "none";
+ };
+
+ const showMain = ()=>{
+ path = [];
+ browseView.style.display = "none";
+ mainView.style.display = "flex";
+ };
+
+ // Button handlers
+ self.play_pause = ()=>{ Client.play_pause(); };
+ self.chan_next = ()=>{ Client.chan_next(); };
+ self.chan_prev = ()=>{ Client.chan_prev(); };
+ self.skip = ()=>{ Client.skip(); };
+ self.select_file = ()=>{ showBrowser(); };
+ self.cancel = ()=>{ showMain(); };
+
+ self.enqueue = (path)=>{
+ console.log(path);
+ Client.send("enqueue", { path: path });
+ showMain();
+ };
+
+ self.set_items = (new_items)=>{
+ items = new_items;
+ refreshItems();
+ };
+
+ self.set_queue = (new_queue)=>{
+ queue = new_queue;
+ refreshQueue();
+ };
+
+ self.set_play_state = (up_now, up_next, playing)=>{
+ currVid.innerText = up_now;
+ nextVid.innerText = up_next;
+ if (document.getElementById("playBtn")) {
+ playBtn.value = (playing ? "Pause" : "Play");
+ }
+ };
+
+ self.browse_up = ()=>{
+ path.pop();
+ refreshItems();
+ };
+
+ 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 refreshItems = ()=>{
+ const dir = getLocalRoot();
+ currDir.innerText = (path[path.length - 1] || "Root");
+
+ itemList.innerText = "";
+ for (const item in dir) {
+ const el = document.createElement("div");
+ el.innerText = item;
+ if ('path' in dir[item]) {
+ el.onclick = ()=>{ self.enqueue(dir[item].path); };
+ } else {
+ el.onclick = ()=>{ linkDown(item); };
+ }
+ itemList.appendChild(el);
+ }
+ };
+
+ return self;
+})();
CONFIG = JSON.parse(File.read(CONFIG_PATH))
else
CONFIG = DEFAULT_CONFIG
+ File.open(CONFIG_PATH, "wb") {|f| f.write JSON.dump(CONFIG) }
end
# Update website files first
@path = "#{root}/index.json"
@data = {}
@dirs = scan_dirs
+ pp scan_dirs
load()
end