2013-10-09 04:43:41 +03:00
|
|
|
'use strict';
|
|
|
|
define(
|
|
|
|
[
|
2013-11-14 06:38:30 +03:00
|
|
|
'vent',
|
2013-10-09 04:43:41 +03:00
|
|
|
'AppLayout',
|
|
|
|
'marionette',
|
|
|
|
'Shared/NotFoundView'
|
2013-11-14 06:38:30 +03:00
|
|
|
], function (vent, AppLayout, Marionette, NotFoundView) {
|
2013-10-09 04:43:41 +03:00
|
|
|
return Marionette.AppRouter.extend({
|
|
|
|
|
2013-11-14 06:38:30 +03:00
|
|
|
initialize: function () {
|
|
|
|
this.listenTo(vent, vent.Events.ServerUpdated, this._onServerUpdated);
|
|
|
|
},
|
|
|
|
|
2013-10-09 04:43:41 +03:00
|
|
|
showNotFound: function () {
|
|
|
|
this.setTitle('Not Found');
|
2013-11-14 06:38:30 +03:00
|
|
|
this.showMainRegion(new NotFoundView(this));
|
2013-10-09 04:43:41 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
setTitle: function (title) {
|
|
|
|
if (title.toLocaleLowerCase() === 'nzbdrone') {
|
2013-11-11 07:09:11 +03:00
|
|
|
document.title = 'NzbDrone';
|
2013-10-09 04:43:41 +03:00
|
|
|
}
|
|
|
|
else {
|
2013-11-11 07:09:11 +03:00
|
|
|
document.title = title + ' - NzbDrone';
|
2013-10-09 04:43:41 +03:00
|
|
|
}
|
2013-11-14 06:38:30 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
_onServerUpdated: function () {
|
|
|
|
this.pendingUpdate = true;
|
|
|
|
},
|
|
|
|
|
|
|
|
showMainRegion: function (view) {
|
|
|
|
if (this.pendingUpdate) {
|
|
|
|
window.location.reload();
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
//AppLayout
|
|
|
|
AppLayout.mainRegion.show(view);
|
|
|
|
}
|
2013-10-09 04:43:41 +03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|