Skip to content

Commit

Permalink
[embedlite-components] Rename wrong comment in EmbedPrefService.js an…
Browse files Browse the repository at this point in the history
…d refactoring property name. Fixes JB#51971

Add correct module description. Rename short property names for setprefs method, "v" to "value", "n" to "name".
Rewrite the "for" loop for an object to be more readable.
  • Loading branch information
atatarov committed Nov 12, 2020
1 parent 201a792 commit 24e1f54
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions jscomps/EmbedPrefService.js
Expand Up @@ -12,7 +12,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
Services.scriptloader.loadSubScript("chrome://embedlite/content/Logger.js");

// -----------------------------------------------------------------------
// Download Manager UI
// Interface for requesting information on prefs values ​​and setting them
// -----------------------------------------------------------------------

function EmbedPrefService()
Expand Down Expand Up @@ -111,7 +111,7 @@ EmbedPrefService.prototype = {
}
case "embedui:clearprefs": {
let prefs = JSON.parse(aData).prefs;
for (var i = 0; i < prefs.length; i++) {
for (var i in prefs) {
Services.prefs.clearUserPref(prefs[i]);
}
break;
Expand All @@ -133,19 +133,19 @@ EmbedPrefService.prototype = {
}
case "embedui:setprefs": {
let prefs = JSON.parse(aData).prefs;
for (var i = 0; i < prefs.length; i++) {
switch (typeof(prefs[i].v)) {
for (var i in prefs) {
switch (typeof(prefs[i].value)) {
case "string":
Services.prefs.setCharPref(prefs[i].n, prefs[i].v);
Services.prefs.setCharPref(prefs[i].name, prefs[i].value);
break;
case "number":
Services.prefs.setIntPref(prefs[i].n, prefs[i].v);
Services.prefs.setIntPref(prefs[i].name, prefs[i].value);
break;
case "boolean":
Services.prefs.setBoolPref(prefs[i].n, prefs[i].v);
Services.prefs.setBoolPref(prefs[i].name, prefs[i].value);
break;
default:
throw new Error("Unexpected value type: " + typeof(prefs[i].v));
throw new Error("Unexpected value type: " + typeof(prefs[i].value));
}
}
break;
Expand Down

0 comments on commit 24e1f54

Please sign in to comment.