mirror of
https://github.com/TangentFoxy/memex.git
synced 2024-11-22 04:54:23 +00:00
46 lines
946 B
JavaScript
46 lines
946 B
JavaScript
function Main()
|
|
{
|
|
// REFERENCE
|
|
this.db = null;
|
|
this.view = null;
|
|
|
|
this.install = function()
|
|
{
|
|
this.db = new DataWrap(DATABASE);
|
|
this.db.install();
|
|
|
|
this.view = new ViewMasonry();
|
|
this.view.install();
|
|
}
|
|
|
|
this.start = function()
|
|
{
|
|
this.load(window.document.location.hash == "" ? 'home' : window.document.location.hash);
|
|
this.view.doStats(this.db.getStats());
|
|
}
|
|
|
|
this.load = function(target = "home")
|
|
{
|
|
target = target.substr(0,1) == "#" ? target.substr(1,target.length-1) : target
|
|
target = target.trim() == "" ? "home" : target
|
|
|
|
if (target === '')
|
|
{
|
|
window.history.replaceState(undefined, undefined, "#" + target)
|
|
}
|
|
else
|
|
{
|
|
window.location.hash = target;
|
|
}
|
|
|
|
var entries = this.db.filter(target);
|
|
this.view.doEntries(entries);
|
|
}
|
|
}
|
|
|
|
window.addEventListener("hashchange", navigate);
|
|
|
|
function navigate()
|
|
{
|
|
main.load(window.document.location.hash);
|
|
} |