2014-08-31 23:22:56 +02:00
|
|
|
var App = App || {};
|
|
|
|
|
2014-09-11 13:59:12 +02:00
|
|
|
App.Bootstrap = function(auth, router, util, promise, presenterManager) {
|
2014-09-03 09:10:26 +02:00
|
|
|
|
2014-10-05 16:30:26 +02:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-09-11 13:59:12 +02:00
|
|
|
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._; });
|
2014-09-12 19:33:27 +02:00
|
|
|
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');
|