parent
0916c8b8d1
commit
24c77b4047
@ -1,37 +1,42 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
define(['app'], function () {
|
define(
|
||||||
|
[
|
||||||
|
'app'
|
||||||
|
], function () {
|
||||||
|
|
||||||
NzbDrone.Config = {
|
NzbDrone.Config = {
|
||||||
Events: {
|
Events: {
|
||||||
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
|
ConfigUpdatedEvent: 'ConfigUpdatedEvent'
|
||||||
},
|
},
|
||||||
Keys : {
|
Keys : {
|
||||||
DefaultQualityProfileId: 'DefaultQualityProfileId'
|
DefaultQualityProfileId: 'DefaultQualityProfileId'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
NzbDrone.Config.GetValue = function (key, defaultValue) {
|
NzbDrone.Config.GetValue = function (key, defaultValue) {
|
||||||
|
|
||||||
var storeValue = localStorage.getItem(key);
|
var storeValue = localStorage.getItem(key);
|
||||||
|
|
||||||
if (!storeValue) {
|
if (!storeValue) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return storeValue.toString();
|
return storeValue.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
NzbDrone.Config.SetValue = function (key, value) {
|
NzbDrone.Config.SetValue = function (key, value) {
|
||||||
|
|
||||||
console.log('Config: [{0}] => [{1}] '.format(key, value));
|
console.log('Config: [{0}] => [{1}] '.format(key, value));
|
||||||
|
|
||||||
if (NzbDrone.Config.GetValue(key) === value.toString()) {
|
if (NzbDrone.Config.GetValue(key) === value.toString()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage.setItem(key, value);
|
localStorage.setItem(key, value);
|
||||||
NzbDrone.vent.trigger(NzbDrone.Config.Events.ConfigUpdatedEvent, {key: key, value: value});
|
NzbDrone.vent.trigger(NzbDrone.Config.Events.ConfigUpdatedEvent, {key: key, value: value});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
});
|
return NzbDrone.Config;
|
||||||
|
|
||||||
|
});
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
var statusText = $.ajax({
|
var statusText = $.ajax({
|
||||||
type : "GET",
|
type : "GET",
|
||||||
url : 'api/system/status',
|
url : '/api/system/status',
|
||||||
async: false,
|
async: false
|
||||||
}).responseText;
|
}).responseText;
|
||||||
|
|
||||||
window.ServerStatus = JSON.parse(statusText);
|
window.ServerStatus = JSON.parse(statusText);
|
||||||
|
@ -1,34 +1,39 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
define(['app', 'Shared/Toolbar/Radio/RadioButtonView', 'Config'], function () {
|
define(
|
||||||
NzbDrone.Shared.Toolbar.RadioButtonCollectionView = Backbone.Marionette.CollectionView.extend({
|
[
|
||||||
className: 'btn-group',
|
'app',
|
||||||
itemView : NzbDrone.Shared.Toolbar.RadioButtonView,
|
'Shared/Toolbar/Radio/RadioButtonView',
|
||||||
|
'Config'
|
||||||
|
], function (App, RadioButtonView, Config) {
|
||||||
|
NzbDrone.Shared.Toolbar.RadioButtonCollectionView = Backbone.Marionette.CollectionView.extend({
|
||||||
|
className: 'btn-group',
|
||||||
|
itemView : NzbDrone.Shared.Toolbar.RadioButtonView,
|
||||||
|
|
||||||
attributes: {
|
attributes: {
|
||||||
'data-toggle': 'buttons-radio'
|
'data-toggle': 'buttons-radio'
|
||||||
},
|
},
|
||||||
|
|
||||||
initialize: function (options) {
|
initialize: function (options) {
|
||||||
this.menu = options.menu;
|
this.menu = options.menu;
|
||||||
|
|
||||||
if (this.menu.storeState) {
|
if (this.menu.storeState) {
|
||||||
this.setActive();
|
this.setActive();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
setActive: function () {
|
setActive: function () {
|
||||||
var storedKey = NzbDrone.Config.GetValue(this.menu.menuKey, this.menu.defaultAction);
|
var storedKey = Config.GetValue(this.menu.menuKey, this.menu.defaultAction);
|
||||||
|
|
||||||
this.collection.each(function (model) {
|
this.collection.each(function (model) {
|
||||||
if (model.get('key').toLocaleLowerCase() === storedKey.toLowerCase()) {
|
if (model.get('key').toLocaleLowerCase() === storedKey.toLowerCase()) {
|
||||||
model.set('active', true);
|
model.set('active', true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
model.set('active, false');
|
model.set('active, false');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in new issue