Refactor clean up new promise setup.

This commit is contained in:
kor 2018-11-06 22:28:12 +13:00
parent 36e2dca38c
commit 19125d1bc4
3 changed files with 29 additions and 35 deletions

View File

@ -386,7 +386,7 @@ article:hover .article-containerlower-image {
}
/* TITLE */
.article-title {
.article-title {
color: var(--color-item);
font-size: var(--size-font-title);
text-decoration: none;

View File

@ -21,7 +21,7 @@ function Main()
{
this.util = new Util();
this.database = new Wrap();
// this.database.install(DATABASE);
this.database.install(DATABASE);
this.grid = new Grid();
this.grid.install(
document.querySelector('main'),
@ -50,28 +50,36 @@ function Main()
this.timeStore = this.curTime;
}
this.resetPage = function()
{
lightbox.close();
document.activeElement.blur();
}
this.updateQuery = function()
{
let target = window.document.location.hash;
if (this.queryCur !== 'add')
{
this.queryPrev = this.queryCur;
}
target = target.substr(0,1) === "#" ? target.substr(1,target.length-1) : target;
this.queryCur = target.trim();
if (window.location.hash != this.queryCur)
{
window.location.hash = this.queryCur;
}
}
this.start = function()
{
this.timediff('load all js files');
this.database.start(new Indental(DATABASE).parse())
this.database.start()
.then((db) => {
this.timediff('process db');
let target = window.document.location.hash;
lightbox.close();
document.activeElement.blur();
if (this.queryCur !== 'add')
{
this.queryPrev = this.queryCur;
}
target = target.substr(0,1) === "#" ? target.substr(1,target.length-1) : target;
this.queryCur = target.trim();
if (window.location.hash != this.queryCur)
{
window.location.hash = this.queryCur;
}
this.resetPage();
this.updateQuery();
this.timediff('prep query \'' + this.queryCur + '\'');
return this.database.filter(db, this.queryCur);

View File

@ -9,8 +9,9 @@ function Wrap()
this.keys = Object.keys(this.database);
}
this.start = function(data)
this.start = function()
{
let data = this.database;
return new Promise(function(resolve, reject)
{
let commaSplit = function(data)
@ -188,7 +189,6 @@ function Wrap()
}
}
}
return tempDatabase;
}
@ -289,18 +289,4 @@ function Wrap()
return stats;
}
this.commaSplit = function(data)
{
if (data !== undefined)
{
var result = data.split(",");
for (var t = 0; t < result.length; t++)
{
result[t] = result[t].trim().toLowerCase();
}
return result;
}
return data;
}
}