From dd4b54e3c47696319173c8e836fe7eed9defd82f Mon Sep 17 00:00:00 2001 From: iceyrazor Date: Sat, 2 Aug 2025 13:28:37 -0500 Subject: [PATCH] - multi db files for web - still load db item if no thumbnail --- web/ytlist.html | 6 +++++- web/ytlist/ytlist.js | 29 +++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/web/ytlist.html b/web/ytlist.html index 02ca50d..493efac 100644 --- a/web/ytlist.html +++ b/web/ytlist.html @@ -12,7 +12,11 @@ category
ALL
-
+
+ +
+ youtube_stuffs.db
+


diff --git a/web/ytlist/ytlist.js b/web/ytlist/ytlist.js index d4ab060..2f13a79 100644 --- a/web/ytlist/ytlist.js +++ b/web/ytlist/ytlist.js @@ -1,3 +1,5 @@ +let db_file="youtube_stuffs.db" + function insert_item(item,imgurl){ the_box.innerHTML+=`
@@ -22,7 +24,7 @@ function get_item(item){ if (res.ok) { insert_item(item,res.url); } else { - console.log("no"); + insert_item(item,null); } }); } @@ -33,7 +35,7 @@ async function search(){ const sqlPromise = initSqlJs({ locateFile: file => `/ytlist/${file}` }); - const dataPromise = fetch("/ytlist/youtube_stuffs.db").then(res => res.arrayBuffer()); + const dataPromise = fetch("/ytlist/"+db_file).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"; @@ -55,18 +57,19 @@ async function search(){ res[0].values.forEach(item=>{get_item(item)}); } - +let first=false async function init(){ const sqlPromise = initSqlJs({ locateFile: file => `/ytlist/${file}` }); - const dataPromise = fetch("/ytlist/youtube_stuffs.db").then(res => res.arrayBuffer()); + const dataPromise = fetch("/ytlist/"+db_file).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=[] + category_box.innerHTML=` ALL
` res[0].values.forEach(item=>{ if (categories.indexOf(item[0]) < 0) { categories.push(item[0]); @@ -75,5 +78,23 @@ async function init(){ } }) + if(first==false){ + db_box.innerHTML=` youtube_stuffs.db
` + fetch(`/ytlist/youtube_stuffs_2.db`, + { method: "HEAD" } + ).then((res) => { + if (res.ok) { + db_box.innerHTML+=` youtube_stuffs_2.db
` + } + }); + } + first=true } init() + +document.body.addEventListener('change', function(event){ + if(event.target.name=="db_choice"){ + db_file=event.target.value + init() + } +})