]> Entropealabs - photography.git/commitdiff
update js
authorChristopher Coté <chris@entropealabs.com>
Tue, 11 Jan 2022 15:37:23 +0000 (10:37 -0500)
committerChristopher Coté <chris@entropealabs.com>
Tue, 11 Jan 2022 15:37:23 +0000 (10:37 -0500)
www/js/index.js
www/js/index.js.map

index 0bb7f06a277eb68a19861be9408bd0c9ffea9946..f8f8423be772fd1d7a140a38f6d0571dc802074b 100644 (file)
@@ -1,2 +1,2 @@
-(()=>{var h=null,i={},s=[],u=null;function f(){g()}function g(){fetch("config.json").then(e=>e.json()).then(e=>p(e))}function p(e){h=e.media_server,E()}function E(){fetch("metadata.json").then(e=>e.json()).then(e=>_(e))}function _(e){s=e,e.forEach(t=>t.datetime=new Date(t.datetime)),e.sort((t,n)=>t.datetime<n.datetime),e.forEach(t=>{t.tags.forEach(n=>{i[n]=i[n]?i[n]:[],i[n].push(t)})}),k(),w()}function w(){let e=window.location.hash;if(e=e.substring(1),console.log(e),C(e))c(e);else if(j(e))y(e);else{let t=Object.keys(i);console.log(t);let n=Math.floor(Math.random()*t.length),l=t[n];console.log(l),c(l)}}function C(e){return i[e]}function j(e){return s.find(t=>t.hash==e)}function c(e){window.scroll(0,0);let t=document.getElementById("media");for(m(e),d(e);t.firstChild;)t.removeChild(t.firstChild);u=e,i[e].forEach(n=>{let l=r(n);t.appendChild(l)})}function y(e){let t=document.getElementById("media");for(;t.firstChild;)t.removeChild(t.firstChild);let n=s.find(a=>a.hash==e),l=r(n);t.appendChild(l),d(n.hash)}function d(e){let n=e.split(" ").map(l=>l[0].toUpperCase()+l.substring(1)).join(" ");document.getElementById("tag").innerHTML=n}function k(){let e=document.getElementById("tags"),t=Object.keys(i);t.sort(),t.forEach(n=>{let l=v(n);e.appendChild(l)})}function r(e){let t=document.createElement("div");t.className="img";let n=document.createElement("img");n.src=h+e.path,n.onclick=a=>m(e.hash);let l=document.createElement("ul");return e.tags.forEach(a=>{let o=document.createElement("li");o.innerText=a,o.className="img-tag",o.onclick=b=>c(a),l.appendChild(o)}),t.appendChild(n),t.appendChild(l),t}function m(e){window.location.hash=e}function v(e){let t=document.createElement("li");return t.innerText=e,t.onclick=n=>c(e),t}f();})();
+(()=>{var d=null,l={},o=[],f=null;function p(){g()}function g(){fetch("config.json").then(e=>e.json()).then(e=>_(e))}function _(e){d=e.media_server,E()}function E(){fetch("metadata.json").then(e=>e.json()).then(e=>C(e))}function C(e){e.forEach(t=>t.datetime=new Date(t.datetime)),e.sort((t,n)=>t.datetime<n.datetime),o=e,e.forEach(t=>{t.tags.forEach(n=>{l[n]=l[n]?l[n]:[],l[n].push(t)})}),w(),x(),j()}function w(){l.latest=[];for(var e=0;e<10;e++)l.latest.push(o[e])}function j(){let e=window.location.hash;e=e.substring(1),console.log(e),v(e)?s(e):y(e)?k(e):s("latest")}function v(e){return l[e]}function y(e){return o.find(t=>t.hash==e)}function s(e){window.scroll(0,0);let t=document.getElementById("media");for(u(e),r(e);t.firstChild;)t.removeChild(t.firstChild);f=e,l[e].forEach(n=>{let a=m(n);t.appendChild(a)})}function k(e){let t=document.getElementById("media");for(;t.firstChild;)t.removeChild(t.firstChild);let n=o.find(i=>i.hash==e),a=m(n);t.appendChild(a),r(n.hash)}function r(e){let n=e.split(" ").map(a=>a[0].toUpperCase()+a.substring(1)).join(" ");document.getElementById("tag").innerHTML=n}function x(){let e=document.getElementById("tags"),t=Object.keys(l);t.sort(),t.forEach(n=>{let a=B(n);e.appendChild(a)})}function m(e){let t=document.createElement("div");t.className="img";let n=document.createElement("img");n.src=d+e.path,n.onclick=h=>u(e.hash),n.style.height=e.height+"px";let a=document.createElement("ul");a.className="image-tags",e.tags.forEach(h=>{let c=document.createElement("li");c.innerText=h,c.className="img-tag",c.onclick=I=>s(h),a.appendChild(c)});let i=document.createElement("span");return i.className="datetime",i.innerText=e.datetime,t.appendChild(n),t.appendChild(a),t.appendChild(i),t}function u(e){window.location.hash=e}function B(e){let t=document.createElement("li");return t.innerText=e,t.onclick=n=>s(e),t}p();})();
 //# sourceMappingURL=index.js.map
