]> Entropealabs - photography.git/commitdiff
show date
authorChristopher Coté <chris@entropealabs.com>
Tue, 11 Jan 2022 15:17:44 +0000 (10:17 -0500)
committerChristopher Coté <chris@entropealabs.com>
Tue, 11 Jan 2022 15:17:44 +0000 (10:17 -0500)
src/index.js

index e1ce78ce8c439bad6b6e671b9e1448dd12683503..92d3cdf6a3dc9f325d2b5389811298eed3c43bb4 100644 (file)
@@ -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;
 }