mirror of
https://github.com/TangentFoxy/memex.git
synced 2024-12-17 19:14:21 +00:00
Refactor view.js into grid.js, nav.js and util.js
This commit is contained in:
parent
c05ca309bb
commit
b2a1d28b16
@ -26,8 +26,10 @@
|
||||
|
||||
<script src="content/data.ndtl"></script>
|
||||
<script src="content/settings.js"></script>
|
||||
<script src="logic/view/util.js"></script>
|
||||
<script src="logic/view/grid.js"></script>
|
||||
<script src="logic/view/nav.js"></script>
|
||||
<script src="logic/wrap.js"></script>
|
||||
<script src="logic/view.js"></script>
|
||||
<script src="logic/main.js"></script>
|
||||
<script src="logic/add.js"></script>
|
||||
<script src="logic/lightbox.js"></script>
|
||||
|
@ -1,7 +1,9 @@
|
||||
function Main()
|
||||
{
|
||||
this.util = null;
|
||||
this.db = null;
|
||||
this.view = null;
|
||||
this.grid = null;
|
||||
this.nav = null;
|
||||
this.add = null;
|
||||
this.write = null;
|
||||
|
||||
@ -13,14 +15,17 @@ function Main()
|
||||
|
||||
this.install = function()
|
||||
{
|
||||
this.util = new Util();
|
||||
this.db = new Wrap();
|
||||
this.db.install(DATABASE);
|
||||
this.view = new View();
|
||||
this.view.install(
|
||||
document.querySelector('nav'),
|
||||
document.querySelector('.container'),
|
||||
this.grid = new Grid();
|
||||
this.grid.install(
|
||||
document.querySelector('main'),
|
||||
document.querySelector('.page-overlay'));
|
||||
document.querySelector('.page-overlay'),
|
||||
'main',
|
||||
'article');
|
||||
this.nav = new Nav();
|
||||
this.nav.install(document.querySelector('nav'));
|
||||
|
||||
if (window.showAdd !== undefined && window.showAdd)
|
||||
{
|
||||
@ -37,7 +42,7 @@ function Main()
|
||||
this.start = function()
|
||||
{
|
||||
this.load(window.document.location.hash);
|
||||
this.view.stats(this.db.stats());
|
||||
this.nav.display(this.db.stats());
|
||||
}
|
||||
|
||||
this.load = function(target)
|
||||
@ -76,7 +81,7 @@ function Main()
|
||||
// // Map our array of entries to
|
||||
// // an array of template promises.
|
||||
// // This makes sure they all template in parallel.
|
||||
// return results.map(this.view.templateEntry)
|
||||
// return results.map(this.grid.templateEntry)
|
||||
// .reduce(function(sequence, chapterPromise) {
|
||||
// // Use reduce to chain the promises together,
|
||||
// // adding content to the page for each entry
|
||||
@ -85,7 +90,7 @@ function Main()
|
||||
// // then wait for this template to arrive.
|
||||
// return chapterPromise;
|
||||
// }).then(function(article) {
|
||||
// this.view.addHtmlToPage(article.html);
|
||||
// this.grid.addHtmlToPage(article.html);
|
||||
// });
|
||||
// }, Promise.resolve());
|
||||
// })
|
||||
@ -97,9 +102,9 @@ function Main()
|
||||
|
||||
// this.db.filter(this.queryCur)
|
||||
// .then(function(results){
|
||||
// return this.view.templateEntry(results[0]);
|
||||
// return this.grid.templateEntry(results[0]);
|
||||
// }).then(function(article) {
|
||||
// this.view.addHtmlToPage(article.html);
|
||||
// this.grid.addHtmlToPage(article.html);
|
||||
// }).catch(function() {
|
||||
// console.log("error: " + err.message);
|
||||
// }).then(function() {
|
||||
@ -108,7 +113,7 @@ function Main()
|
||||
|
||||
// see: https://developers.google.com/web/fundamentals/primers/promises#whats-all-the-fuss-about
|
||||
|
||||
this.view.display(this.db.filter(this.queryCur));
|
||||
this.grid.display(this.db.filter(this.queryCur));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,563 +0,0 @@
|
||||
function View()
|
||||
{
|
||||
this.nav = null;
|
||||
this.container = null;
|
||||
this.grid = null;
|
||||
this.overlay = null;
|
||||
|
||||
this.msnry = null;
|
||||
var parent = this;
|
||||
|
||||
this.install = function(nav, container, grid, overlay)
|
||||
{
|
||||
this.nav = nav;
|
||||
this.container = container;
|
||||
this.grid = grid;
|
||||
this.overlay = overlay;
|
||||
|
||||
if (SETTINGS.USEMASONRY)
|
||||
{
|
||||
this.msnry = new Masonry('main',
|
||||
{
|
||||
itemSelector: 'article',
|
||||
columnWidth: 350,
|
||||
gutter: 20,
|
||||
fitWidth: true,
|
||||
transitionDuration: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.display = function(db)
|
||||
{
|
||||
if (window.showAdd !== undefined && window.showAdd)
|
||||
{
|
||||
main.add.setOverlay(false);
|
||||
}
|
||||
|
||||
// BUILD
|
||||
let dbKeys = Object.keys(db);
|
||||
let i = 0;
|
||||
let contentHtml = '';
|
||||
while (i < dbKeys.length)
|
||||
{
|
||||
contentHtml += this.buildArticle(db, dbKeys[i]);
|
||||
i++;
|
||||
}
|
||||
this.grid.innerHTML = contentHtml;
|
||||
|
||||
// LAYOUT
|
||||
if (SETTINGS.USEMASONRY)
|
||||
{
|
||||
this.msnry.reloadItems();
|
||||
this.msnry.layout();
|
||||
|
||||
if (SETTINGS.MASONRYCOMPLETE || SETTINGS.MASONRYPROGRESS)
|
||||
{
|
||||
let imgLoad = imagesLoaded( this.container );
|
||||
if (!SETTINGS.MASONRYPROGRESS)
|
||||
{
|
||||
// When all images finish: redo mansonry layout
|
||||
imgLoad.on( 'always', function() { parent.msnry.layout(); } );
|
||||
}
|
||||
else
|
||||
{
|
||||
// As images load one by one: redo masonry layout
|
||||
imgLoad.on( 'progress', function() { parent.msnry.layout(); } );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.buildArticle = function(db, key)
|
||||
{
|
||||
let value = db[key];
|
||||
let itemClass = "article";
|
||||
if (SETTINGS.WIDEARTICLE)
|
||||
{
|
||||
if (this.isDefined(value.WIDE) && value.WIDE)
|
||||
{
|
||||
itemClass += " article-wide";
|
||||
}
|
||||
else if (this.isDefined(value.QOTE))
|
||||
{
|
||||
if (Array.isArray(value.QOTE) && value.QOTE.length > SETTINGS.AUTOWIDETRIGGER)
|
||||
{
|
||||
itemClass += " article-wide";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let onclickImage = ``;
|
||||
let articleIsImageType = (SETTINGS.SHOWIMAG && this.isType(value.TYPE, 'image'));
|
||||
if (articleIsImageType)
|
||||
{
|
||||
itemClass += " article-image";
|
||||
onclickImage = `onclick="main.view.handleImageClick(event, this, '${value.FILE}');"
|
||||
style="cursor: pointer;"`;
|
||||
}
|
||||
|
||||
// ARTICLE
|
||||
let article = `<article class="${itemClass}" id="${SETTINGS.ARTICLEIDBASE + value.DIID}">`;
|
||||
if (this.isDefined(value.LINK))
|
||||
{
|
||||
var idUrl = "url";
|
||||
if (this.isDefined(value.SEEN) && value.SEEN === "true")
|
||||
{
|
||||
idUrl = "urlseen";
|
||||
}
|
||||
|
||||
// LINK START
|
||||
if (SETTINGS.SHOWLINK && !this.isObject(value.LINK))
|
||||
{
|
||||
// If this item has only one link then make the whole title the link
|
||||
article += `<a class="article-link" href="${String(value.LINK)}" id="${idUrl}">`;
|
||||
}
|
||||
}
|
||||
|
||||
// UPPER CONTENT START
|
||||
if (SETTINGS.SHOWUPPER)
|
||||
{
|
||||
let upperClass = 'article-containerupper';
|
||||
if (articleIsImageType)
|
||||
{
|
||||
upperClass = 'article-containerupper-image';
|
||||
}
|
||||
article += `<div class="${upperClass}" ${onclickImage}>`;
|
||||
|
||||
// TITLE
|
||||
if (SETTINGS.SHOWTITLE)
|
||||
{
|
||||
article += `<header class="article-title">${key.to_properCase()}</header>`;
|
||||
}
|
||||
|
||||
// LINK END
|
||||
if (SETTINGS.SHOWLINK && this.isDefined(value.LINK))
|
||||
{
|
||||
if (this.isObject(value.LINK))
|
||||
{
|
||||
for (let l = 0; l < value.LINK.length; l++)
|
||||
{
|
||||
article += `<a class="article-link" href="${String(value.LINK[l])}" id="${idUrl}">`;
|
||||
article += `<div class="article-linkcontainer"><div class="article-linkicon">${this.buildIcon('link')}</div><div class="article-linktitle">${this.extractRootDomain(value.LINK[l])}</div></div></a>`;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
article += `<div class="article-linkcontainer"><div class="article-linkicon">${this.buildIcon('link')}</div><div class="article-linktitle">${this.extractRootDomain(value.LINK)}</div></div></a>`;
|
||||
}
|
||||
}
|
||||
|
||||
// TYPE
|
||||
if (SETTINGS.SHOWTYPE && this.isDefined(value.TYPE))
|
||||
{
|
||||
|
||||
article += `<div class="article-typecontainer">`;
|
||||
for (let tc = 0; tc < value.TYPE.length; tc++)
|
||||
{
|
||||
article += `<a class="article-type" href='#type-${value.TYPE[tc]}'>`;
|
||||
article += this.buildIcon(value.TYPE[tc], value.TYPE[tc], 'article-typeicon');
|
||||
article += `</a>`;
|
||||
}
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
// UPPER CONTENT END
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
// LOWER CONTENT START
|
||||
if (SETTINGS.SHOWLOWER)
|
||||
{
|
||||
let lowerClass = 'article-containerlower';
|
||||
if (articleIsImageType)
|
||||
{
|
||||
lowerClass = 'article-containerlower-image';
|
||||
}
|
||||
article += `<div class="${lowerClass}" ${onclickImage}>`;
|
||||
|
||||
// TIME
|
||||
if (SETTINGS.SHOWDATE && this.isDefined(value.DATE))
|
||||
{
|
||||
article += this.doRow('date', value.DATE);
|
||||
}
|
||||
|
||||
// AUTHOR
|
||||
if (SETTINGS.SHOWAUTH && this.isDefined(value.AUTH))
|
||||
{
|
||||
for (var i = 0; i < value.AUTH.length; i++)
|
||||
{
|
||||
article += this.doRow('author', value.AUTH[i].to_properCase());
|
||||
}
|
||||
}
|
||||
|
||||
// TAGS
|
||||
if (SETTINGS.SHOWTAGS && this.isDefined(value.TAGS))
|
||||
{
|
||||
article += this.doRowArray('tags', value.TAGS, 'tag', false);
|
||||
}
|
||||
|
||||
// PROJECT
|
||||
if (SETTINGS.SHOWPROJ && this.isDefined(value.PROJ))
|
||||
{
|
||||
article += this.doRowArray('project', value.PROJ, 'proj', true);
|
||||
}
|
||||
|
||||
// TERM
|
||||
if (SETTINGS.SHOWTERM && this.isDefined(value.TERM))
|
||||
{
|
||||
article += this.doRowMulti('term', value.TERM);
|
||||
}
|
||||
|
||||
// NOTE
|
||||
if (SETTINGS.SHOWNOTE && this.isDefined(value.NOTE))
|
||||
{
|
||||
article += this.doRowMulti('note', value.NOTE);
|
||||
}
|
||||
|
||||
// QUOTE
|
||||
if (SETTINGS.SHOWQOTE && this.isDefined(value.QOTE))
|
||||
{
|
||||
article += this.doRowMulti('quote', value.QOTE);
|
||||
}
|
||||
|
||||
// PROGRESS
|
||||
if (SETTINGS.SHOWPROG && this.isDefined(value.PROG))
|
||||
{
|
||||
article += this.doRow('progress', value.PROG);
|
||||
}
|
||||
|
||||
// IMAGE - for non-image-type-article
|
||||
if (SETTINGS.SHOWIMAG
|
||||
&& !this.isType(value.TYPE, 'image')
|
||||
&& this.isDefined(value.FILE)
|
||||
&& this.isImage(value.FILE))
|
||||
{
|
||||
article += `<div class="image">`;
|
||||
article += `<img class="article-img" src="content/media/${value.FILE}" onclick="lightbox.load('content/media/${value.FILE}')">`;
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
// FILE
|
||||
if (SETTINGS.SHOWFILE && this.isDefined(value.FILE))
|
||||
{
|
||||
if (this.isObject(value.FILE))
|
||||
{
|
||||
for (var i = 0; i < value.FILE.length; i++)
|
||||
{
|
||||
article += this.doRow('file', `<a class="article-file-link" href="content/media/${value.FILE[i]}">${value.FILE[i]}</a>`, 'article-file');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// single
|
||||
article += this.doRow('file', `<a class="article-file-link" href="content/media/${value.FILE}">${value.FILE}</a>`, 'article-file');
|
||||
}
|
||||
}
|
||||
|
||||
// LOWER CONTENT END
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
// IMAGE - for image-type-article
|
||||
if (articleIsImageType
|
||||
&& this.isDefined(value.FILE)
|
||||
&& this.isImage(value.FILE))
|
||||
{
|
||||
article += `<div class="image">`;
|
||||
if (SETTINGS.SHOWOVERLAY)
|
||||
{
|
||||
article += `<div class="image-overlay"></div>`;
|
||||
}
|
||||
article += `<img class="article-image-img" src="content/media/${value.FILE}">`;
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
article += `</article>`;
|
||||
return article;
|
||||
}
|
||||
|
||||
this.doRow = function(type, content, extraClass)
|
||||
{
|
||||
return `<div class="article-row${extraClass != undefined ? ' '+extraClass : ''}">
|
||||
${type != undefined ? this.buildIcon(type) : ''}
|
||||
<div class="article-rowtext">${content}</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
this.doRowArray = function(type, data, query, propercase)
|
||||
{
|
||||
let content = '';
|
||||
for (var i = 0; i < data.length; i++)
|
||||
{
|
||||
content += `<a class="article-taglink" href="#${query}-${data[i]}">${propercase == true ? data[i].to_properCase() : data[i]}</a>`;
|
||||
if (i + 1 !== data.length)
|
||||
{
|
||||
content += `, `;
|
||||
}
|
||||
}
|
||||
return this.doRow(type, content);
|
||||
}
|
||||
|
||||
this.doRowMulti = function(type, data)
|
||||
{
|
||||
let result = '';
|
||||
if (Array.isArray(data))
|
||||
{
|
||||
for (var i in data)
|
||||
{
|
||||
if (data[i].substring(0, 2) == "> ")
|
||||
{
|
||||
// New item
|
||||
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();
|
||||
}
|
||||
result += this.doRow(type, `<b>${titleSplit[0]}</b>: ${titleSplit[1]}`);
|
||||
}
|
||||
else
|
||||
{
|
||||
result += this.doRow(type, data[i].substring(2));
|
||||
}
|
||||
}
|
||||
else if (data[i].substring(0, 2) === "& ")
|
||||
{
|
||||
// New line in current item
|
||||
result += this.doRow(null, data[i].substring(2));
|
||||
}
|
||||
else if (data[i].substring(0, 2) == "- ")
|
||||
{
|
||||
// Bullet point
|
||||
result += this.doRow('dash', data[i].substring(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle unformatted
|
||||
result += this.doRow(type, data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle not array
|
||||
result += this.doRow(type, data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
this.stats = function(value)
|
||||
{
|
||||
let navContent = ``;
|
||||
if (window.showAdd !== undefined && window.showAdd)
|
||||
{
|
||||
// ADD
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
navContent += `<a href='#add' class="nav-item">`;
|
||||
navContent += `<b>a</b>dd`;
|
||||
navContent += `</a>`;
|
||||
navContent += `</div>`;
|
||||
}
|
||||
|
||||
// TOTAL
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
navContent += `<a href='#' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${value.total}</div>`;
|
||||
navContent += `<i title="all" class="nav-itemicon fas fa-asterisk"></i>`;
|
||||
navContent += `</a>`;
|
||||
navContent += `</div>`;
|
||||
|
||||
// DONE
|
||||
if (SETTINGS.SHOWDONE)
|
||||
{
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
navContent += `<a href='#done-true' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${value.done}</div>`;
|
||||
navContent += `<i title="done" class="nav-itemicon fas fa-check"></i>`;
|
||||
navContent += `</a>`;
|
||||
navContent += `<a href='#done-false' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${value.total - value.done}</div>`;
|
||||
navContent += `<i title="to do" class="nav-itemicon fas fa-times"></i>`;
|
||||
navContent += `</a>`;
|
||||
navContent += `</div>`;
|
||||
}
|
||||
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
for (let ty = 0; ty < Math.min(value.types.length, SETTINGS.STATSNUMTYPE); ty++)
|
||||
{
|
||||
const type = value.types[ty][0];
|
||||
const count = value.types[ty][1];
|
||||
const icon = this.getIcon(type);
|
||||
navContent += `<a href='#type-${type}' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${count}</div>`;
|
||||
navContent += `<i title="${type}" class="nav-itemicon ${icon}"></i>`;
|
||||
navContent += `</a>`;
|
||||
}
|
||||
navContent += `</div>`;
|
||||
|
||||
// TERM
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
if (value.terms > 0)
|
||||
{
|
||||
navContent += `<a href='#term' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${value.terms}</div>`;
|
||||
navContent += `<i title="terms" class="nav-itemicon fas fa-ribbon"></i>`;
|
||||
navContent += `</a>`;
|
||||
}
|
||||
navContent += `</div>`;
|
||||
|
||||
// TAGS
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
if (value.tags.length > 0)
|
||||
{
|
||||
navContent += `<div class="nav-tagcontainer">`;
|
||||
navContent += `<i title="tags" class="nav-tagicon fas fa-tag"></i>`;
|
||||
for (var t = 0; t < Math.min(value.tags.length, SETTINGS.STATSNUMTAGS); t++)
|
||||
{
|
||||
navContent += `<a class="nav-tag" href='#tag-${value.tags[t][0]}'>`;
|
||||
navContent += `<div class="nav-tagcount">${value.tags[t][1]}</div>`;
|
||||
navContent += `<div class="nav-taglabel">${value.tags[t][0]}</div>`;
|
||||
navContent += `</a>`;
|
||||
}
|
||||
navContent += `</div>`;
|
||||
}
|
||||
navContent += `</div>`;
|
||||
this.nav.innerHTML = navContent;
|
||||
}
|
||||
|
||||
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
|
||||
lightbox.load(`content/media/${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
this.buildIcon = function(type, label, altClass)
|
||||
{
|
||||
if (label == undefined) { label = type; }
|
||||
let labelElem = label != null ? `title="${label}" ` : ``;
|
||||
let iconClass = altClass == undefined ? 'article-icon' : altClass;
|
||||
return `<i ${labelElem}class="${this.getIcon(type)} textIcon ${iconClass}"></i>`;
|
||||
}
|
||||
|
||||
this.getIcon = 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;
|
||||
case 'note': icon = 'fas fa-sticky-note'; break;
|
||||
case 'date': icon = 'fas fa-clock'; break;
|
||||
case 'author': icon = 'fas fa-user'; break;
|
||||
case 'tags': icon = 'fas fa-tag'; break;
|
||||
case 'project': icon = 'fas fa-leaf'; break;
|
||||
case 'progress': icon = 'fas fa-clock'; break;
|
||||
case 'file': icon = 'fas fa-folder-open'; break;
|
||||
case 'dash': icon = 'fas fa-caret-right'; break;
|
||||
case 'link': icon = 'fas fa-link'; break;
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
// HELPER
|
||||
this.isDefined = function(value)
|
||||
{
|
||||
return (typeof value !== 'undefined');
|
||||
}
|
||||
|
||||
this.isObject = function(value)
|
||||
{
|
||||
return (typeof value == 'object');
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// extracting the root domain here
|
||||
// if there is a subdomain
|
||||
if (arrLen > 2)
|
||||
{
|
||||
domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1];
|
||||
// check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk")
|
||||
if (splitArr[arrLen - 2].length === 2 && splitArr[arrLen - 1].length === 2)
|
||||
{
|
||||
// this is using a ccTLD
|
||||
domain = splitArr[arrLen - 3] + '.' + domain;
|
||||
}
|
||||
}
|
||||
return domain;
|
||||
}
|
||||
|
||||
// Source: https://stackoverflow.com/questions/8498592/extract-hostname-name-from-string
|
||||
this.extractHostname = function(url)
|
||||
{
|
||||
var hostname;
|
||||
// find & remove protocol (http, ftp, etc.) and get hostname
|
||||
|
||||
if (url.indexOf("://") > -1)
|
||||
{
|
||||
hostname = url.split('/')[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
hostname = url.split('/')[0];
|
||||
}
|
||||
|
||||
// find & remove port number
|
||||
hostname = hostname.split(':')[0];
|
||||
// find & remove "?"
|
||||
hostname = hostname.split('?')[0];
|
||||
|
||||
return hostname;
|
||||
}
|
||||
}
|
367
docs/logic/view/grid.js
Normal file
367
docs/logic/view/grid.js
Normal file
@ -0,0 +1,367 @@
|
||||
function Grid()
|
||||
{
|
||||
this.container = null;
|
||||
this.overlay = null;
|
||||
|
||||
this.msnry = null;
|
||||
var parent = this;
|
||||
|
||||
this.install = function(container, overlay, elemContainer, elemItem)
|
||||
{
|
||||
this.container = container;
|
||||
this.overlay = overlay;
|
||||
|
||||
if (SETTINGS.USEMASONRY)
|
||||
{
|
||||
this.msnry = new Masonry(elemContainer,
|
||||
{
|
||||
itemSelector: elemItem,
|
||||
columnWidth: 350,
|
||||
gutter: 20,
|
||||
fitWidth: true,
|
||||
transitionDuration: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
this.display = function(db)
|
||||
{
|
||||
if (window.showAdd !== undefined && window.showAdd)
|
||||
{
|
||||
main.add.setOverlay(false);
|
||||
}
|
||||
|
||||
// BUILD
|
||||
let dbKeys = Object.keys(db);
|
||||
let i = 0;
|
||||
let contentHtml = '';
|
||||
while (i < dbKeys.length)
|
||||
{
|
||||
contentHtml += this.buildArticle(db, dbKeys[i]);
|
||||
i++;
|
||||
}
|
||||
this.container.innerHTML = contentHtml;
|
||||
|
||||
// LAYOUT
|
||||
if (SETTINGS.USEMASONRY)
|
||||
{
|
||||
this.msnry.reloadItems();
|
||||
this.msnry.layout();
|
||||
|
||||
if (SETTINGS.MASONRYCOMPLETE || SETTINGS.MASONRYPROGRESS)
|
||||
{
|
||||
let imgLoad = imagesLoaded( this.container );
|
||||
if (!SETTINGS.MASONRYPROGRESS)
|
||||
{
|
||||
// When all images finish: redo mansonry layout
|
||||
imgLoad.on( 'always', function() { parent.msnry.layout(); } );
|
||||
}
|
||||
else
|
||||
{
|
||||
// As images load one by one: redo masonry layout
|
||||
imgLoad.on( 'progress', function() { parent.msnry.layout(); } );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.buildArticle = function(db, key)
|
||||
{
|
||||
let value = db[key];
|
||||
let itemClass = "article";
|
||||
if (SETTINGS.WIDEARTICLE)
|
||||
{
|
||||
if (main.util.isDefined(value.WIDE) && value.WIDE)
|
||||
{
|
||||
itemClass += " article-wide";
|
||||
}
|
||||
else if (main.util.isDefined(value.QOTE))
|
||||
{
|
||||
if (Array.isArray(value.QOTE) && value.QOTE.length > SETTINGS.AUTOWIDETRIGGER)
|
||||
{
|
||||
itemClass += " article-wide";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let onclickImage = ``;
|
||||
let articleIsImageType = (SETTINGS.SHOWIMAG && main.util.isType(value.TYPE, 'image'));
|
||||
if (articleIsImageType)
|
||||
{
|
||||
itemClass += " article-image";
|
||||
onclickImage = `onclick="main.grid.handleImageClick(event, this, '${value.FILE}');"
|
||||
style="cursor: pointer;"`;
|
||||
}
|
||||
|
||||
// ARTICLE
|
||||
let article = `<article class="${itemClass}" id="${SETTINGS.ARTICLEIDBASE + value.DIID}">`;
|
||||
if (main.util.isDefined(value.LINK))
|
||||
{
|
||||
var idUrl = "url";
|
||||
if (main.util.isDefined(value.SEEN) && value.SEEN === "true")
|
||||
{
|
||||
idUrl = "urlseen";
|
||||
}
|
||||
|
||||
// LINK START
|
||||
if (SETTINGS.SHOWLINK && !main.util.isObject(value.LINK))
|
||||
{
|
||||
// If this item has only one link then make the whole title the link
|
||||
article += `<a class="article-link" href="${String(value.LINK)}" id="${idUrl}">`;
|
||||
}
|
||||
}
|
||||
|
||||
// UPPER CONTENT START
|
||||
if (SETTINGS.SHOWUPPER)
|
||||
{
|
||||
let upperClass = 'article-containerupper';
|
||||
if (articleIsImageType)
|
||||
{
|
||||
upperClass = 'article-containerupper-image';
|
||||
}
|
||||
article += `<div class="${upperClass}" ${onclickImage}>`;
|
||||
|
||||
// TITLE
|
||||
if (SETTINGS.SHOWTITLE)
|
||||
{
|
||||
article += `<header class="article-title">${key.to_properCase()}</header>`;
|
||||
}
|
||||
|
||||
// LINK END
|
||||
if (SETTINGS.SHOWLINK && main.util.isDefined(value.LINK))
|
||||
{
|
||||
if (main.util.isObject(value.LINK))
|
||||
{
|
||||
for (let l = 0; l < value.LINK.length; l++)
|
||||
{
|
||||
article += `<a class="article-link" href="${String(value.LINK[l])}" id="${idUrl}">`;
|
||||
article += `<div class="article-linkcontainer"><div class="article-linkicon">${main.util.buildIcon('link')}</div><div class="article-linktitle">${main.util.extractRootDomain(value.LINK[l])}</div></div></a>`;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
article += `<div class="article-linkcontainer"><div class="article-linkicon">${main.util.buildIcon('link')}</div><div class="article-linktitle">${main.util.extractRootDomain(value.LINK)}</div></div></a>`;
|
||||
}
|
||||
}
|
||||
|
||||
// TYPE
|
||||
if (SETTINGS.SHOWTYPE && main.util.isDefined(value.TYPE))
|
||||
{
|
||||
|
||||
article += `<div class="article-typecontainer">`;
|
||||
for (let tc = 0; tc < value.TYPE.length; tc++)
|
||||
{
|
||||
article += `<a class="article-type" href='#type-${value.TYPE[tc]}'>`;
|
||||
article += main.util.buildIcon(value.TYPE[tc], value.TYPE[tc], 'article-typeicon');
|
||||
article += `</a>`;
|
||||
}
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
// UPPER CONTENT END
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
// LOWER CONTENT START
|
||||
if (SETTINGS.SHOWLOWER)
|
||||
{
|
||||
let lowerClass = 'article-containerlower';
|
||||
if (articleIsImageType)
|
||||
{
|
||||
lowerClass = 'article-containerlower-image';
|
||||
}
|
||||
article += `<div class="${lowerClass}" ${onclickImage}>`;
|
||||
|
||||
// TIME
|
||||
if (SETTINGS.SHOWDATE && main.util.isDefined(value.DATE))
|
||||
{
|
||||
article += this.doRow('date', value.DATE);
|
||||
}
|
||||
|
||||
// AUTHOR
|
||||
if (SETTINGS.SHOWAUTH && main.util.isDefined(value.AUTH))
|
||||
{
|
||||
for (var i = 0; i < value.AUTH.length; i++)
|
||||
{
|
||||
article += this.doRow('author', value.AUTH[i].to_properCase());
|
||||
}
|
||||
}
|
||||
|
||||
// TAGS
|
||||
if (SETTINGS.SHOWTAGS && main.util.isDefined(value.TAGS))
|
||||
{
|
||||
article += this.doRowArray('tags', value.TAGS, 'tag', false);
|
||||
}
|
||||
|
||||
// PROJECT
|
||||
if (SETTINGS.SHOWPROJ && main.util.isDefined(value.PROJ))
|
||||
{
|
||||
article += this.doRowArray('project', value.PROJ, 'proj', true);
|
||||
}
|
||||
|
||||
// TERM
|
||||
if (SETTINGS.SHOWTERM && main.util.isDefined(value.TERM))
|
||||
{
|
||||
article += this.doRowMulti('term', value.TERM);
|
||||
}
|
||||
|
||||
// NOTE
|
||||
if (SETTINGS.SHOWNOTE && main.util.isDefined(value.NOTE))
|
||||
{
|
||||
article += this.doRowMulti('note', value.NOTE);
|
||||
}
|
||||
|
||||
// QUOTE
|
||||
if (SETTINGS.SHOWQOTE && main.util.isDefined(value.QOTE))
|
||||
{
|
||||
article += this.doRowMulti('quote', value.QOTE);
|
||||
}
|
||||
|
||||
// PROGRESS
|
||||
if (SETTINGS.SHOWPROG && main.util.isDefined(value.PROG))
|
||||
{
|
||||
article += this.doRow('progress', value.PROG);
|
||||
}
|
||||
|
||||
// IMAGE - for non-image-type-article
|
||||
if (SETTINGS.SHOWIMAG
|
||||
&& !main.util.isType(value.TYPE, 'image')
|
||||
&& main.util.isDefined(value.FILE)
|
||||
&& main.util.isImage(value.FILE))
|
||||
{
|
||||
article += `<div class="image">`;
|
||||
article += `<img class="article-img" src="content/media/${value.FILE}" onclick="lightbox.load('content/media/${value.FILE}')">`;
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
// FILE
|
||||
if (SETTINGS.SHOWFILE && main.util.isDefined(value.FILE))
|
||||
{
|
||||
if (main.util.isObject(value.FILE))
|
||||
{
|
||||
for (var i = 0; i < value.FILE.length; i++)
|
||||
{
|
||||
article += this.doRow('file', `<a class="article-file-link" href="content/media/${value.FILE[i]}">${value.FILE[i]}</a>`, 'article-file');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// single
|
||||
article += this.doRow('file', `<a class="article-file-link" href="content/media/${value.FILE}">${value.FILE}</a>`, 'article-file');
|
||||
}
|
||||
}
|
||||
|
||||
// LOWER CONTENT END
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
// IMAGE - for image-type-article
|
||||
if (articleIsImageType
|
||||
&& main.util.isDefined(value.FILE)
|
||||
&& main.util.isImage(value.FILE))
|
||||
{
|
||||
article += `<div class="image">`;
|
||||
if (SETTINGS.SHOWOVERLAY)
|
||||
{
|
||||
article += `<div class="image-overlay"></div>`;
|
||||
}
|
||||
article += `<img class="article-image-img" src="content/media/${value.FILE}">`;
|
||||
article += `</div>`;
|
||||
}
|
||||
|
||||
article += `</article>`;
|
||||
return article;
|
||||
}
|
||||
|
||||
this.doRow = function(type, content, extraClass)
|
||||
{
|
||||
return `<div class="article-row${extraClass != undefined ? ' '+extraClass : ''}">
|
||||
${type != undefined ? main.util.buildIcon(type) : ''}
|
||||
<div class="article-rowtext">${content}</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
this.doRowArray = function(type, data, query, propercase)
|
||||
{
|
||||
let content = '';
|
||||
for (var i = 0; i < data.length; i++)
|
||||
{
|
||||
content += `<a class="article-taglink" href="#${query}-${data[i]}">${propercase == true ? data[i].to_properCase() : data[i]}</a>`;
|
||||
if (i + 1 !== data.length)
|
||||
{
|
||||
content += `, `;
|
||||
}
|
||||
}
|
||||
return this.doRow(type, content);
|
||||
}
|
||||
|
||||
this.doRowMulti = function(type, data)
|
||||
{
|
||||
let result = '';
|
||||
if (Array.isArray(data))
|
||||
{
|
||||
for (var i in data)
|
||||
{
|
||||
if (data[i].substring(0, 2) == "> ")
|
||||
{
|
||||
// New item
|
||||
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();
|
||||
}
|
||||
result += this.doRow(type, `<b>${titleSplit[0]}</b>: ${titleSplit[1]}`);
|
||||
}
|
||||
else
|
||||
{
|
||||
result += this.doRow(type, data[i].substring(2));
|
||||
}
|
||||
}
|
||||
else if (data[i].substring(0, 2) === "& ")
|
||||
{
|
||||
// New line in current item
|
||||
result += this.doRow(null, data[i].substring(2));
|
||||
}
|
||||
else if (data[i].substring(0, 2) == "- ")
|
||||
{
|
||||
// Bullet point
|
||||
result += this.doRow('dash', data[i].substring(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle unformatted
|
||||
result += this.doRow(type, data[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Handle not array
|
||||
result += this.doRow(type, data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
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
|
||||
lightbox.load(`content/media/${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
main.util.buildIcon = function(type, label, altClass)
|
||||
{
|
||||
if (label == undefined) { label = type; }
|
||||
let labelElem = label != null ? `title="${label}" ` : ``;
|
||||
let iconClass = altClass == undefined ? 'article-icon' : altClass;
|
||||
return `<i ${labelElem}class="${main.util.getIcon(type)} textIcon ${iconClass}"></i>`;
|
||||
}
|
||||
}
|
88
docs/logic/view/nav.js
Normal file
88
docs/logic/view/nav.js
Normal file
@ -0,0 +1,88 @@
|
||||
function Nav()
|
||||
{
|
||||
this.container = null;
|
||||
|
||||
this.install = function(container)
|
||||
{
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
this.display = function(value)
|
||||
{
|
||||
let navContent = ``;
|
||||
if (window.showAdd !== undefined && window.showAdd)
|
||||
{
|
||||
// ADD
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
navContent += `<a href='#add' class="nav-item">`;
|
||||
navContent += `<b>a</b>dd`;
|
||||
navContent += `</a>`;
|
||||
navContent += `</div>`;
|
||||
}
|
||||
|
||||
// TOTAL
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
navContent += `<a href='#' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${value.total}</div>`;
|
||||
navContent += `<i title="all" class="nav-itemicon fas fa-asterisk"></i>`;
|
||||
navContent += `</a>`;
|
||||
navContent += `</div>`;
|
||||
|
||||
// DONE
|
||||
if (SETTINGS.SHOWDONE)
|
||||
{
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
navContent += `<a href='#done-true' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${value.done}</div>`;
|
||||
navContent += `<i title="done" class="nav-itemicon fas fa-check"></i>`;
|
||||
navContent += `</a>`;
|
||||
navContent += `<a href='#done-false' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${value.total - value.done}</div>`;
|
||||
navContent += `<i title="to do" class="nav-itemicon fas fa-times"></i>`;
|
||||
navContent += `</a>`;
|
||||
navContent += `</div>`;
|
||||
}
|
||||
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
for (let ty = 0; ty < Math.min(value.types.length, SETTINGS.STATSNUMTYPE); ty++)
|
||||
{
|
||||
const type = value.types[ty][0];
|
||||
const count = value.types[ty][1];
|
||||
const icon = main.util.getIcon(type);
|
||||
navContent += `<a href='#type-${type}' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${count}</div>`;
|
||||
navContent += `<i title="${type}" class="nav-itemicon ${icon}"></i>`;
|
||||
navContent += `</a>`;
|
||||
}
|
||||
navContent += `</div>`;
|
||||
|
||||
// TERM
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
if (value.terms > 0)
|
||||
{
|
||||
navContent += `<a href='#term' class="nav-item">`;
|
||||
navContent += `<div class="nav-itemcount">${value.terms}</div>`;
|
||||
navContent += `<i title="terms" class="nav-itemicon fas fa-ribbon"></i>`;
|
||||
navContent += `</a>`;
|
||||
}
|
||||
navContent += `</div>`;
|
||||
|
||||
// TAGS
|
||||
navContent += `<div class="nav-itemgroup">`;
|
||||
if (value.tags.length > 0)
|
||||
{
|
||||
navContent += `<div class="nav-tagcontainer">`;
|
||||
navContent += `<i title="tags" class="nav-tagicon fas fa-tag"></i>`;
|
||||
for (var t = 0; t < Math.min(value.tags.length, SETTINGS.STATSNUMTAGS); t++)
|
||||
{
|
||||
navContent += `<a class="nav-tag" href='#tag-${value.tags[t][0]}'>`;
|
||||
navContent += `<div class="nav-tagcount">${value.tags[t][1]}</div>`;
|
||||
navContent += `<div class="nav-taglabel">${value.tags[t][0]}</div>`;
|
||||
navContent += `</a>`;
|
||||
}
|
||||
navContent += `</div>`;
|
||||
}
|
||||
navContent += `</div>`;
|
||||
this.container.innerHTML = navContent;
|
||||
}
|
||||
}
|
114
docs/logic/view/util.js
Normal file
114
docs/logic/view/util.js
Normal file
@ -0,0 +1,114 @@
|
||||
function Util()
|
||||
{
|
||||
this.getIcon = 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;
|
||||
case 'note': icon = 'fas fa-sticky-note'; break;
|
||||
case 'date': icon = 'fas fa-clock'; break;
|
||||
case 'author': icon = 'fas fa-user'; break;
|
||||
case 'tags': icon = 'fas fa-tag'; break;
|
||||
case 'project': icon = 'fas fa-leaf'; break;
|
||||
case 'progress': icon = 'fas fa-clock'; break;
|
||||
case 'file': icon = 'fas fa-folder-open'; break;
|
||||
case 'dash': icon = 'fas fa-caret-right'; break;
|
||||
case 'link': icon = 'fas fa-link'; break;
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
this.isDefined = function(value)
|
||||
{
|
||||
return (typeof value !== 'undefined');
|
||||
}
|
||||
|
||||
this.isObject = function(value)
|
||||
{
|
||||
return (typeof value == 'object');
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
// extracting the root domain here
|
||||
// if there is a subdomain
|
||||
if (arrLen > 2)
|
||||
{
|
||||
domain = splitArr[arrLen - 2] + '.' + splitArr[arrLen - 1];
|
||||
// check to see if it's using a Country Code Top Level Domain (ccTLD) (i.e. ".me.uk")
|
||||
if (splitArr[arrLen - 2].length === 2 && splitArr[arrLen - 1].length === 2)
|
||||
{
|
||||
// this is using a ccTLD
|
||||
domain = splitArr[arrLen - 3] + '.' + domain;
|
||||
}
|
||||
}
|
||||
return domain;
|
||||
}
|
||||
|
||||
// Source: https://stackoverflow.com/questions/8498592/extract-hostname-name-from-string
|
||||
this.extractHostname = function(url)
|
||||
{
|
||||
var hostname;
|
||||
// find & remove protocol (http, ftp, etc.) and get hostname
|
||||
|
||||
if (url.indexOf("://") > -1)
|
||||
{
|
||||
hostname = url.split('/')[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
hostname = url.split('/')[0];
|
||||
}
|
||||
|
||||
// find & remove port number
|
||||
hostname = hostname.split(':')[0];
|
||||
// find & remove "?"
|
||||
hostname = hostname.split('?')[0];
|
||||
|
||||
return hostname;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user