From 0b854ecccfe7832ba9a837605822a103fd9d8bc0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 21 Jun 2017 00:50:15 +0200 Subject: clearing out old code --- client/db.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 client/db.js (limited to 'client/db.js') diff --git a/client/db.js b/client/db.js new file mode 100644 index 0000000..8c3a6b5 --- /dev/null +++ b/client/db.js @@ -0,0 +1,33 @@ +function fetchDB(cb) { + let raw_db; + fetch('/db.json', { + method: 'GET' + }).then(res => { + if (res.status !== 200) { + return null + } + return res.json() + }).then(json => { + if (json) { + raw_db = parse(json) + } + cb(raw_db) + }).catch((err) => { + console.warn(err) + }) +} + +function parse(db) { + Object.keys(db).forEach(key => { + db[key] = db[key] + .filter((el) => ! el.disabled) + .sort((a,b) => a.__index