Improved hash handling wrapper
This commit is contained in:
parent
bca16a4784
commit
8967289631
|
@ -7,19 +7,22 @@ app.script = function(name, cback) {
|
|||
loadScript(name, file, cback);
|
||||
}
|
||||
|
||||
function scriptPageHandler(modname, cfg) {
|
||||
cfg['callback'] = function(args) {
|
||||
app.script(modname, function(ok) {
|
||||
if (!ok) return;
|
||||
eval(`app.${modname}`).load(args);
|
||||
});
|
||||
};
|
||||
app.hashHandlers.push(cfg);
|
||||
}
|
||||
|
||||
window.onload = function(e) {
|
||||
app.hashHandlers.push({'exact': '', 'callback': function(args) {
|
||||
app.script('pages.home', function(ok) {
|
||||
if (!ok) return;
|
||||
app.pages.home.load(args);
|
||||
});
|
||||
}});
|
||||
app.hashHandlers.push({'exact': 'meet', 'callback': function(args) {
|
||||
app.script('pages.meet', function(ok) {
|
||||
if (!ok) return;
|
||||
app.pages.meet.load(args);
|
||||
});
|
||||
}});
|
||||
scriptPageHandler('pages.home', { exact: '' });
|
||||
scriptPageHandler('pages.meet', { exact: 'meet' });
|
||||
scriptPageHandler('pages.crushes', { exact: 'crushes' });
|
||||
scriptPageHandler('pages.chat', { exact: 'chat' });
|
||||
window.onhashchange();
|
||||
}
|
||||
|
||||
window.onhashchange = function(e) {
|
||||
|
|
Loading…
Reference in New Issue