`;
// AUTHOR
- if (SETTINGS.SHOWAUTH && typeof value.AUTH !== 'undefined')
+ if (SETTINGS.SHOWAUTH && this.isDefined(value.AUTH))
{
entry += `
${value.AUTH}
`;
}
// TAGS
- if (SETTINGS.SHOWTAGS && typeof value.TAGS !== 'undefined')
+ if (SETTINGS.SHOWTAGS && this.isDefined(value.TAGS))
{
entry += `
`;
for (var i = 0; i < value.TAGS.length; i++)
@@ -209,74 +198,65 @@ function View()
}
// PROJECT
- if (SETTINGS.SHOWPROJ)
+ if (SETTINGS.SHOWPROJ && this.isDefined(value.PROJ))
{
- if (this.isDefined(value.PROJ))
+ entry += `
`;
+ for (var i = 0; i < value.PROJ.length; i++)
{
- entry += `
`;
+ entry += `, `;
+ }
}
+ entry += `
`;
}
// TERM
- if (SETTINGS.SHOWTERM)
+ if (SETTINGS.SHOWTERM && this.isDefined(value.TERM))
{
- if (this.isDefined(value.TERM))
- {
- entry += this.buildArrayElement(value.TERM, "griditem-term", "fas fa-ribbon textIcon");
- }
+ entry += this.doMultilineFormatting(value.TERM, "griditem-term", "fas fa-ribbon textIcon");
}
// NOTE
- if (SETTINGS.SHOWNOTE && typeof value.NOTE !== 'undefined')
+ if (SETTINGS.SHOWNOTE && this.isDefined(value.NOTE))
{
- entry += this.buildArrayElement(value.NOTE, "griditem-note", "fas fa-sticky-note textIcon");
+ entry += this.doMultilineFormatting(value.NOTE, "griditem-note", "fas fa-sticky-note textIcon");
}
// QUOTE
- if (SETTINGS.SHOWQOTE && typeof value.QOTE !== 'undefined')
+ if (SETTINGS.SHOWQOTE && this.isDefined(value.QOTE))
{
- entry += this.buildArrayElement(value.QOTE, "griditem-quote", "fas fa-comment textIcon");
+ entry += this.doMultilineFormatting(value.QOTE, "griditem-quote", "fas fa-comment textIcon");
}
// TERM
- if (SETTINGS.SHOWTERM && typeof value.TERM !== 'undefined')
+ if (SETTINGS.SHOWTERM && this.isDefined(value.TERM))
{
- entry += this.buildArrayElement(value.TERM, "griditem-term", "fas fa-ribbon textIcon");
+ entry += this.doMultilineFormatting(value.TERM, "griditem-term", "fas fa-ribbon textIcon");
}
// PROGRESS
- if (SETTINGS.SHOWPROG && typeof value.PROG !== 'undefined')
+ if (SETTINGS.SHOWPROG && this.isDefined(value.PROG))
{
entry += `
${value.PROG}
`;
}
// FILE
- if (SETTINGS.SHOWFILE)
+ if (SETTINGS.SHOWFILE && this.isDefined(value.FILE))
{
- if (this.isDefined(value.FILE))
+ if (this.isObject(value.FILE))
{
- if (typeof value.FILE == 'object')
+ for (var i = 0; i < value.FILE.length; i++)
{
- for (var i = 0; i < value.FILE.length; i++)
- {
- entry += `
`;
- }
- }
- else
- {
- // single
- entry += `
`;
+ entry += `
`;
}
}
+ else
+ {
+ // single
+ entry += `
`;
+ }
}
// LOWER CONTENT END
@@ -284,11 +264,8 @@ function View()
}
// IMAGE
- if (
- SETTINGS.SHOWIMAG
- && typeof value.TYPE !== 'undefined' && value.TYPE === 'image'
- && typeof value.FILE !== 'undefined'
- )
+ if (SETTINGS.SHOWIMAG && this.isDefined(value.TYPE)
+ && value.TYPE === 'image' && this.isDefined(value.FILE))
{
entry += `
`;
if (SETTINGS.SHOWOVERLAY)
@@ -306,7 +283,6 @@ function View()
this.stats = function(value)
{
let menuContent = ``;
-
if (window.showAdd !== undefined && window.showAdd)
{
// ADD
@@ -327,20 +303,17 @@ function View()
// DONE
menuContent += ``;
+
menuContent += ``;
// TAGS
@@ -383,12 +355,10 @@ function View()
menuContent += `
`;
}
menuContent += `
`;
-
- this.menu.innerHTML = ``;
- this.menu.innerHTML += menuContent;
+ this.menu.innerHTML = menuContent;
}
- this.buildArrayElement = function(data, className, iconName)
+ this.doMultilineFormatting = function(data, className, iconName)
{
let result = '';
if (Array.isArray(data))
@@ -437,7 +407,6 @@ function View()
return result;
}
- // HELPER
getTypeIconName = function(type)
{
let icon = '';
@@ -461,6 +430,17 @@ function View()
return icon;
}
+ // GENERAL HELPER
+ this.isDefined = function(value)
+ {
+ return (typeof value !== 'undefined');
+ }
+
+ this.isObject = function(value)
+ {
+ return (typeof value == 'object');
+ }
+
String.prototype.to_properCase = function()
{
return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
@@ -500,8 +480,6 @@ function View()
}
else
{
- console.log('calling extract on: ' + url);
-
hostname = url.split('/')[0];
}