diff options
Diffstat (limited to 'web/ytlist')
| -rw-r--r-- | web/ytlist/ytlist.js | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/web/ytlist/ytlist.js b/web/ytlist/ytlist.js index 2f13a79..9354b02 100644 --- a/web/ytlist/ytlist.js +++ b/web/ytlist/ytlist.js @@ -1,34 +1,43 @@ let db_file="youtube_stuffs.db" +let gen_thumb=true function insert_item(item,imgurl){ + let imgtag="<br><br>" + if(imgurl){ + imgtag=`<img src="${imgurl}"></img>` + } the_box.innerHTML+=`<div> <a href="https://youtube.com/watch?v=${item[2]}" target="_BLANK"> <span class="video-title">${item[0]}: ${item[1]}</span> <span class="video-channelname">${item[3]}</span> <br> - <img src="${imgurl}"></img> + ${imgtag} </a> </div>` } 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 { - insert_item(item,null); - } - }); - } - }); + if(gen_thumb==true){ + 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 { + insert_item(item,null); + } + }); + } + }); + } else { + insert_item(item,null) + } } async function search(){ @@ -54,6 +63,7 @@ async function search(){ let res = db.exec(query); the_box.innerHTML=""; + gen_thumb=gen_thumb_check.checked res[0].values.forEach(item=>{get_item(item)}); } |
