2013-01-23 01:23:27 +00:00
|
|
|
|
/// <reference path="JsLibraries/jquery.js" />
|
2013-01-22 23:58:08 +00:00
|
|
|
|
/// <reference path="JsLibraries/underscore.js" />
|
2013-01-25 17:54:45 +00:00
|
|
|
|
/// <reference path="JsLibraries/sugar.js" />
|
2013-01-22 23:58:08 +00:00
|
|
|
|
/// <reference path="JsLibraries/backbone.js" />
|
2013-01-25 19:04:37 +00:00
|
|
|
|
/// <reference path="JsLibraries/handlebars.js" />
|
2013-01-23 05:48:22 +00:00
|
|
|
|
/// <reference path="JsLibraries/backbone.modelbinder.js" />
|
2013-01-25 17:54:45 +00:00
|
|
|
|
/// <reference path="JsLibraries/backbone.mutators.js" />
|
|
|
|
|
/// <reference path="JsLibraries/backbone.shortcuts.js" />
|
2013-01-22 23:58:08 +00:00
|
|
|
|
/// <reference path="JsLibraries/backbone.marionette.js" />
|
|
|
|
|
/// <reference path="JsLibraries/backbone.marionette.extend.js" />
|
2013-01-27 02:14:42 +00:00
|
|
|
|
/// <reference path="JsLibraries/backbone.marionette.viewswapper.js" />
|
2013-01-23 05:48:22 +00:00
|
|
|
|
/// <reference path="JsLibraries/backbone.modelbinder.js" />
|
2013-01-22 23:58:08 +00:00
|
|
|
|
/// <reference path="JsLibraries/bootstrap.js" />
|
2013-02-10 03:42:44 +00:00
|
|
|
|
/// <reference path="Shared/ModalRegion.js" />
|
2013-01-22 23:58:08 +00:00
|
|
|
|
|
2013-01-30 06:52:31 +00:00
|
|
|
|
if (typeof console === undefined) {
|
2013-01-23 00:34:00 +00:00
|
|
|
|
window.console = { log: function () { } };
|
|
|
|
|
}
|
2013-01-22 23:58:08 +00:00
|
|
|
|
|
|
|
|
|
NzbDrone = new Backbone.Marionette.Application();
|
2013-01-31 22:40:51 +00:00
|
|
|
|
NzbDrone.Series = {};
|
2013-02-09 10:04:18 +00:00
|
|
|
|
NzbDrone.Series.Index = {};
|
2013-01-31 22:40:51 +00:00
|
|
|
|
NzbDrone.AddSeries = {};
|
|
|
|
|
NzbDrone.AddSeries.New = {};
|
|
|
|
|
NzbDrone.AddSeries.Existing = {};
|
|
|
|
|
NzbDrone.AddSeries.RootFolders = {};
|
|
|
|
|
NzbDrone.Quality = {};
|
|
|
|
|
NzbDrone.Shared = {};
|
2013-01-22 05:40:26 +00:00
|
|
|
|
|
2013-01-27 02:14:42 +00:00
|
|
|
|
/*
|
2013-01-25 19:04:37 +00:00
|
|
|
|
_.templateSettings = {
|
|
|
|
|
interpolate: /\{\{([\s\S]+?)\}\}/g
|
|
|
|
|
};
|
2013-01-27 02:14:42 +00:00
|
|
|
|
*/
|
2013-01-25 19:04:37 +00:00
|
|
|
|
|
2013-01-23 05:48:22 +00:00
|
|
|
|
NzbDrone.ModelBinder = new Backbone.ModelBinder();
|
2013-01-23 05:03:57 +00:00
|
|
|
|
|
2013-01-22 05:40:26 +00:00
|
|
|
|
NzbDrone.Constants = {
|
2013-01-27 03:04:15 +00:00
|
|
|
|
ApiRoot: '/api'
|
2013-01-22 05:40:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
NzbDrone.Events = {
|
2013-01-30 06:52:31 +00:00
|
|
|
|
DisplayInMainRegion: 'DisplayInMainRegion'
|
2013-01-22 05:40:26 +00:00
|
|
|
|
};
|
|
|
|
|
|
2013-01-26 20:05:08 +00:00
|
|
|
|
NzbDrone.Controller = Backbone.Marionette.Controller.extend({
|
2013-01-22 05:40:26 +00:00
|
|
|
|
|
2013-01-29 02:00:35 +00:00
|
|
|
|
addSeries: function (action, query) {
|
|
|
|
|
NzbDrone.mainRegion.show(new NzbDrone.AddSeries.AddSeriesLayout(this, action, query));
|
2013-01-26 20:05:08 +00:00
|
|
|
|
},
|
2013-01-22 05:40:26 +00:00
|
|
|
|
|
2013-02-09 10:04:18 +00:00
|
|
|
|
series: function (action, query) {
|
|
|
|
|
NzbDrone.mainRegion.show(new NzbDrone.Series.IndexLayout(this, action, query));
|
|
|
|
|
},
|
2013-01-22 05:40:26 +00:00
|
|
|
|
|
2013-01-26 20:05:08 +00:00
|
|
|
|
notFound: function () {
|
|
|
|
|
alert('route not found');
|
2013-01-28 18:06:54 +00:00
|
|
|
|
}
|
2013-01-26 20:05:08 +00:00
|
|
|
|
});
|
2013-01-22 05:40:26 +00:00
|
|
|
|
|
2013-01-25 00:02:53 +00:00
|
|
|
|
NzbDrone.Router = Backbone.Marionette.AppRouter.extend({
|
2013-01-22 05:40:26 +00:00
|
|
|
|
|
|
|
|
|
controller: new NzbDrone.Controller(),
|
|
|
|
|
// "someMethod" must exist at controller.someMethod
|
|
|
|
|
appRoutes: {
|
2013-02-13 06:32:17 +00:00
|
|
|
|
'series': 'series',
|
2013-02-09 10:04:18 +00:00
|
|
|
|
'series/index': 'series',
|
2013-01-30 06:52:31 +00:00
|
|
|
|
'series/add': 'addSeries',
|
|
|
|
|
'series/add/:action(/:query)': 'addSeries',
|
|
|
|
|
':whatever': 'notFound'
|
2013-01-22 05:40:26 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.addInitializer(function (options) {
|
|
|
|
|
|
2013-01-30 06:52:31 +00:00
|
|
|
|
console.log('starting application');
|
2013-01-22 05:40:26 +00:00
|
|
|
|
|
2013-02-10 03:42:44 +00:00
|
|
|
|
NzbDrone.registerHelpers();
|
|
|
|
|
|
2013-01-22 05:40:26 +00:00
|
|
|
|
NzbDrone.addRegions({
|
2013-01-30 06:52:31 +00:00
|
|
|
|
mainRegion: '#main-region',
|
2013-02-10 03:42:44 +00:00
|
|
|
|
notificationRegion: '#notification-region',
|
|
|
|
|
modalRegion: ModalRegion
|
2013-01-22 05:40:26 +00:00
|
|
|
|
});
|
|
|
|
|
|
2013-01-25 00:02:53 +00:00
|
|
|
|
NzbDrone.Router = new NzbDrone.Router();
|
2013-01-22 05:40:26 +00:00
|
|
|
|
Backbone.history.start();
|
2013-02-10 03:42:44 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
NzbDrone.registerHelpers = function() {
|
|
|
|
|
Handlebars.registerHelper("formatStatus", function (status, monitored) {
|
|
|
|
|
if (!monitored) return '<i class="icon-pause grid-icon" title="Not Monitored"></i>';
|
|
|
|
|
if (status === 'Continuing') return '<i class="icon-play grid-icon" title="Continuing"></i>';
|
|
|
|
|
|
|
|
|
|
return '<i class="icon-stop grid-icon" title="Ended"></i>';
|
|
|
|
|
});
|
|
|
|
|
}
|