mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-20 13:23:34 -07:00
WebUI: Use modern class syntax to create LocalPreferences class
LocalPreferences class is now created using modern class syntax (minimal changes to remove Mootools bits). In addition, I removed redundant suffix from class name. PR #21780.
This commit is contained in:
parent
71f83cf9ba
commit
3ec645674a
2 changed files with 9 additions and 9 deletions
|
@ -32,28 +32,28 @@ window.qBittorrent ??= {};
|
||||||
window.qBittorrent.LocalPreferences ??= (() => {
|
window.qBittorrent.LocalPreferences ??= (() => {
|
||||||
const exports = () => {
|
const exports = () => {
|
||||||
return {
|
return {
|
||||||
LocalPreferencesClass: LocalPreferencesClass
|
LocalPreferences: LocalPreferences
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const LocalPreferencesClass = new Class({
|
class LocalPreferences {
|
||||||
get: (key, defaultValue) => {
|
get(key, defaultValue) {
|
||||||
const value = localStorage.getItem(key);
|
const value = localStorage.getItem(key);
|
||||||
return ((value === null) && (defaultValue !== undefined))
|
return ((value === null) && (defaultValue !== undefined))
|
||||||
? defaultValue
|
? defaultValue
|
||||||
: value;
|
: value;
|
||||||
},
|
}
|
||||||
|
|
||||||
set: (key, value) => {
|
set(key, value) {
|
||||||
try {
|
try {
|
||||||
localStorage.setItem(key, value);
|
localStorage.setItem(key, value);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
remove: (key) => {
|
remove(key) {
|
||||||
try {
|
try {
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key);
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ window.qBittorrent.LocalPreferences ??= (() => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
return exports();
|
return exports();
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -99,7 +99,7 @@ window.qBittorrent.Dialog ??= (() => {
|
||||||
})();
|
})();
|
||||||
Object.freeze(window.qBittorrent.Dialog);
|
Object.freeze(window.qBittorrent.Dialog);
|
||||||
|
|
||||||
const LocalPreferences = new window.qBittorrent.LocalPreferences.LocalPreferencesClass();
|
const LocalPreferences = new window.qBittorrent.LocalPreferences.LocalPreferences();
|
||||||
|
|
||||||
let saveWindowSize = () => {};
|
let saveWindowSize = () => {};
|
||||||
let loadWindowWidth = () => {};
|
let loadWindowWidth = () => {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue