From 0d4bb2a40513705edb4de6cc7794c228b0096bf3 Mon Sep 17 00:00:00 2001 From: kor Date: Mon, 16 Jul 2018 17:53:23 +1200 Subject: [PATCH] Added type filtering. --- content/Memex.ndtl | 3 +-- logic/main.js | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/content/Memex.ndtl b/content/Memex.ndtl index c39c2f1..2063690 100644 --- a/content/Memex.ndtl +++ b/content/Memex.ndtl @@ -1106,8 +1106,7 @@ TUDOR MONASTERY FARM LINK : https://www.youtube.com/watch?v=t1ERDYjsHBg TYPE : video DATE : 12018-07-14 - SEEN : false - PROG : Episode 04 + SEEN : true TAGS : history CLIMATE CHANGE IN POST TRUTH diff --git a/logic/main.js b/logic/main.js index e30dd88..be2b203 100644 --- a/logic/main.js +++ b/logic/main.js @@ -41,6 +41,8 @@ function Main() this.load = function(target = "home") { + console.log('load'); + target = target.substr(0,1) == "#" ? target.substr(1,target.length-1) : target target = target.trim() == "" ? "home" : target @@ -70,8 +72,11 @@ function Main() else { var splitTarget = target.split("-"); + console.log('split: ' + splitTarget[0]); + if (splitTarget[0] == 'tag') { + // TAG console.log('Display tag \'' + splitTarget[1] + '\''); var tempDatabase = {} @@ -101,7 +106,30 @@ function Main() } else if (splitTarget[0] == 'type') { - console.log('type'); + // TYPE + console.log('Display type \'' + splitTarget[1] + '\''); + + var tempDatabase = {} + for (i = 0; i < this.keys.length; i++) + { + let value = this.database[this.keys[i]]; + if (typeof value.TYPE !== 'undefined') + { + if (value.TYPE == splitTarget[1]) + { + tempDatabase[this.keys[i]] = this.database[this.keys[i]]; + } + } + } + + this.grid.innerHTML = ''; + this.displayEntries(tempDatabase); + + if (this.useMasonry) + { + this.msnry.reloadItems(); + this.msnry.layout(); + } } } } @@ -193,7 +221,7 @@ function Main() if (typeof value.TYPE !== 'undefined') { entry += `
`; - entry += ``; + entry += ``; if (value.TYPE == 'article') { entry += ``;