index 4fbe5e8cc8e44aee68e8d2997b828869b1f8c2fa..1b5762fea82b66fb069aa1a7302193e737bdff5b 100644 (file)
@@ -1,7 +1,7 @@
 {
   "version": 3,
   "sources": ["../../src/index.js"],
-  "sourcesContent": ["let server = null;\nlet tags = {};\nlet media = [];\nlet current_tag = null;\nlet current_hash = null;\n\nfunction init(){\n  get_config();\n}\n\nfunction get_config(){\n  fetch(\"config.json\")\n    .then(result => result.json())\n    .then(data => handle_config(data))\n}\n\nfunction handle_config(data){\n  server = data.media_server;\n  get_metadata();\n}\n\nfunction get_metadata(){\n  fetch(\"metadata.json\")\n    .then(result => result.json())\n    .then(data => process_media(data))\n}\n\nfunction process_media(items){\n  media = items;\n  items.forEach(i => i.datetime = new Date(i.datetime));\n  items.sort((a, b) => a.datetime < b.datetime);\n  items.forEach(i => {\n    i.tags.forEach(t => {\n      tags[t] = tags[t] ? tags[t] : [];\n      tags[t].push(i);\n    })\n  });\n  create_tags();\n  parse_hash();\n}\n\nfunction parse_hash(){\n  let hash = window.location.hash;\n  hash = hash.substring(1);\n  console.log(hash)\n  if(is_tag(hash)){\n    show_tag(hash);\n  }else if(is_image(hash)){\n    show_image(hash);\n  }else{\n    let ta = Object.keys(tags);\n    console.log(ta);\n    let rand = Math.floor(Math.random() * ta.length);\n    let t = ta[rand];\n    console.log(t);\n    show_tag(t);\n  }\n}\n\nfunction is_tag(hash){\n  return tags[hash];\n}\n\nfunction is_image(hash){\n  return media.find(img => img.hash == hash);\n}\n\nfunction show_tag(tag){\n  window.scroll(0, 0);\n  let p = document.getElementById(\"media\");\n  set_hash(tag);\n  set_title(tag);\n  while(p.firstChild){\n    p.removeChild(p.firstChild);\n  }\n  current_tag = tag;\n  tags[tag].forEach(i => {\n    let img = image(i);\n    p.appendChild(img);\n  });\n}\n\nfunction show_image(hash){\n  let p = document.getElementById(\"media\");\n  while(p.firstChild){\n    p.removeChild(p.firstChild);\n  }\n  let img = media.find(img => img.hash == hash)\n  let i = image(img);\n  p.appendChild(i);\n  set_title(img.hash);\n}\n\nfunction set_title(tag){\n  let words = tag.split(\" \");\n  let t = words.map((word) => word[0].toUpperCase() + word.substring(1)).join(\" \");\n  document.getElementById(\"tag\").innerHTML = t;\n}\n\nfunction create_tags(){\n  let p = document.getElementById(\"tags\");\n  let ta = Object.keys(tags);\n  ta.sort();\n  ta.forEach(t => {\n    let ta = tag(t);\n    p.appendChild(ta);\n  })\n}\n\nfunction image(image){\n  let w = document.createElement(\"div\");\n  w.className = \"img\";\n  let i = document.createElement(\"img\");\n  i.src = server + image.path;\n  i.onclick = (e) => set_hash(image.hash);\n  let u = document.createElement(\"ul\");\n  image.tags.forEach(t => {\n    let l = document.createElement(\"li\");\n    l.innerText = t;\n    l.className = \"img-tag\";\n    l.onclick = (e) => show_tag(t);\n    u.appendChild(l);\n  })\n  w.appendChild(i);\n  w.appendChild(u);\n  return w;\n}\n\nfunction set_hash(hash){\n  window.location.hash = hash;\n}\n\nfunction tag(tag){\n  let t = document.createElement(\"li\");\n  t.innerText = tag;\n  t.onclick = (e) => show_tag(tag);\n  return t;\n}\n\ninit();\n"],
-  "mappings": "MAAA,GAAI,GAAS,KACT,EAAO,GACP,EAAQ,GACR,EAAc,KAGlB,YAAe,CACb,IAGF,YAAqB,CACnB,MAAM,eACH,KAAK,GAAU,EAAO,QACtB,KAAK,GAAQ,EAAc,IAGhC,WAAuB,EAAK,CAC1B,EAAS,EAAK,aACd,IAGF,YAAuB,CACrB,MAAM,iBACH,KAAK,GAAU,EAAO,QACtB,KAAK,GAAQ,EAAc,IAGhC,WAAuB,EAAM,CAC3B,EAAQ,EACR,EAAM,QAAQ,GAAK,EAAE,SAAW,GAAI,MAAK,EAAE,WAC3C,EAAM,KAAK,CAAC,EAAG,IAAM,EAAE,SAAW,EAAE,UACpC,EAAM,QAAQ,GAAK,CACjB,EAAE,KAAK,QAAQ,GAAK,CAClB,EAAK,GAAK,EAAK,GAAK,EAAK,GAAK,GAC9B,EAAK,GAAG,KA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M,EAAS,EAAM,KACvB,EAAE,QAAU,AAAC,GAAM,EAAS,EAAM,MAClC,GAAI,GAAI,SAAS,cAAc,MAC/B,SAAM,KAAK,QAAQ,GAAK,CACtB,GAAI,GAAI,SAAS,cAAc,MAC/B,EAAE,UAAY,EACd,EAAE,UAAY,UACd,EAAE,QAAU,AAAC,GAAM,EAAS,GAC5B,EAAE,YAAY,KAEhB,EAAE,YAAY,GACd,EAAE,YAAY,GACP,EAGT,WAAkB,EAAK,CACrB,OAAO,SAAS,KAAO,EAGzB,WAAa,EAAI,CACf,GAAI,GAAI,SAAS,cAAc,MAC/B,SAAE,UAAY,EACd,EAAE,QAAU,AAAC,GAAM,EAAS,GACrB,EAGT",
+  "sourcesContent": ["let server = null;\nlet tags = {};\nlet media = [];\nlet current_tag = null;\nlet current_hash = null;\n\nfunction init(){\n  get_config();\n}\n\nfunction get_config(){\n  fetch(\"config.json\")\n    .then(result => result.json())\n    .then(data => handle_config(data))\n}\n\nfunction handle_config(data){\n  server = data.media_server;\n  get_metadata();\n}\n\nfunction get_metadata(){\n  fetch(\"metadata.json\")\n    .then(result => result.json())\n    .then(data => process_media(data))\n}\n\nfunction process_media(items){\n  items.forEach(i => i.datetime = new Date(i.datetime));\n  items.sort((a, b) => a.datetime < b.datetime);\n  media = items;\n  items.forEach(i => {\n    i.tags.forEach(t => {\n      tags[t] = tags[t] ? tags[t] : [];\n      tags[t].push(i);\n    })\n  });\n  create_latest_ten();\n  create_tags();\n  parse_hash();\n}\n\nfunction create_latest_ten(){\n  tags[\"latest\"] = []\n  for(var i=0; i<10; i++){\n    tags[\"latest\"].push(media[i]);\n  }\n}\n\nfunction parse_hash(){\n  let hash = window.location.hash;\n  hash = hash.substring(1);\n  console.log(hash)\n  if(is_tag(hash)){\n    show_tag(hash);\n  }else if(is_image(hash)){\n    show_image(hash);\n  }else{\n    show_tag(\"latest\");\n  }\n}\n\nfunction is_tag(hash){\n  return tags[hash];\n}\n\nfunction is_image(hash){\n  return media.find(img => img.hash == hash);\n}\n\nfunction show_tag(tag){\n  window.scroll(0, 0);\n  let p = document.getElementById(\"media\");\n  set_hash(tag);\n  set_title(tag);\n  while(p.firstChild){\n    p.removeChild(p.firstChild);\n  }\n  current_tag = tag;\n  tags[tag].forEach(i => {\n    let img = image(i);\n    p.appendChild(img);\n  });\n}\n\nfunction show_image(hash){\n  let p = document.getElementById(\"media\");\n  while(p.firstChild){\n    p.removeChild(p.firstChild);\n  }\n  let img = media.find(img => img.hash == hash)\n  let i = image(img);\n  p.appendChild(i);\n  set_title(img.hash);\n}\n\nfunction set_title(tag){\n  let words = tag.split(\" \");\n  let t = words.map((word) => word[0].toUpperCase() + word.substring(1)).join(\" \");\n  document.getElementById(\"tag\").innerHTML = t;\n}\n\nfunction create_tags(){\n  let p = document.getElementById(\"tags\");\n  let ta = Object.keys(tags);\n  ta.sort();\n  ta.forEach(t => {\n    let ta = tag(t);\n    p.appendChild(ta);\n  })\n}\n\nfunction image(image){\n  let w = document.createElement(\"div\");\n  w.className = \"img\";\n  let i = document.createElement(\"img\");\n  i.src = server + image.path;\n  i.onclick = (e) => set_hash(image.hash);\n  i.style.height = image.height + \"px\";\n  let u = document.createElement(\"ul\");\n  u.className = \"image-tags\";\n  image.tags.forEach(t => {\n    let l = document.createElement(\"li\");\n    l.innerText = t;\n    l.className = \"img-tag\";\n    l.onclick = (e) => show_tag(t);\n    u.appendChild(l);\n  });\n  let dt = document.createElement(\"span\");\n  dt.className = \"datetime\";\n  dt.innerText = image.datetime;\n  w.appendChild(i);\n  w.appendChild(u);\n  w.appendChild(dt);\n  return w;\n}\n\nfunction set_hash(hash){\n  window.location.hash = hash;\n}\n\nfunction tag(tag){\n  let t = document.createElement(\"li\");\n  t.innerText = tag;\n  t.onclick = (e) => show_tag(tag);\n  return t;\n}\n\ninit();\n"],
+  "mappings": "MAAA,GAAI,GAAS,KACT,EAAO,GACP,EAAQ,GACR,EAAc,KAGlB,YAAe,CACb,IAGF,YAAqB,CACnB,MAAM,eACH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