Added type filtering.

This commit is contained in:
kor 2018-07-16 17:53:23 +12:00
parent 162927592e
commit 0d4bb2a405
2 changed files with 31 additions and 4 deletions

View File

@ -1106,8 +1106,7 @@ TUDOR MONASTERY FARM
LINK : https://www.youtube.com/watch?v=t1ERDYjsHBg LINK : https://www.youtube.com/watch?v=t1ERDYjsHBg
TYPE : video TYPE : video
DATE : 12018-07-14 DATE : 12018-07-14
SEEN : false SEEN : true
PROG : Episode 04
TAGS : history TAGS : history
CLIMATE CHANGE IN POST TRUTH CLIMATE CHANGE IN POST TRUTH

View File

@ -41,6 +41,8 @@ function Main()
this.load = function(target = "home") this.load = function(target = "home")
{ {
console.log('load');
target = target.substr(0,1) == "#" ? target.substr(1,target.length-1) : target target = target.substr(0,1) == "#" ? target.substr(1,target.length-1) : target
target = target.trim() == "" ? "home" : target target = target.trim() == "" ? "home" : target
@ -70,8 +72,11 @@ function Main()
else else
{ {
var splitTarget = target.split("-"); var splitTarget = target.split("-");
console.log('split: ' + splitTarget[0]);
if (splitTarget[0] == 'tag') if (splitTarget[0] == 'tag')
{ {
// TAG
console.log('Display tag \'' + splitTarget[1] + '\''); console.log('Display tag \'' + splitTarget[1] + '\'');
var tempDatabase = {} var tempDatabase = {}
@ -101,7 +106,30 @@ function Main()
} }
else if (splitTarget[0] == 'type') else if (splitTarget[0] == 'type')
{ {
console.log('type'); // TYPE
console.log('Display type \'' + splitTarget[1] + '\'');
var tempDatabase = {}
for (i = 0; i < this.keys.length; i++)
{
let value = this.database[this.keys[i]];
if (typeof value.TYPE !== 'undefined')
{
if (value.TYPE == splitTarget[1])
{
tempDatabase[this.keys[i]] = this.database[this.keys[i]];
}
}
}
this.grid.innerHTML = '';
this.displayEntries(tempDatabase);
if (this.useMasonry)
{
this.msnry.reloadItems();
this.msnry.layout();
}
} }
} }
} }
@ -193,7 +221,7 @@ function Main()
if (typeof value.TYPE !== 'undefined') if (typeof value.TYPE !== 'undefined')
{ {
entry += `<div id="type">`; entry += `<div id="type">`;
entry += `<a href='#type:${String(value.TYPE)}'>`; entry += `<a href='#type-${String(value.TYPE)}'>`;
if (value.TYPE == 'article') if (value.TYPE == 'article')
{ {
entry += `<i class="far fa-newspaper"></i>`; entry += `<i class="far fa-newspaper"></i>`;