szurubooru/public_html/js/Bootstrap.js

31 lines
662 B
JavaScript
Raw Normal View History

2014-08-31 23:22:56 +02:00
var App = App || {};
2014-09-04 18:06:25 +02:00
App.Bootstrap = function(auth, router, util, promise) {
2014-09-07 09:30:48 +02:00
util.initPresenter('topNavigationPresenter');
2014-08-31 23:22:56 +02:00
2014-09-04 18:06:25 +02:00
promise.wait(auth.tryLoginFromCookie())
2014-08-31 23:22:56 +02:00
.then(startRouting)
2014-09-04 18:06:25 +02:00
.fail(function(error) {
promise.wait(auth.loginAnonymous())
2014-08-31 23:22:56 +02:00
.then(startRouting)
2014-09-04 18:06:25 +02:00
.fail(function(response) {
2014-08-31 23:22:56 +02:00
console.log(response);
alert('Fatal authentication error: ' + response.json.error);
});
});
function startRouting() {
try {
router.start();
} catch (err) {
console.log(err);
}
}
};
App.DI.registerSingleton('bootstrap', App.Bootstrap);
App.DI.registerManual('jQuery', function() { return $; });
2014-09-01 00:22:17 +02:00
App.DI.get('bootstrap');