2018-07-21 14:35:55 +00:00
|
|
|
function View()
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
|
|
|
this.msnry = null;
|
2018-07-23 13:20:03 +00:00
|
|
|
this.overlay = null;
|
|
|
|
this.container = null;
|
2018-07-17 13:41:00 +00:00
|
|
|
this.grid = null;
|
|
|
|
this.menu = null;
|
2018-07-18 10:06:56 +00:00
|
|
|
var parent = this;
|
2018-07-21 17:46:18 +00:00
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
this.install = function()
|
|
|
|
{
|
2018-07-23 13:20:03 +00:00
|
|
|
this.overlay = document.getElementById("overlay");
|
|
|
|
this.container = document.getElementById("container");
|
2018-07-17 13:41:00 +00:00
|
|
|
this.grid = document.getElementById("grid");
|
|
|
|
this.menu = document.getElementById("menu");
|
|
|
|
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.USEMASONRY)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-07-22 17:44:46 +00:00
|
|
|
this.msnry = new Masonry('.grid',
|
|
|
|
{
|
2018-09-15 13:37:29 +00:00
|
|
|
itemSelector: '.griditem',
|
2018-07-17 13:41:00 +00:00
|
|
|
columnWidth: 350,
|
|
|
|
gutter: 20,
|
|
|
|
fitWidth: true,
|
|
|
|
transitionDuration: 0,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-22 19:45:04 +00:00
|
|
|
this.display = function(db)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
if (window.showAdd !== undefined && window.showAdd)
|
2018-08-09 15:18:32 +00:00
|
|
|
{
|
|
|
|
main.add.setOverlay(false);
|
|
|
|
}
|
2018-07-23 13:20:03 +00:00
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
// BUILD
|
2018-10-30 08:09:48 +00:00
|
|
|
let dbKeys = Object.keys(db);
|
|
|
|
let i = 0;
|
|
|
|
let contentHtml = '';
|
2018-07-17 13:41:00 +00:00
|
|
|
while (i < dbKeys.length)
|
|
|
|
{
|
2018-10-30 08:09:48 +00:00
|
|
|
contentHtml += this.buildEntry(db, dbKeys[i]);
|
2018-07-17 13:41:00 +00:00
|
|
|
i++;
|
|
|
|
}
|
2018-10-30 08:09:48 +00:00
|
|
|
this.grid.innerHTML = contentHtml;
|
2018-07-17 13:41:00 +00:00
|
|
|
|
|
|
|
// LAYOUT
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.USEMASONRY)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
|
|
|
this.msnry.reloadItems();
|
|
|
|
this.msnry.layout();
|
2018-07-22 17:44:46 +00:00
|
|
|
|
2018-10-30 23:50:38 +00:00
|
|
|
if (SETTINGS.MASONRYCOMPLETE || SETTINGS.MASONRYPROGRESS)
|
|
|
|
{
|
|
|
|
let imgLoad = imagesLoaded( container );
|
2018-10-30 23:55:51 +00:00
|
|
|
if (!SETTINGS.MASONRYPROGRESS)
|
2018-10-30 23:50:38 +00:00
|
|
|
{
|
|
|
|
// When all images finish: redo mansonry layout
|
|
|
|
imgLoad.on( 'always', function() { parent.msnry.layout(); } );
|
|
|
|
}
|
2018-10-30 23:55:51 +00:00
|
|
|
else
|
2018-10-30 23:50:38 +00:00
|
|
|
{
|
|
|
|
// As images load one by one: redo masonry layout
|
|
|
|
imgLoad.on( 'progress', function() { parent.msnry.layout(); } );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.buildEntry = function(db, key)
|
|
|
|
{
|
|
|
|
let value = db[key];
|
2018-09-15 13:37:29 +00:00
|
|
|
let itemClass = "griditem";
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.WIDEGRIDITEM)
|
2018-07-17 14:36:13 +00:00
|
|
|
{
|
2018-10-29 14:04:20 +00:00
|
|
|
if (this.isDefined(value.WIDE) && value.WIDE)
|
2018-07-18 13:06:29 +00:00
|
|
|
{
|
2018-09-15 13:37:29 +00:00
|
|
|
itemClass += " griditem-wide";
|
2018-07-18 13:06:29 +00:00
|
|
|
}
|
2018-10-30 10:29:02 +00:00
|
|
|
else if (this.isDefined(value.QOTE))
|
2018-07-17 14:36:13 +00:00
|
|
|
{
|
2018-10-31 00:12:31 +00:00
|
|
|
if (Array.isArray(value.QOTE) && value.QOTE.length > SETTINGS.AUTOWIDETRIGGER)
|
2018-07-17 14:36:13 +00:00
|
|
|
{
|
2018-09-15 13:37:29 +00:00
|
|
|
itemClass += " griditem-wide";
|
2018-07-17 14:36:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-30 14:05:23 +00:00
|
|
|
let onclickImage = ``;
|
2018-10-31 01:26:21 +00:00
|
|
|
let entryIsImageType = (SETTINGS.SHOWIMAG && this.isType(value.TYPE, 'image'));
|
|
|
|
if (entryIsImageType)
|
2018-07-18 11:17:51 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
itemClass += " griditem-image";
|
2018-10-30 14:38:55 +00:00
|
|
|
onclickImage = `onclick="main.view.handleImageClick(event, this, '${value.FILE}');"
|
|
|
|
style="cursor: pointer;"`;
|
2018-07-18 11:17:51 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 06:36:36 +00:00
|
|
|
let entry = ``;
|
2018-10-30 14:05:23 +00:00
|
|
|
entry += `<div class="${itemClass}" id="${SETTINGS.GRIDITEMIDBASE + value.DIID}">`;
|
2018-07-18 13:06:29 +00:00
|
|
|
|
|
|
|
// ITEM DIV
|
2018-10-29 14:04:20 +00:00
|
|
|
if (this.isDefined(value.LINK))
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
|
|
|
var idUrl = "url";
|
2018-10-30 10:29:02 +00:00
|
|
|
if (this.isDefined(value.SEEN) && value.SEEN === "true")
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
idUrl = "urlseen";
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
2018-07-18 06:36:36 +00:00
|
|
|
|
|
|
|
// LINK START
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWLINK && !this.isObject(value.LINK))
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
// If this item has only one link then make the whole title the link
|
|
|
|
entry += `<a class="griditem-link" href="${String(value.LINK)}" id="${idUrl}">`;
|
2018-07-21 17:46:18 +00:00
|
|
|
}
|
2018-07-18 06:36:36 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 11:17:51 +00:00
|
|
|
// UPPER CONTENT START
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWUPPER)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-10-31 01:26:21 +00:00
|
|
|
let upperClass = 'griditem-containerupper';
|
|
|
|
if (entryIsImageType)
|
|
|
|
{
|
|
|
|
upperClass = 'griditem-containerupper-image';
|
|
|
|
}
|
|
|
|
entry += `<div class="${upperClass}" ${onclickImage}>`;
|
2018-07-18 07:20:53 +00:00
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// TITLE
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWTITLE)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-09-15 13:37:29 +00:00
|
|
|
entry += `<div class="griditem-title">${key.to_properCase()}</div>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
2018-07-21 17:46:18 +00:00
|
|
|
|
|
|
|
// LINK END
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWLINK && this.isDefined(value.LINK))
|
2018-07-18 15:28:10 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
if (this.isObject(value.LINK))
|
2018-10-30 09:03:16 +00:00
|
|
|
{
|
|
|
|
for (let l = 0; l < value.LINK.length; l++)
|
|
|
|
{
|
|
|
|
entry += `<a class="griditem-link" href="${String(value.LINK[l])}" id="${idUrl}">`;
|
|
|
|
entry += `<div class="griditem-linkcontainer"><i class="griditem-linkicon fas fa-link"></i><div class="griditem-linktitle">${this.extractRootDomain(value.LINK[l])}</div></div></a>`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
entry += `<div class="griditem-linkcontainer"><i class="griditem-linkicon fas fa-link"></i><div class="griditem-linktitle">${this.extractRootDomain(value.LINK)}</div></div></a>`;
|
|
|
|
}
|
2018-07-18 15:28:10 +00:00
|
|
|
}
|
2018-07-21 17:46:18 +00:00
|
|
|
|
|
|
|
// TYPE
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWTYPE && this.isDefined(value.TYPE))
|
2018-10-30 03:01:22 +00:00
|
|
|
{
|
|
|
|
|
2018-10-30 10:08:12 +00:00
|
|
|
entry += `<div class="griditem-typecontainer">`;
|
|
|
|
for (let tc = 0; tc < value.TYPE.length; tc++)
|
|
|
|
{
|
|
|
|
const icon = getTypeIconName(value.TYPE[tc]);
|
|
|
|
entry += `<a class="griditem-type" href='#type-${value.TYPE[tc]}'>`;
|
|
|
|
entry += `<i class="griditem-typeicon ${icon}"></i>`;
|
|
|
|
entry += `</a>`;
|
|
|
|
}
|
|
|
|
entry += `</div>`; // griditem-typecontainer
|
2018-07-19 04:46:43 +00:00
|
|
|
}
|
2018-07-21 17:46:18 +00:00
|
|
|
|
|
|
|
// UPPER CONTENT END
|
2018-07-17 13:41:00 +00:00
|
|
|
entry += `</div>`;
|
|
|
|
}
|
|
|
|
|
2018-07-18 11:17:51 +00:00
|
|
|
// LOWER CONTENT START
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWLOWER)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-10-31 01:26:21 +00:00
|
|
|
let lowerClass = 'griditem-containerlower';
|
|
|
|
if (entryIsImageType)
|
|
|
|
{
|
|
|
|
lowerClass = 'griditem-containerlower-image';
|
|
|
|
}
|
|
|
|
entry += `<div class="${lowerClass}" ${onclickImage}>`;
|
2018-07-21 17:46:18 +00:00
|
|
|
|
2018-08-13 15:29:24 +00:00
|
|
|
// AUTHOR
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWAUTH && this.isDefined(value.AUTH))
|
2018-08-13 15:29:24 +00:00
|
|
|
{
|
2018-10-31 01:53:42 +00:00
|
|
|
for (var i = 0; i < value.AUTH.length; i++)
|
|
|
|
{
|
|
|
|
entry += `<div class="griditem-auth"><i class="fas fa-user textIcon"></i>${value.AUTH[i].to_properCase()}</div>`;
|
|
|
|
}
|
2018-08-13 15:29:24 +00:00
|
|
|
}
|
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// TAGS
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWTAGS && this.isDefined(value.TAGS))
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
entry += `<div class="griditem-tags"><i class="fas fa-tag textIcon"></i>`;
|
|
|
|
for (var i = 0; i < value.TAGS.length; i++)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
entry += `<a class="griditem-taglink" href="#tag-${value.TAGS[i]}">${value.TAGS[i]}</a>`;
|
|
|
|
if (i+1 !== value.TAGS.length)
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
entry += `, `;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
entry += `</div>`;
|
2018-07-21 17:46:18 +00:00
|
|
|
}
|
2018-07-17 13:41:00 +00:00
|
|
|
|
2018-10-29 13:45:34 +00:00
|
|
|
// PROJECT
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWPROJ && this.isDefined(value.PROJ))
|
2018-10-29 14:04:20 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
entry += `<div class="griditem-proj"><i class="fas fa-leaf textIcon"></i>`;
|
|
|
|
for (var i = 0; i < value.PROJ.length; i++)
|
2018-10-29 13:45:34 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
entry += `<a class="griditem-taglink" href="#proj-${value.PROJ[i]}">${value.PROJ[i].to_properCase()}</a>`;
|
|
|
|
if (i + 1 != value.PROJ.length)
|
2018-10-29 13:45:34 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
entry += `, `;
|
|
|
|
}
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
2018-10-30 10:29:02 +00:00
|
|
|
entry += `</div>`;
|
2018-07-21 17:46:18 +00:00
|
|
|
}
|
2018-07-17 13:41:00 +00:00
|
|
|
|
2018-10-29 13:27:30 +00:00
|
|
|
// TERM
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWTERM && this.isDefined(value.TERM))
|
2018-10-29 13:27:30 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
entry += this.doMultilineFormatting(value.TERM, "griditem-term", "fas fa-ribbon textIcon");
|
2018-10-29 13:27:30 +00:00
|
|
|
}
|
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// NOTE
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWNOTE && this.isDefined(value.NOTE))
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
entry += this.doMultilineFormatting(value.NOTE, "griditem-note", "fas fa-sticky-note textIcon");
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// QUOTE
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWQOTE && this.isDefined(value.QOTE))
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
entry += this.doMultilineFormatting(value.QOTE, "griditem-quote", "fas fa-comment textIcon");
|
2018-07-21 17:46:18 +00:00
|
|
|
}
|
2018-07-17 13:41:00 +00:00
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// PROGRESS
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWPROG && this.isDefined(value.PROG))
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
entry += `<div class="griditem-prog"><i class="fas fa-clock textIcon"></i>${value.PROG}</div>`;
|
2018-07-21 17:46:18 +00:00
|
|
|
}
|
2018-07-18 11:17:51 +00:00
|
|
|
|
2018-10-30 11:42:51 +00:00
|
|
|
// IMAGE - for non-image-type-entry
|
|
|
|
if (SETTINGS.SHOWIMAG
|
|
|
|
&& !this.isType(value.TYPE, 'image')
|
|
|
|
&& this.isDefined(value.FILE)
|
|
|
|
&& this.isImage(value.FILE))
|
|
|
|
{
|
|
|
|
entry += `<div class="image">`;
|
2018-10-30 14:05:23 +00:00
|
|
|
entry += `<img class="griditem-img" src="content/media/${value.FILE}" onclick="main.lightbox.load('content/media/${value.FILE}')">`;
|
2018-10-30 11:42:51 +00:00
|
|
|
entry += `</div>`;
|
|
|
|
}
|
|
|
|
|
2018-10-29 14:41:42 +00:00
|
|
|
// FILE
|
2018-10-30 10:29:02 +00:00
|
|
|
if (SETTINGS.SHOWFILE && this.isDefined(value.FILE))
|
2018-10-29 14:41:42 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
if (this.isObject(value.FILE))
|
2018-10-29 14:41:42 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
for (var i = 0; i < value.FILE.length; i++)
|
2018-10-29 14:41:42 +00:00
|
|
|
{
|
2018-10-30 10:29:02 +00:00
|
|
|
entry += `<div class="griditem-file"><i class="fas fa-folder-open textIcon"></i><a class="griditem-file-link" href="content/media/${value.FILE[i]}">${value.FILE[i]}</a></div>`;
|
2018-10-29 14:41:42 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-30 10:29:02 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// single
|
|
|
|
entry += `<div class="griditem-file"><i class="fas fa-folder-open textIcon"></i><a class="griditem-file-link" href="content/media/${value.FILE}">${value.FILE}</a></div>`;
|
|
|
|
}
|
2018-10-29 14:41:42 +00:00
|
|
|
}
|
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// LOWER CONTENT END
|
|
|
|
entry += `</div>`;
|
|
|
|
}
|
2018-07-18 11:17:51 +00:00
|
|
|
|
2018-10-30 11:42:51 +00:00
|
|
|
// IMAGE - for image-type-entry
|
2018-10-31 01:26:21 +00:00
|
|
|
if (entryIsImageType
|
2018-10-30 11:42:51 +00:00
|
|
|
&& this.isDefined(value.FILE)
|
|
|
|
&& this.isImage(value.FILE))
|
2018-07-18 06:36:36 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
entry += `<div class="image">`;
|
|
|
|
if (SETTINGS.SHOWOVERLAY)
|
2018-07-18 06:36:36 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
entry += `<div class="image-overlay"></div>`;
|
2018-07-18 06:36:36 +00:00
|
|
|
}
|
2018-10-30 03:01:22 +00:00
|
|
|
entry += `<img class="griditem-image-img" src="content/media/${value.FILE}">`;
|
|
|
|
entry += `</div>`;
|
2018-07-18 06:36:36 +00:00
|
|
|
}
|
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
entry += `</div>`;
|
2018-10-30 08:09:48 +00:00
|
|
|
return entry;
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
|
|
|
|
2018-07-22 19:45:04 +00:00
|
|
|
this.stats = function(value)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
|
|
|
let menuContent = ``;
|
2018-10-30 03:01:22 +00:00
|
|
|
if (window.showAdd !== undefined && window.showAdd)
|
2018-08-09 15:26:29 +00:00
|
|
|
{
|
|
|
|
// ADD
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<div class="menu-itemgroup">`;
|
|
|
|
menuContent += `<a href='#add' class="menu-item">`;
|
|
|
|
menuContent += `<b>a</b>dd`;
|
2018-08-09 15:26:29 +00:00
|
|
|
menuContent += `</a>`;
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `</div>`;
|
2018-08-09 15:26:29 +00:00
|
|
|
}
|
2018-07-23 13:20:03 +00:00
|
|
|
|
2018-08-13 16:30:09 +00:00
|
|
|
// TOTAL
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<div class="menu-itemgroup">`;
|
|
|
|
menuContent += `<a href='#' class="menu-item">`;
|
|
|
|
menuContent += `<div class="menu-itemcount">${value.total}</div>`;
|
|
|
|
menuContent += `<i class="menu-itemicon fas fa-asterisk"></i>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
menuContent += `</a>`;
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `</div>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
|
2018-08-13 16:30:09 +00:00
|
|
|
// DONE
|
2018-10-30 22:19:49 +00:00
|
|
|
if (SETTINGS.SHOWDONE)
|
|
|
|
{
|
|
|
|
menuContent += `<div class="menu-itemgroup">`;
|
|
|
|
menuContent += `<a href='#done-true' class="menu-item">`;
|
|
|
|
menuContent += `<div class="menu-itemcount">${value.done}</div>`;
|
|
|
|
menuContent += `<i class="menu-itemicon fas fa-check"></i>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
menuContent += `<a href='#done-false' class="menu-item">`;
|
|
|
|
menuContent += `<div class="menu-itemcount">${value.total - value.done}</div>`;
|
|
|
|
menuContent += `<i class="menu-itemicon fas fa-times"></i>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
}
|
2018-10-30 10:55:36 +00:00
|
|
|
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<div class="menu-itemgroup">`;
|
2018-10-30 10:08:12 +00:00
|
|
|
for (let ty = 0; ty < Math.min(value.types.length, SETTINGS.STATSNUMTYPE); ty++)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-10-30 03:01:22 +00:00
|
|
|
const type = value.types[ty][0];
|
|
|
|
const count = value.types[ty][1];
|
2018-10-30 10:08:12 +00:00
|
|
|
const icon = getTypeIconName(type);
|
2018-10-30 03:01:22 +00:00
|
|
|
menuContent += `<a href='#type-${type}' class="menu-item">`;
|
|
|
|
menuContent += `<div class="menu-itemcount">${count}</div>`;
|
|
|
|
menuContent += `<i class="menu-itemicon ${icon}"></i>`;
|
|
|
|
menuContent += `</a>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `</div>`;
|
2018-09-14 22:53:56 +00:00
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
// TERM
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<div class="menu-itemgroup">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
if (value.terms > 0)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
|
|
|
// menuContent += `<div class="menu-item-space"></div>`;
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<a href='#term' class="menu-item">`;
|
|
|
|
menuContent += `<div class="menu-itemcount">${value.terms}</div>`;
|
|
|
|
menuContent += `<i class="menu-itemicon fas fa-ribbon"></i>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `</div>`;
|
2018-07-17 18:17:43 +00:00
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
// TAGS
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<div class="menu-itemgroup">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
if (value.tags.length > 0)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<div class="menu-tagcontainer">`;
|
|
|
|
menuContent += `<i class="menu-tagicon fas fa-tag"></i>`;
|
2018-10-30 21:56:05 +00:00
|
|
|
for (var t = 0; t < Math.min(value.tags.length, SETTINGS.STATSNUMTAGS); t++)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<a class="menu-tag" href='#tag-${value.tags[t][0]}'>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
// menuContent += `<i class="fas fa-tag textIcon"></i>`;
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `<div class="menu-tagcount">${value.tags[t][1]}</div>`;
|
|
|
|
menuContent += `<div class="menu-taglabel">${value.tags[t][0]}</div>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
|
|
|
menuContent += `</div>`;
|
|
|
|
}
|
2018-09-14 18:55:32 +00:00
|
|
|
menuContent += `</div>`;
|
2018-10-30 10:29:02 +00:00
|
|
|
this.menu.innerHTML = menuContent;
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
|
|
|
|
2018-10-30 14:38:55 +00:00
|
|
|
this.handleImageClick = function(e, element, file)
|
|
|
|
{
|
|
|
|
e = e || window.event;
|
|
|
|
var target = e.target || e.srcElement;
|
|
|
|
if (target == element)
|
|
|
|
{
|
|
|
|
// If user is clicking given element, or element's background...
|
|
|
|
// as opposed to an element's child content, then do lightbox.
|
|
|
|
// This stops lightbox from happening when clicking on tags, file etc
|
|
|
|
main.lightbox.load(`content/media/${file}`);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-30 10:29:02 +00:00
|
|
|
this.doMultilineFormatting = function(data, className, iconName)
|
2018-08-11 16:31:55 +00:00
|
|
|
{
|
|
|
|
let result = '';
|
|
|
|
if (Array.isArray(data))
|
|
|
|
{
|
|
|
|
for (var i in data)
|
|
|
|
{
|
2018-10-29 14:17:10 +00:00
|
|
|
if (data[i].substring(0, 2) == "> ")
|
2018-08-11 16:31:55 +00:00
|
|
|
{
|
|
|
|
// New item
|
2018-08-12 14:48:17 +00:00
|
|
|
if (data[i].includes(": "))
|
|
|
|
{
|
|
|
|
let titleSplit = data[i].substring(2).split(': '); // .substring(2) removes the "> "
|
|
|
|
for (var e = 0; e < titleSplit.length; e++)
|
|
|
|
{
|
|
|
|
titleSplit[e] = titleSplit[e].trim();
|
|
|
|
}
|
2018-08-12 15:05:56 +00:00
|
|
|
result += `<div class="${className}"><i class="${iconName}"></i><b>${titleSplit[0]}</b>: ${titleSplit[1]}</div>`;
|
2018-08-12 14:48:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result += `<div class="${className}"><i class="${iconName}"></i>${data[i].substring(2)}</div>`;
|
|
|
|
}
|
2018-08-11 16:31:55 +00:00
|
|
|
}
|
2018-10-30 03:01:22 +00:00
|
|
|
else if (data[i].substring(0, 2) === "& ")
|
2018-08-11 16:31:55 +00:00
|
|
|
{
|
|
|
|
// New line in current item
|
|
|
|
result += `<div class="${className}">${data[i].substring(2)}</div>`;
|
|
|
|
}
|
2018-10-29 14:17:10 +00:00
|
|
|
else if (data[i].substring(0, 2) == "- ")
|
|
|
|
{
|
|
|
|
// Bullet point
|
|
|
|
result += `<div class="${className}"><i class="fas fa-caret-right textIcon"></i>${data[i].substring(2)}</div>`;
|
|
|
|
}
|
2018-08-11 16:31:55 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// Handle unformatted
|
|
|
|
result += `<div class="${className}"><i class="${iconName}"></i>${data[i]}</div>`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Handle not array
|
|
|
|
result += `<div class="${className}"><i class="${iconName}"></i>${data}</div>`;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-10-30 10:08:12 +00:00
|
|
|
getTypeIconName = function(type)
|
|
|
|
{
|
|
|
|
let icon = '';
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case 'article': icon = 'far fa-newspaper'; break;
|
|
|
|
case 'podcast': icon = 'fas fa-podcast'; break;
|
|
|
|
case 'video': icon = 'fas fa-tv'; break;
|
|
|
|
case 'list': icon = 'fas fa-file-alt'; break;
|
|
|
|
case 'book': icon = 'fas fa-book-open'; break;
|
|
|
|
case 'game': icon = 'fas fa-gamepad'; break;
|
|
|
|
case 'service': icon = 'fas fa-server'; break;
|
|
|
|
case 'lecture': icon = 'fas fa-chalkboard-teacher'; break;
|
|
|
|
case 'quote': icon = 'fas fa-comment'; break;
|
|
|
|
case 'tool': icon = 'fas fa-wrench'; break;
|
|
|
|
case 'music': icon = 'fas fa-music'; break;
|
|
|
|
case 'image': icon = 'fas fa-image'; break;
|
|
|
|
case 'encyclopedia': icon = 'fas fa-globe'; break;
|
|
|
|
case 'term': icon = 'fas fa-ribbon'; break;
|
|
|
|
}
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
2018-10-30 11:42:51 +00:00
|
|
|
// HELPER
|
2018-10-30 10:29:02 +00:00
|
|
|
this.isDefined = function(value)
|
|
|
|
{
|
|
|
|
return (typeof value !== 'undefined');
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isObject = function(value)
|
|
|
|
{
|
|
|
|
return (typeof value == 'object');
|
|
|
|
}
|
|
|
|
|
2018-10-30 11:42:51 +00:00
|
|
|
this.isImage = function(filename)
|
|
|
|
{
|
|
|
|
return (/\.(gif|jpg|jpeg|tiff|png)$/i).test(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.isType = function(typeArray, value)
|
|
|
|
{
|
|
|
|
if (this.isDefined(typeArray))
|
|
|
|
{
|
|
|
|
for (var i = 0; i < typeArray.length; i++)
|
|
|
|
{
|
|
|
|
if (typeArray[i] == value)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
String.prototype.to_properCase = function()
|
|
|
|
{
|
|
|
|
return this.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Source: https://stackoverflow.com/questions/8498592/extract-hostname-name-from-string
|
|
|
|
this.extractRootDomain = function(url)
|
|
|
|
{
|
|
|
|
var domain = this.extractHostname(url),
|
|
|
|
splitArr = domain.split('.'),
|
|
|
|
arrLen = splitArr.length;
|
|
|
|
|
2018-07-22 17:44:46 +00:00
|
|
|
// extracting the root domain here
|
|
|
|
// if there is a subdomain
|
2018-07-17 13:41:00 +00:00
|
|
|
if (arrLen > 2)
|
|
|
|
{
|
|
|
|
domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1];
|
2018-07-22 17:44:46 +00:00
|
|
|
// check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk")
|
2018-10-30 03:01:22 +00:00
|
|
|
if (splitArr[arrLen - 2].length === 2 && splitArr[arrLen - 1].length === 2)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-07-22 17:44:46 +00:00
|
|
|
// this is using a ccTLD
|
2018-07-17 13:41:00 +00:00
|
|
|
domain = splitArr[arrLen - 3] + '.' + domain;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return domain;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Source: https://stackoverflow.com/questions/8498592/extract-hostname-name-from-string
|
|
|
|
this.extractHostname = function(url)
|
|
|
|
{
|
|
|
|
var hostname;
|
2018-07-22 17:44:46 +00:00
|
|
|
// find & remove protocol (http, ftp, etc.) and get hostname
|
2018-07-17 13:41:00 +00:00
|
|
|
|
2018-08-12 14:48:17 +00:00
|
|
|
if (url.indexOf("://") > -1)
|
|
|
|
{
|
2018-07-17 13:41:00 +00:00
|
|
|
hostname = url.split('/')[2];
|
|
|
|
}
|
2018-08-12 14:48:17 +00:00
|
|
|
else
|
|
|
|
{
|
2018-07-17 13:41:00 +00:00
|
|
|
hostname = url.split('/')[0];
|
|
|
|
}
|
|
|
|
|
2018-07-22 17:44:46 +00:00
|
|
|
// find & remove port number
|
2018-07-17 13:41:00 +00:00
|
|
|
hostname = hostname.split(':')[0];
|
2018-07-22 17:44:46 +00:00
|
|
|
// find & remove "?"
|
2018-07-17 13:41:00 +00:00
|
|
|
hostname = hostname.split('?')[0];
|
|
|
|
|
|
|
|
return hostname;
|
|
|
|
}
|
|
|
|
}
|