From 08973c019146710c94b854c79df58eb0836f75d2 Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Wed, 30 Jul 2025 15:59:59 -0500 Subject: WEB - added web front end page --- web/ytlist/ytlist.css | 35 +++++++++++++++++++++++ web/ytlist/ytlist.js | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 web/ytlist/ytlist.css create mode 100644 web/ytlist/ytlist.js (limited to 'web/ytlist') diff --git a/web/ytlist/ytlist.css b/web/ytlist/ytlist.css new file mode 100644 index 0000000..47f6446 --- /dev/null +++ b/web/ytlist/ytlist.css @@ -0,0 +1,35 @@ +a:link { + text-decoration: none; +} + +a:visited { + text-decoration: none; +} + +a:hover { + text-decoration: none; +} + +a:active { + text-decoration: none; +} + +#the_box{ + display: grid; + grid-template-columns: 1fr 1fr 1fr 1fr; + grid-gap: 5px; +} + +#the_box img { + width: 100%; +} + +.video-title, .video-channelname{ + text-decoration: none; + color: #222222; +} + + +.video-title{ + font-size: 24px +} diff --git a/web/ytlist/ytlist.js b/web/ytlist/ytlist.js new file mode 100644 index 0000000..d4ab060 --- /dev/null +++ b/web/ytlist/ytlist.js @@ -0,0 +1,79 @@ +function insert_item(item,imgurl){ + the_box.innerHTML+=`
+ + ${item[0]}: ${item[1]} + ${item[3]} +
+ +
+
` +} + +function get_item(item){ + fetch(`/ytlist/thumbnails/${item[2]}.webp`, + { method: "HEAD" } + ).then((res) => { + if (res.ok) { + insert_item(item,res.url); + } else { + fetch(`/ytlist/thumbnails/${item[2]}.jpg`, + { method: "HEAD" } + ).then((res) => { + if (res.ok) { + insert_item(item,res.url); + } else { + console.log("no"); + } + }); + } + }); +} + +async function search(){ + const sqlPromise = initSqlJs({ + locateFile: file => `/ytlist/${file}` + }); + const dataPromise = fetch("/ytlist/youtube_stuffs.db").then(res => res.arrayBuffer()); + const [SQL, buf] = await Promise.all([sqlPromise, dataPromise]) + const db = new SQL.Database(new Uint8Array(buf)); + //search_box.style.display="none"; + + category=document.querySelector('input[name="category_choice"]:checked').value; + let query="SELECT rowid,* FROM ytlist" + if (category!="ALL"){ + query+=` WHERE category='${category}'` + if (search_in.value != ""){ + query+=` AND title LIKE '%${search_in.value}%'` + } + } else if (search_in.value != ""){ + query+=` WHERE title LIKE '%${search_in.value}%'` + } + + let res = db.exec(query); + + the_box.innerHTML=""; + res[0].values.forEach(item=>{get_item(item)}); +} + + +async function init(){ + const sqlPromise = initSqlJs({ + locateFile: file => `/ytlist/${file}` + }); + const dataPromise = fetch("/ytlist/youtube_stuffs.db").then(res => res.arrayBuffer()); + const [SQL, buf] = await Promise.all([sqlPromise, dataPromise]) + const db = new SQL.Database(new Uint8Array(buf)); + + const res = db.exec("SELECT category FROM ytlist"); + + let categories=[] + res[0].values.forEach(item=>{ + if (categories.indexOf(item[0]) < 0) { + categories.push(item[0]); + + category_box.innerHTML+=` ${item[0]}
` + } + }) + +} +init() -- cgit v1.3