From 2b1ecf58d8f604585356b4e6b551596f9a38adca Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christopher=20Cot=C3=A9?= Date: Tue, 11 Jan 2022 10:17:44 -0500 Subject: [PATCH] show date --- src/index.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/index.js b/src/index.js index e1ce78ce..92d3cdf6 100644 --- a/src/index.js +++ b/src/index.js @@ -26,19 +26,27 @@ function get_metadata(){ } function process_media(items){ - media = items; items.forEach(i => i.datetime = new Date(i.datetime)); items.sort((a, b) => a.datetime < b.datetime); + media = items; items.forEach(i => { i.tags.forEach(t => { tags[t] = tags[t] ? tags[t] : []; tags[t].push(i); }) }); + create_latest_ten(); create_tags(); parse_hash(); } +function create_latest_ten(){ + tags["latest"] = [] + for(var i=0; i<10; i++){ + tags["latest"].push(media[i]); + } +} + function parse_hash(){ let hash = window.location.hash; hash = hash.substring(1); @@ -48,12 +56,7 @@ function parse_hash(){ }else if(is_image(hash)){ show_image(hash); }else{ - let ta = Object.keys(tags); - console.log(ta); - let rand = Math.floor(Math.random() * ta.length); - let t = ta[rand]; - console.log(t); - show_tag(t); + show_tag("latest"); } } @@ -114,15 +117,20 @@ function image(image){ i.src = server + image.path; i.onclick = (e) => set_hash(image.hash); let u = document.createElement("ul"); + u.className = "image-tags"; image.tags.forEach(t => { let l = document.createElement("li"); l.innerText = t; l.className = "img-tag"; l.onclick = (e) => show_tag(t); u.appendChild(l); - }) + }); + let dt = document.createElement("span"); + dt.className = "datetime"; + dt.innerText = image.datetime; w.appendChild(i); w.appendChild(u); + w.appendChild(dt); return w; } -- 2.45.3