From a7e432f0ca5ff148e9b55eabd93d38dc868e6d39 Mon Sep 17 00:00:00 2001 From: kor Date: Sun, 15 Jul 2018 22:42:10 +1200 Subject: [PATCH] Split tags string into keywords array. --- logic/main.js | 245 +++++++++++++++++++++++++++----------------------- 1 file changed, 133 insertions(+), 112 deletions(-) diff --git a/logic/main.js b/logic/main.js index a8ae42b..ab3f23f 100644 --- a/logic/main.js +++ b/logic/main.js @@ -6,8 +6,6 @@ let postPerPage = 1000; function Main() { - console.log(DB); - let view = ``; let html = document.body; @@ -24,123 +22,18 @@ function Main() fitWidth: true, transitionDuration: 0, }); + + console.log(DB); } -function displayEntries(db) +function displayEntries() { let entries = ``; page += postPerPage; - - var i = lastEntry+1; - var value; + var i = lastEntry + 1; while (i < Math.min(keys.length, page)) { - value = db[keys[i]]; - - // ENTRY - entries += `
`; - entries += `
${keys[i].toProperCase()}
`; - - // LINK - if (typeof value.LINK !== 'undefined') - { - var idUrl = "url"; - if (typeof value.SEEN !== 'undefined') - { - if (value.SEEN == "true") - { - idUrl = "urlseen"; - } - } - entries += ``; - } - - // TYPE - if (typeof value.TYPE !== 'undefined') - { - entries += ``; - } - - // TAGS - if (typeof value.TAGS !== 'undefined') - { - entries += ``; - } - - // NOTE - if (typeof value.NOTE !== 'undefined') - { - entries += `
${value.NOTE}
`; - } - - // QUOTE - if (typeof value.QOTE !== 'undefined') - { - entries += `
${value.QOTE}
`; - } - - // TERM - if (typeof value.TERM !== 'undefined') - { - entries += `
${value.TERM}
`; - } - - // PROGRESS - if (typeof value.PROG !== 'undefined') - { - entries += `
${value.PROG}
`; - } - - entries += `
`; - + entries += buildEntry(i); lastEntry = i; i += 1; } @@ -149,6 +42,134 @@ function displayEntries(db) return entries; } +function buildEntry(id) +{ + var value = this.DB[keys[id]]; + + var entry = `
`; + entry += `
${keys[id].toProperCase()}
`; + + // LINK + if (typeof value.LINK !== 'undefined') + { + var idUrl = "url"; + if (typeof value.SEEN !== 'undefined') + { + if (value.SEEN == "true") + { + idUrl = "urlseen"; + } + } + entry += ``; + } + + // TYPE + if (typeof value.TYPE !== 'undefined') + { + entry += ``; + } + + // TAGS + if (typeof value.TAGS !== 'undefined') + { + var tags = value.TAGS.split(","); + for (var i = 0; i < tags.length; i++) + { + tags[i] = tags[i].trim().toLowerCase(); + } + + this.DB[keys[id]].TAGS = tags; + + entry += `
`; + for (var i = 0; i < tags.length; i++) + { + entry += `${tags[i]}`; + if (i+1 != tags.length) + { + entry += `, `; + } + }; + entry += `
`; + } + + + // NOTE + if (typeof value.NOTE !== 'undefined') + { + entry += `
${value.NOTE}
`; + } + + // QUOTE + if (typeof value.QOTE !== 'undefined') + { + entry += `
${value.QOTE}
`; + } + + // TERM + if (typeof value.TERM !== 'undefined') + { + entry += `
${value.TERM}
`; + } + + // PROGRESS + if (typeof value.PROG !== 'undefined') + { + entry += `
${value.PROG}
`; + } + + entry += `
`; + + return entry; +} + function doPagination() { return `