mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-12 16:13:58 -07:00
client side config uses localstorage instead of cookies
This commit is contained in:
parent
95a9a297bc
commit
347bcb0cf4
3 changed files with 5 additions and 136 deletions
45
UI/Config.js
45
UI/Config.js
|
@ -1,55 +1,20 @@
|
|||
"use strict";
|
||||
define(['app'], function () {
|
||||
|
||||
$.cookie.json = true;
|
||||
|
||||
NzbDrone.Config.SeriesViewStyle = function (value) {
|
||||
var key = 'seriesViewStyle';
|
||||
|
||||
if (value !== undefined) {
|
||||
NzbDrone.Config.SetValue(key, value);
|
||||
}
|
||||
else {
|
||||
return NzbDrone.Config.GetValue(key, 1);
|
||||
}
|
||||
};
|
||||
|
||||
NzbDrone.Config.GetValue = function (key, defaultValue) {
|
||||
var cookie = NzbDrone.Config.GetCookie();
|
||||
|
||||
if (!cookie) {
|
||||
var storeValue = localStorage.getItem(key);
|
||||
|
||||
if (!storeValue) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
var value = cookie[key];
|
||||
|
||||
if (value === undefined) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
else {
|
||||
return value;
|
||||
}
|
||||
return storeValue;
|
||||
};
|
||||
|
||||
NzbDrone.Config.SetValue = function (key, value) {
|
||||
var cookie = NzbDrone.Config.GetCookie();
|
||||
|
||||
if (!cookie) {
|
||||
cookie = {};
|
||||
}
|
||||
|
||||
console.log('Config: [{0}] => [{1}] '.format(key, value));
|
||||
|
||||
cookie[key] = value;
|
||||
NzbDrone.Config.SetCookie(cookie);
|
||||
localStorage.setItem(key, value);
|
||||
};
|
||||
|
||||
NzbDrone.Config.GetCookie = function () {
|
||||
return $.cookie('NzbDroneConfig');
|
||||
};
|
||||
|
||||
NzbDrone.Config.SetCookie = function (cookie) {
|
||||
$.cookie('NzbDroneConfig', cookie, { expires: 365, path: '/' });
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue