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 += `
`;
+ }
+
+
+ // 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 `