Add support for filtering by DONE.

This commit is contained in:
kor 2018-08-14 04:30:09 +12:00
parent 9bb671a93c
commit baf4b2f8b7
2 changed files with 63 additions and 2 deletions

View File

@ -50,6 +50,7 @@ function View()
this.display = function(db) this.display = function(db)
{ {
if (window.showAdd != undefined && window.showAdd) if (window.showAdd != undefined && window.showAdd)
{ {
main.add.setOverlay(false); main.add.setOverlay(false);
@ -328,7 +329,7 @@ function View()
menuContent += `<div class="menu-spacer"></div>`; menuContent += `<div class="menu-spacer"></div>`;
} }
// TYPE // TOTAL
menuContent += `<a href='#'>`; menuContent += `<a href='#'>`;
menuContent += `<div class="menu-item">`; menuContent += `<div class="menu-item">`;
menuContent += `<div class="count">${value.total}</div>`; menuContent += `<div class="count">${value.total}</div>`;
@ -336,6 +337,25 @@ function View()
menuContent += `</div>`; menuContent += `</div>`;
menuContent += `</a>`; menuContent += `</a>`;
// 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>`;
for (var ty = 0; ty < Math.min(value.types.length, SETTINGS.STATSNUMTYPE); ty++) for (var ty = 0; ty < Math.min(value.types.length, SETTINGS.STATSNUMTYPE); ty++)
{ {
if (value.types[ty][0] == 'article') if (value.types[ty][0] == 'article')

View File

@ -77,7 +77,6 @@ function Wrap()
{ {
// TYPE // TYPE
var tagDecoded = decodeURI(splitTarget[1]); var tagDecoded = decodeURI(splitTarget[1]);
var tempDatabase = {}
for (i = 0; i < this.keys.length; i++) for (i = 0; i < this.keys.length; i++)
{ {
let value = this.database[this.keys[i]]; let value = this.database[this.keys[i]];
@ -90,6 +89,38 @@ function Wrap()
} }
} }
} }
else if (splitTarget[0] == 'done')
{
// DONE
var doneValue = decodeURI(splitTarget[1]);
for (i = 0; i < this.keys.length; i++)
{
let value = this.database[this.keys[i]];
if (doneValue == 'true')
{
// true
if (typeof value.DONE !== 'undefined')
{
if (value.DONE == 'true')
{
tempDatabase[this.keys[i]] = this.database[this.keys[i]];
}
}
}
else
{
// false
if (typeof value.DONE === 'undefined')
{
tempDatabase[this.keys[i]] = this.database[this.keys[i]];
}
else if (value.DONE == false)
{
tempDatabase[this.keys[i]] = this.database[this.keys[i]];
}
}
}
}
} }
return tempDatabase; return tempDatabase;
} }
@ -104,6 +135,7 @@ function Wrap()
types: {}, types: {},
tags: {}, tags: {},
terms: 0, terms: 0,
done: 0
}; };
for (var i = 0; i < dbKeys.length; i++) for (var i = 0; i < dbKeys.length; i++)
@ -151,6 +183,15 @@ function Wrap()
stats.terms += count; stats.terms += count;
} }
// DONE
if (typeof db[dbKeys[i]].DONE !== 'undefined')
{
if (db[dbKeys[i]].DONE == 'true')
{
stats.done ++;
}
}
} }
// SORT TYPES, TAKE TOP X // SORT TYPES, TAKE TOP X