From dd32fe1e62c68738d4cfcddd5ab5c3b671712ce5 Mon Sep 17 00:00:00 2001 From: Matthew Kousoulas Date: Mon, 21 Jun 2021 08:52:46 -0400 Subject: [PATCH 1/1] Initial Commit --- CSVtoJSON.awk | 32 +++++++++++ CSVtoJSON.sh | 2 + driver.js | 143 ++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 26 +++++++++ pictures.csv | 3 ++ pictures.json | 1 + style.css | 44 ++++++++++++++++ 7 files changed, 251 insertions(+) create mode 100644 CSVtoJSON.awk create mode 100755 CSVtoJSON.sh create mode 100644 driver.js create mode 100644 index.html create mode 100644 pictures.csv create mode 100644 pictures.json create mode 100644 style.css diff --git a/CSVtoJSON.awk b/CSVtoJSON.awk new file mode 100644 index 0000000..d6dd0ed --- /dev/null +++ b/CSVtoJSON.awk @@ -0,0 +1,32 @@ +BEGIN{ + FS=":" + ORS="" + getline #parse header + for(i=1;i<=NF;i++) + { + fields[i]=($i) + } + print "{\"photos\":[" +} +{ + print "{" + for(i=1;i<=NF;i++) + { + vals[i][$i]=($i) + printf "\"%s\":\"%s\"%s",fields[i],($i),(i == NF ? "" : ",") + } + printf "}," +} +END{ + print "]," + for(i=1;i<=NF;i++) + { + printf "\"%s\":[",fields[i] + for(v in vals[i]) + { + printf "\"%s\",",v + } + printf "]," + } + print "}\n" +} diff --git a/CSVtoJSON.sh b/CSVtoJSON.sh new file mode 100755 index 0000000..99d7a4e --- /dev/null +++ b/CSVtoJSON.sh @@ -0,0 +1,2 @@ +#!/bin/sh +awk -f CSVtoJSON.awk pictures.csv | sed -E 's/,(]|})/\1/g' > pictures.json diff --git a/driver.js b/driver.js new file mode 100644 index 0000000..67432aa --- /dev/null +++ b/driver.js @@ -0,0 +1,143 @@ +// (() => { +"use strict"; +const methods = [ "loc", "date", "sub" ]; +let up_dom, photo_dom; +// pointers to