szurubooru/public_html/js/Bootstrap.js

35 lines
1,017 B
JavaScript
Raw Normal View History

2014-08-31 23:22:56 +02:00
var App = App || {};
App.Bootstrap = function(auth, router, util, promise, presenterManager) {
promise.wait(
auth.tryLoginFromCookie(),
presenterManager.init())
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);
2014-09-08 22:02:28 +02:00
window.alert('Fatal authentication error: ' + response.json.error);
2014-08-31 23:22:56 +02:00
});
});
function startRouting() {
try {
router.start();
} catch (err) {
console.log(err);
}
}
};
App.DI.registerSingleton('bootstrap', ['auth', 'router', 'util', 'promise', 'presenterManager'], App.Bootstrap);
2014-09-08 22:02:28 +02:00
App.DI.registerManual('jQuery', function() { return window.$; });
2014-10-02 23:44:04 +02:00
App.DI.registerManual('pathJs', function() { return window.pathjs; });
2014-09-08 22:02:28 +02:00
App.DI.registerManual('_', function() { return window._; });
App.DI.registerManual('mousetrap', function() { return window.Mousetrap; });
2014-10-05 20:22:45 +02:00
App.DI.registerManual('marked', function() { return window.marked; });
2014-09-01 00:22:17 +02:00
App.DI.get('bootstrap');