Reformatted variable name.

This commit is contained in:
Ajay Ramachandran
2020-01-09 13:17:26 -05:00
parent 4ba82f6e00
commit a8fc22eae8

18
SB.js
View File

@@ -9,7 +9,7 @@ Map.prototype.toJSON = function() {
class MapIO { class MapIO {
constructor(id) { constructor(id) {
this.id = id; this.id = id;
this.map = SB.localconfig[this.id]; this.map = SB.localConfig[this.id];
} }
set(key, value) { set(key, value) {
@@ -83,20 +83,20 @@ function decodeStoredItem(data) {
function configProxy() { function configProxy() {
chrome.storage.onChanged.addListener((changes, namespace) => { chrome.storage.onChanged.addListener((changes, namespace) => {
for (key in changes) { for (key in changes) {
SB.localconfig[key] = decodeStoredItem(changes[key].newValue); SB.localConfig[key] = decodeStoredItem(changes[key].newValue);
} }
}); });
var handler = { var handler = {
set: function(obj, prop, value) { set: function(obj, prop, value) {
SB.localconfig[prop] = value; SB.localConfig[prop] = value;
chrome.storage.sync.set({ chrome.storage.sync.set({
[prop]: encodeStoredItem(value) [prop]: encodeStoredItem(value)
}); });
}, },
get: function(obj, prop) { get: function(obj, prop) {
let data = SB.localconfig[prop]; let data = SB.localConfig[prop];
if(data instanceof Map) data = new MapIO(prop); if(data instanceof Map) data = new MapIO(prop);
return obj[prop] || data; return obj[prop] || data;
@@ -110,14 +110,14 @@ function configProxy() {
function fetchConfig() { function fetchConfig() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
chrome.storage.sync.get(null, function(items) { chrome.storage.sync.get(null, function(items) {
SB.localconfig = items; // Data is ready SB.localConfig = items; // Data is ready
resolve(); resolve();
}); });
}); });
} }
function migrateOldFormats() { // Convert sponsorTimes format function migrateOldFormats() { // Convert sponsorTimes format
for (key in SB.localconfig) { for (key in SB.localConfig) {
if (key.startsWith("sponsorTimes") && key !== "sponsorTimes" && key !== "sponsorTimesContributed") { if (key.startsWith("sponsorTimes") && key !== "sponsorTimes" && key !== "sponsorTimesContributed") {
SB.config.sponsorTimes.set(key.substr(12), SB.config[key]); SB.config.sponsorTimes.set(key.substr(12), SB.config[key]);
delete SB.config[key]; delete SB.config[key];
@@ -158,15 +158,15 @@ function resetConfig() {
function convertJSON() { function convertJSON() {
Object.keys(SB.defaults).forEach(key => { Object.keys(SB.defaults).forEach(key => {
SB.localconfig[key] = decodeStoredItem(SB.localconfig[key], key); SB.localConfig[key] = decodeStoredItem(SB.localConfig[key], key);
}); });
} }
// Add defaults // Add defaults
function addDefaults() { function addDefaults() {
Object.keys(SB.defaults).forEach(key => { Object.keys(SB.defaults).forEach(key => {
if(!SB.localconfig.hasOwnProperty(key)) { if(!SB.localConfig.hasOwnProperty(key)) {
SB.localconfig[key] = SB.defaults[key]; SB.localConfig[key] = SB.defaults[key];
} }
}); });
}; };