mirror of
https://github.com/TangentFoxy/memex.git
synced 2024-11-22 04:54:23 +00:00
Remove all promises.
This commit is contained in:
parent
0a3d0f794b
commit
90375587ac
@ -44,10 +44,7 @@ function Main()
|
||||
|
||||
this.start = function()
|
||||
{
|
||||
this.wrap.start(DATABASE)
|
||||
.then((db) =>
|
||||
{
|
||||
this.articles = db;
|
||||
this.articles = this.wrap.start(DATABASE);
|
||||
seer.note('process db');
|
||||
|
||||
let stats = this.wrap.stats(this.articles);
|
||||
@ -55,34 +52,34 @@ function Main()
|
||||
this.nav.display(stats);
|
||||
seer.note('render stats');
|
||||
|
||||
return this.load();
|
||||
})
|
||||
.catch((error) =>
|
||||
this.load();
|
||||
}
|
||||
|
||||
this.test = function()
|
||||
{
|
||||
console.log('ERROR: ' + error, error);
|
||||
});
|
||||
this.grid.clear();
|
||||
document.querySelector('.loading-wave').style.display = 'inline-block';
|
||||
setTimeout(this.load(), 1000);
|
||||
}
|
||||
|
||||
this.load = function()
|
||||
{
|
||||
// this.grid.clear();
|
||||
// document.querySelector('.loading-wave').style.display = 'inline-block';
|
||||
|
||||
this.resetPage();
|
||||
this.updateQuery();
|
||||
|
||||
let filtered = this.wrap.filter(this.queryCur, this.articles);
|
||||
seer.note('filter db');
|
||||
|
||||
this.grid.buildAllArticles(filtered)
|
||||
.then((html) =>
|
||||
{
|
||||
let html = this.grid.buildAllArticles(filtered)
|
||||
seer.note('build html');
|
||||
|
||||
this.grid.newDisplay(html);
|
||||
this.grid.display(html);
|
||||
seer.report();
|
||||
|
||||
document.querySelector('.loading-wave').style.display = 'none';
|
||||
return seer.report();
|
||||
}).catch((error) =>
|
||||
{
|
||||
console.log('ERROR: ' + error, error);
|
||||
});
|
||||
}
|
||||
|
||||
this.resetPage = function()
|
||||
@ -107,4 +104,4 @@ function Main()
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("hashchange", function() { main.load(); });
|
||||
window.addEventListener("hashchange", function() { main.test(); });
|
@ -24,15 +24,19 @@ function Grid()
|
||||
}
|
||||
}
|
||||
|
||||
this.newDisplay = function(html)
|
||||
this.clear = function()
|
||||
{
|
||||
this.container.innerHTML = '';
|
||||
}
|
||||
|
||||
this.display = function(html)
|
||||
{
|
||||
if (window.showAdd !== undefined && window.showAdd)
|
||||
{
|
||||
main.add.setOverlay(false);
|
||||
}
|
||||
|
||||
document.querySelector('main').innerHTML = html;
|
||||
|
||||
this.container.innerHTML = html;
|
||||
seer.note('render html');
|
||||
|
||||
// LAYOUT
|
||||
@ -55,59 +59,23 @@ function Grid()
|
||||
imgLoad.on( 'progress', function() { parent.msnry.layout(); } );
|
||||
}
|
||||
}
|
||||
|
||||
seer.note('masonry layout');
|
||||
}
|
||||
}
|
||||
|
||||
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]], 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.buildAllArticles = function(db)
|
||||
{
|
||||
return new Promise(function(resolve, reject)
|
||||
let dbKeys = Object.keys(db);
|
||||
let html = '';
|
||||
for (var i = 0; i < dbKeys.length; i++)
|
||||
{
|
||||
html += this.buildArticle(db[dbKeys[i]], dbKeys[i]);
|
||||
}
|
||||
return html;
|
||||
}
|
||||
|
||||
this.buildArticle = function(value, key)
|
||||
{
|
||||
// let value = db[key];
|
||||
let itemClass = "article";
|
||||
if (SETTINGS.WIDEARTICLE)
|
||||
{
|
||||
@ -451,16 +419,4 @@ function Grid()
|
||||
lightbox.load(`content/media/${file}`);
|
||||
}
|
||||
}
|
||||
|
||||
let dbKeys = Object.keys(db);
|
||||
let i = 0;
|
||||
let html = '';
|
||||
while (i < dbKeys.length)
|
||||
{
|
||||
html += buildArticle(db[dbKeys[i]], dbKeys[i]);
|
||||
i++;
|
||||
}
|
||||
resolve(html);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
function Wrap()
|
||||
{
|
||||
this.start = function(data)
|
||||
{
|
||||
return new Promise(function(resolve, reject)
|
||||
{
|
||||
this.commaSplit = function(data)
|
||||
{
|
||||
@ -50,8 +48,7 @@ function Wrap()
|
||||
database[keys[i]].DIID = i;
|
||||
}
|
||||
|
||||
resolve(database);
|
||||
});
|
||||
return database;
|
||||
}
|
||||
|
||||
this.filter = function(target, db)
|
||||
|
Loading…
Reference in New Issue
Block a user