memex/docs/logic/main.js

29 lines
647 B
JavaScript
Raw Normal View History

2018-07-13 15:56:09 +00:00
function Main()
{
this.db = null;
this.view = null;
2018-07-13 15:56:09 +00:00
2018-07-15 14:23:07 +00:00
this.install = function()
{
this.db = new Wrap(DATABASE);
this.db.install();
this.view = new View();
this.view.install();
2018-07-15 14:23:07 +00:00
}
this.start = function()
{
2018-07-22 19:45:04 +00:00
this.load(window.document.location.hash);
this.view.stats(this.db.stats());
2018-07-15 14:23:07 +00:00
}
2018-07-22 19:45:04 +00:00
this.load = function(target)
2018-07-15 14:23:07 +00:00
{
2018-07-22 19:45:04 +00:00
target = target.substr(0,1) == "#" ? target.substr(1,target.length-1) : target;
target = target.trim();
var entries = this.db.filter(target);
2018-07-22 19:45:04 +00:00
this.view.display(entries);
2018-07-15 14:23:07 +00:00
}
2018-07-13 15:56:09 +00:00
}
2018-07-22 19:45:04 +00:00
window.addEventListener("hashchange", function() { main.load(window.document.location.hash); });