Split tags string into keywords array.

This commit is contained in:
kor 2018-07-15 22:42:10 +12:00
parent 8efc6cde0f
commit a7e432f0ca

View File

@ -6,8 +6,6 @@ let postPerPage = 1000;
function Main() function Main()
{ {
console.log(DB);
let view = ``; let view = ``;
let html = document.body; let html = document.body;
@ -24,22 +22,32 @@ function Main()
fitWidth: true, fitWidth: true,
transitionDuration: 0, transitionDuration: 0,
}); });
console.log(DB);
} }
function displayEntries(db) function displayEntries()
{ {
let entries = ``; let entries = ``;
page += postPerPage; page += postPerPage;
var i = lastEntry + 1;
var i = lastEntry+1;
var value;
while (i < Math.min(keys.length, page)) while (i < Math.min(keys.length, page))
{ {
value = db[keys[i]]; entries += buildEntry(i);
lastEntry = i;
i += 1;
}
// ENTRY entries += doPagination();
entries += `<div class="grid-item">`; return entries;
entries += `<div class="title">${keys[i].toProperCase()}</div>`; }
function buildEntry(id)
{
var value = this.DB[keys[id]];
var entry = `<div class="grid-item">`;
entry += `<div class="title">${keys[id].toProperCase()}</div>`;
// LINK // LINK
if (typeof value.LINK !== 'undefined') if (typeof value.LINK !== 'undefined')
@ -52,101 +60,114 @@ function displayEntries(db)
idUrl = "urlseen"; idUrl = "urlseen";
} }
} }
entries += `<div class="link"><i class="fas fa-link textIcon"></i><a href="${String(value.LINK)}" id="${idUrl}">${extractRootDomain(value.LINK)}</a></div>`; entry += `<div class="link"><i class="fas fa-link textIcon"></i><a href="${String(value.LINK)}" id="${idUrl}">${extractRootDomain(value.LINK)}</a></div>`;
} }
// TYPE // TYPE
if (typeof value.TYPE !== 'undefined') if (typeof value.TYPE !== 'undefined')
{ {
entries += `<div id="type">`; entry += `<div id="type">`;
entries += `<a href='#type:${String(value.TYPE)}'>`; entry += `<a href='#type:${String(value.TYPE)}'>`;
if (value.TYPE == 'article') if (value.TYPE == 'article')
{ {
entries += `<i class="far fa-newspaper"></i>`; entry += `<i class="far fa-newspaper"></i>`;
} }
else if (value.TYPE == 'podcast') else if (value.TYPE == 'podcast')
{ {
entries += `<i class="fas fa-podcast"></i>`; entry += `<i class="fas fa-podcast"></i>`;
} }
else if (value.TYPE == 'video') else if (value.TYPE == 'video')
{ {
entries += `<i class="fas fa-tv"></i>`; entry += `<i class="fas fa-tv"></i>`;
} }
else if (value.TYPE == 'list') else if (value.TYPE == 'list')
{ {
entries += `<i class="fas fa-file-alt"></i>`; entry += `<i class="fas fa-file-alt"></i>`;
} }
else if (value.TYPE == 'book') else if (value.TYPE == 'book')
{ {
entries += `<i class="fas fa-book-open"></i>`; entry += `<i class="fas fa-book-open"></i>`;
} }
else if (value.TYPE == 'game') else if (value.TYPE == 'game')
{ {
entries += `<i class="fas fa-gamepad"></i>`; entry += `<i class="fas fa-gamepad"></i>`;
} }
else if (value.TYPE == 'service') else if (value.TYPE == 'service')
{ {
entries += `<i class="fas fa-server"></i>`; entry += `<i class="fas fa-server"></i>`;
} }
else if (value.TYPE == 'lecture') else if (value.TYPE == 'lecture')
{ {
entries += `<i class="fas fa-chalkboard-teacher"></i>`; entry += `<i class="fas fa-chalkboard-teacher"></i>`;
} }
else if (value.TYPE == 'quote') else if (value.TYPE == 'quote')
{ {
entries += `<i class="fas fa-comment"></i>`; entry += `<i class="fas fa-comment"></i>`;
} }
else if (value.TYPE == 'tool') else if (value.TYPE == 'tool')
{ {
entries += `<i class="fas fa-wrench"></i>`; entry += `<i class="fas fa-wrench"></i>`;
} }
else if (value.TYPE == 'music') else if (value.TYPE == 'music')
{ {
entries += `<i class="fas fa-music"></i>`; entry += `<i class="fas fa-music"></i>`;
} }
entries += `</a>`; entry += `</a>`;
entries += `</div>`; entry += `</div>`;
} }
// TAGS // TAGS
if (typeof value.TAGS !== 'undefined') if (typeof value.TAGS !== 'undefined')
{ {
entries += `<div class="tags"><i class="fas fa-tag textIcon"></i><a href=#tag:${value.TAGS.toLowerCase()}>${value.TAGS.toLowerCase()}</a></div>`; 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 += `<div class="tags"><i class="fas fa-tag textIcon"></i>`;
for (var i = 0; i < tags.length; i++)
{
entry += `<a href=#tag:${tags[i]}>${tags[i]}</a>`;
if (i+1 != tags.length)
{
entry += `, `;
}
};
entry += `</div>`;
}
// NOTE // NOTE
if (typeof value.NOTE !== 'undefined') if (typeof value.NOTE !== 'undefined')
{ {
entries += `<div class="note"><i class="fas fa-sticky-note textIcon"></i>${value.NOTE}</div>`; entry += `<div class="note"><i class="fas fa-sticky-note textIcon"></i>${value.NOTE}</div>`;
} }
// QUOTE // QUOTE
if (typeof value.QOTE !== 'undefined') if (typeof value.QOTE !== 'undefined')
{ {
entries += `<div class="quote"><i class="fas fa-comment textIcon"></i>${value.QOTE}</div>`; entry += `<div class="quote"><i class="fas fa-comment textIcon"></i>${value.QOTE}</div>`;
} }
// TERM // TERM
if (typeof value.TERM !== 'undefined') if (typeof value.TERM !== 'undefined')
{ {
entries += `<div class="term"><i class="fas fa-ribbon textIcon"></i>${value.TERM}</div>`; entry += `<div class="term"><i class="fas fa-ribbon textIcon"></i>${value.TERM}</div>`;
} }
// PROGRESS // PROGRESS
if (typeof value.PROG !== 'undefined') if (typeof value.PROG !== 'undefined')
{ {
entries += `<div class="prog"><i class="fas fa-clock textIcon"></i>${value.PROG}</div>`; entry += `<div class="prog"><i class="fas fa-clock textIcon"></i>${value.PROG}</div>`;
} }
entries += `</div>`; entry += `</div>`;
lastEntry = i; return entry;
i += 1;
}
entries += doPagination();
return entries;
} }
function doPagination() function doPagination()