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-23 13:20:03 +00:00
|
|
|
|
2018-07-22 19:45:04 +00:00
|
|
|
const SETTINGS = {
|
|
|
|
STATSNUMTAGS: 5,
|
|
|
|
STATSNUMTYPE: 10,
|
2018-07-24 11:50:04 +00:00
|
|
|
WIDEGRIDITEM: true,
|
2018-07-22 19:45:04 +00:00
|
|
|
USEMASONRY: true,
|
|
|
|
GRIDITEMIDBASE: 'item',
|
|
|
|
SHOWUPPER: true,
|
|
|
|
SHOWTITLE: true,
|
2018-08-13 15:29:24 +00:00
|
|
|
SHOWAUTH: true,
|
2018-07-22 19:45:04 +00:00
|
|
|
SHOWTYPE: true,
|
|
|
|
SHOWLINK: true,
|
|
|
|
SHOWLOWER: true,
|
|
|
|
SHOWTAGS: true,
|
|
|
|
SHOWNOTE: true,
|
|
|
|
SHOWQOTE: true,
|
|
|
|
SHOWTERM: true,
|
|
|
|
SHOWPROG: true,
|
|
|
|
SHOWIMAG: true,
|
|
|
|
SHOWOVERLAY: true
|
|
|
|
}
|
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-07-17 13:41:00 +00:00
|
|
|
itemSelector: '.grid-item',
|
|
|
|
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-08-13 16:30:09 +00:00
|
|
|
|
2018-08-09 15:18:32 +00:00
|
|
|
if (window.showAdd != undefined && window.showAdd)
|
|
|
|
{
|
|
|
|
main.add.setOverlay(false);
|
|
|
|
}
|
2018-07-23 13:20:03 +00:00
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
// BUILD
|
|
|
|
this.grid.innerHTML = '';
|
2018-07-19 04:46:43 +00:00
|
|
|
this.grid.innerHTML += "<div class='grid-sizer'></div>";
|
2018-07-17 13:41:00 +00:00
|
|
|
var dbKeys = Object.keys(db);
|
|
|
|
var i = 0;
|
|
|
|
while (i < dbKeys.length)
|
|
|
|
{
|
|
|
|
this.buildEntry(db, dbKeys[i]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
|
|
|
var imgLoad = imagesLoaded( container );
|
|
|
|
// When all images finish: redo mansonry layout
|
|
|
|
imgLoad.on( 'always', function() { parent.msnry.layout(); } );
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.buildEntry = function(db, key)
|
|
|
|
{
|
|
|
|
let value = db[key];
|
|
|
|
|
2018-07-17 14:36:13 +00:00
|
|
|
let itemClass = "grid-item";
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.WIDEGRIDITEM)
|
2018-07-17 14:36:13 +00:00
|
|
|
{
|
2018-07-18 13:06:29 +00:00
|
|
|
if (typeof value.WIDE !== 'undefined' && value.WIDE)
|
|
|
|
{
|
|
|
|
itemClass += " grid-item--width2";
|
|
|
|
}
|
|
|
|
else if (typeof value.QOTE !== 'undefined')
|
2018-07-17 14:36:13 +00:00
|
|
|
{
|
|
|
|
if (Array.isArray(value.QOTE) && value.QOTE.length > 4)
|
|
|
|
{
|
2018-07-18 06:36:36 +00:00
|
|
|
itemClass += " grid-item--width2";
|
2018-07-17 14:36:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWIMAG)
|
2018-07-18 11:17:51 +00:00
|
|
|
{
|
2018-07-21 17:46:18 +00:00
|
|
|
if (typeof value.TYPE !== 'undefined' && value.TYPE == 'image')
|
|
|
|
{
|
|
|
|
itemClass += " grid-item-image";
|
|
|
|
}
|
2018-07-18 11:17:51 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 06:36:36 +00:00
|
|
|
let entry = ``;
|
2018-07-18 13:06:29 +00:00
|
|
|
|
|
|
|
// ITEM DIV
|
2018-07-22 19:45:04 +00:00
|
|
|
entry += `<div class="${itemClass}" id="${SETTINGS.GRIDITEMIDBASE + value.DIID}">`;
|
2018-07-17 13:41:00 +00:00
|
|
|
|
|
|
|
if (typeof value.LINK !== 'undefined')
|
|
|
|
{
|
|
|
|
var idUrl = "url";
|
|
|
|
if (typeof value.SEEN !== 'undefined')
|
|
|
|
{
|
|
|
|
if (value.SEEN == "true")
|
|
|
|
{
|
|
|
|
idUrl = "urlseen";
|
|
|
|
}
|
|
|
|
}
|
2018-07-18 06:36:36 +00:00
|
|
|
|
|
|
|
// LINK START
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWLINK)
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
|
|
|
entry += `<a href="${String(value.LINK)}" id="${idUrl}" class="link">`;
|
|
|
|
}
|
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-07-21 17:46:18 +00:00
|
|
|
entry += `<div class="grid-item-upper-content">`;
|
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-07-21 17:46:18 +00:00
|
|
|
entry += `<div class="title">${key.to_properCase()}</div>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
2018-07-21 17:46:18 +00:00
|
|
|
|
|
|
|
// LINK END
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWLINK)
|
2018-07-18 15:28:10 +00:00
|
|
|
{
|
2018-07-21 17:46:18 +00:00
|
|
|
if (typeof value.LINK !== 'undefined')
|
|
|
|
{
|
|
|
|
entry += `<div class="link-line"><i class="fas fa-link textIcon"></i><div class="link-title">${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-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWTYPE)
|
2018-07-19 04:46:43 +00:00
|
|
|
{
|
2018-07-21 17:46:18 +00:00
|
|
|
if (typeof value.TYPE !== 'undefined')
|
|
|
|
{
|
|
|
|
entry += `<a href='#type-${String(value.TYPE)}'>`;
|
|
|
|
entry += `<div class="type">`;
|
|
|
|
|
|
|
|
if (value.TYPE == 'article')
|
|
|
|
{
|
|
|
|
entry += `<i class="far fa-newspaper"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'podcast')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-podcast"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'video')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-tv"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'list')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-file-alt"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'book')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-book-open"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'game')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-gamepad"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'service')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-server"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'lecture')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-chalkboard-teacher"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'quote')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-comment"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'tool')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-wrench"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'music')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-music"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'image')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-image"></i>`;
|
|
|
|
}
|
|
|
|
else if (value.TYPE == 'encyclopedia')
|
|
|
|
{
|
|
|
|
entry += `<i class="fas fa-globe"></i>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
entry += `</div>`;
|
|
|
|
entry += `</a>`;
|
|
|
|
}
|
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-07-21 17:46:18 +00:00
|
|
|
entry += `<div class="grid-item-lower-content">`;
|
|
|
|
|
2018-08-13 15:29:24 +00:00
|
|
|
// AUTHOR
|
|
|
|
if (SETTINGS.SHOWAUTH)
|
|
|
|
{
|
|
|
|
if (typeof value.AUTH !== 'undefined')
|
|
|
|
{
|
|
|
|
entry += `<div class="auth"><i class="fas fa-user textIcon"></i>${value.AUTH}</div>`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// TAGS
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWTAGS)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-07-21 17:46:18 +00:00
|
|
|
if (typeof value.TAGS !== 'undefined')
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-07-21 17:46:18 +00:00
|
|
|
entry += `<div class="tags"><i class="fas fa-tag textIcon"></i>`;
|
|
|
|
for (var i = 0; i < value.TAGS.length; i++)
|
|
|
|
{
|
2018-08-09 15:38:34 +00:00
|
|
|
entry += `<a href="#tag-${value.TAGS[i]}">${value.TAGS[i]}</a>`;
|
2018-07-21 17:46:18 +00:00
|
|
|
if (i+1 != value.TAGS.length)
|
|
|
|
{
|
|
|
|
entry += `, `;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
entry += `</div>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
2018-07-21 17:46:18 +00:00
|
|
|
}
|
2018-07-17 13:41:00 +00:00
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// NOTE
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWNOTE)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-07-21 17:46:18 +00:00
|
|
|
if (typeof value.NOTE !== 'undefined')
|
|
|
|
{
|
2018-08-11 16:31:55 +00:00
|
|
|
entry += this.buildArrayElement(value.NOTE, "note", "fas fa-sticky-note 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
|
|
|
// QUOTE
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWQOTE)
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
|
|
|
if (typeof value.QOTE !== 'undefined')
|
|
|
|
{
|
2018-08-11 16:31:55 +00:00
|
|
|
entry += this.buildArrayElement(value.QOTE, "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
|
|
|
// TERM
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWTERM)
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
|
|
|
if (typeof value.TERM !== 'undefined')
|
|
|
|
{
|
2018-08-12 14:48:17 +00:00
|
|
|
entry += this.buildArrayElement(value.TERM, "term", "fas fa-ribbon textIcon");
|
2018-07-21 17:46:18 +00:00
|
|
|
}
|
|
|
|
}
|
2018-07-18 11:17:51 +00:00
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// PROGRESS
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWPROG)
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
|
|
|
if (typeof value.PROG !== 'undefined')
|
|
|
|
{
|
|
|
|
entry += `<div class="prog"><i class="fas fa-clock textIcon"></i>${value.PROG}</div>`;
|
|
|
|
}
|
|
|
|
}
|
2018-07-18 11:17:51 +00:00
|
|
|
|
2018-07-21 17:46:18 +00:00
|
|
|
// LOWER CONTENT END
|
|
|
|
entry += `</div>`;
|
|
|
|
}
|
2018-07-18 11:17:51 +00:00
|
|
|
|
|
|
|
// IMAGE
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWIMAG)
|
2018-07-18 06:36:36 +00:00
|
|
|
{
|
2018-07-21 17:46:18 +00:00
|
|
|
if (typeof value.TYPE !== 'undefined' && value.TYPE == 'image')
|
2018-07-18 06:36:36 +00:00
|
|
|
{
|
2018-07-21 17:46:18 +00:00
|
|
|
if (typeof value.FILE !== 'undefined')
|
|
|
|
{
|
|
|
|
entry += `<div class="image">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
if (SETTINGS.SHOWOVERLAY)
|
2018-07-21 17:46:18 +00:00
|
|
|
{
|
|
|
|
entry += `<div class="image-overlay"></div>`;
|
|
|
|
}
|
|
|
|
entry += `<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>`;
|
|
|
|
|
|
|
|
this.grid.innerHTML += entry;
|
|
|
|
}
|
|
|
|
|
2018-07-22 19:45:04 +00:00
|
|
|
this.stats = function(value)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
|
|
|
let menuContent = ``;
|
|
|
|
|
2018-08-09 15:26:29 +00:00
|
|
|
if (window.showAdd != undefined && window.showAdd)
|
|
|
|
{
|
|
|
|
// ADD
|
|
|
|
menuContent += `<a href='#add'>`;
|
|
|
|
menuContent += `<div class="menu-item"><b>a</b>dd</div>`;
|
|
|
|
menuContent += `</a>`;
|
2018-07-23 13:20:03 +00:00
|
|
|
|
2018-08-09 15:26:29 +00:00
|
|
|
menuContent += `<div class="menu-spacer"></div>`;
|
|
|
|
}
|
2018-07-23 13:20:03 +00:00
|
|
|
|
2018-08-13 16:30:09 +00:00
|
|
|
// TOTAL
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<a href='#'>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.total}</div>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
menuContent += `<i class="fas fa-asterisk"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
|
2018-08-13 16:30:09 +00:00
|
|
|
// DONE
|
|
|
|
menuContent += `<div class="menu-spacer"></div>`;
|
|
|
|
|
|
|
|
menuContent += `<a href='#done-true'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
|
|
|
menuContent += `<div class="count">${value.done}</div>`;
|
|
|
|
menuContent += `<i class="fas fa-check"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
|
|
|
|
menuContent += `<a href='#done-false'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
|
|
|
menuContent += `<div class="count">${value.total - value.done}</div>`;
|
|
|
|
menuContent += `<i class="fas fa-times"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
|
|
|
|
menuContent += `<div class="menu-spacer"></div>`;
|
|
|
|
|
2018-07-22 19:45:04 +00:00
|
|
|
for (var ty = 0; ty < Math.min(value.types.length, SETTINGS.STATSNUMTYPE); ty++)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-07-22 19:45:04 +00:00
|
|
|
if (value.types[ty][0] == 'article')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-article'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="far fa-newspaper"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'podcast')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-podcast'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-podcast"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'video')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-video'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-tv"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'list')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-list'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-file-alt"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'book')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-book'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-book-open"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'game')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-game'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-gamepad"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'service')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-service'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-server"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'lecture')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-lecture'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-chalkboard-teacher"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'quote')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-quote'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-comment"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'tool')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-tool'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-wrench"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'music')
|
2018-07-17 14:09:23 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-music'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<i class="fas fa-music"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'image')
|
2018-07-18 16:28:01 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-image'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-18 16:28:01 +00:00
|
|
|
menuContent += `<i class="fas fa-image"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-22 19:45:04 +00:00
|
|
|
else if (value.types[ty][0] == 'encyclopedia')
|
2018-07-19 04:46:43 +00:00
|
|
|
{
|
|
|
|
menuContent += `<a href='#type-encyclopedia'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.types[ty][1]}</div>`;
|
2018-07-19 04:46:43 +00:00
|
|
|
menuContent += `<i class="fas fa-globe"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
2018-07-17 13:41:00 +00:00
|
|
|
}
|
|
|
|
|
2018-07-17 14:09:23 +00:00
|
|
|
menuContent += `<div class="menu-spacer"></div>`;
|
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
// TERM
|
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>`;
|
|
|
|
menuContent += `<a href='#term'>`;
|
|
|
|
menuContent += `<div class="menu-item">`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="count">${value.terms}</div>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
menuContent += `<i class="fas fa-ribbon"></i>`;
|
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
|
|
|
|
2018-07-17 18:17:43 +00:00
|
|
|
menuContent += `<div class="menu-spacer"></div>`;
|
|
|
|
|
2018-07-17 13:41:00 +00:00
|
|
|
// TAGS
|
2018-07-22 19:45:04 +00:00
|
|
|
if (value.tags.length > 0)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
|
|
|
menuContent += `<div class="menu-tag-container">`;
|
|
|
|
menuContent += `<i class="fas fa-tag"></i>`;
|
2018-07-22 19:45:04 +00:00
|
|
|
for (var t = 0; t < Math.min(value.types.length, SETTINGS.STATSNUMTAGS); t++)
|
2018-07-17 13:41:00 +00:00
|
|
|
{
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<a href='#tag-${value.tags[t][0]}'>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
menuContent += `<div class="menu-tag">`;
|
|
|
|
// menuContent += `<i class="fas fa-tag textIcon"></i>`;
|
2018-07-22 19:45:04 +00:00
|
|
|
menuContent += `<div class="menu-tag-count">${value.tags[t][1]}</div>`;
|
|
|
|
menuContent += `<div class="menu-tag-label">${value.tags[t][0]}</div>`;
|
2018-07-17 13:41:00 +00:00
|
|
|
menuContent += `</div>`;
|
|
|
|
menuContent += `</a>`;
|
|
|
|
}
|
|
|
|
menuContent += `</div>`;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.menu.innerHTML = ``;
|
|
|
|
this.menu.innerHTML += menuContent;
|
|
|
|
}
|
|
|
|
|
2018-08-11 16:31:55 +00:00
|
|
|
this.buildArrayElement = function(data, className, iconName)
|
|
|
|
{
|
|
|
|
let result = '';
|
|
|
|
if (Array.isArray(data))
|
|
|
|
{
|
|
|
|
for (var i in data)
|
|
|
|
{
|
|
|
|
if (data[i] == "& ")
|
|
|
|
{
|
|
|
|
// blank line, do nothing
|
|
|
|
}
|
|
|
|
else if (data[i].substring(0, 2) == "> ")
|
|
|
|
{
|
|
|
|
// 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
|
|
|
}
|
|
|
|
else if (data[i].substring(0, 2) == "& ")
|
|
|
|
{
|
|
|
|
// New line in current item
|
|
|
|
result += `<div class="${className}">${data[i].substring(2)}</div>`;
|
|
|
|
}
|
|
|
|
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-07-17 13:41:00 +00:00
|
|
|
// HELPER
|
|
|
|
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-07-17 13:41:00 +00:00
|
|
|
if (splitArr[arrLen - 2].length == 2 && splitArr[arrLen - 1].length == 2)
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
}
|