[Pkg-mozext-commits] [wot] 121/226: Fixed settings page issue (search rules)
David Prévot
taffit at moszumanska.debian.org
Fri May 1 00:35:42 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository wot.
commit 0ebc3ecd6b805e59fa203dcd9cae5f33d5fa1258
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Fri Aug 23 16:02:53 2013 +0300
Fixed settings page issue (search rules)
---
content/api.js | 2 +-
content/config.js | 18 ++++----
content/settings.js | 120 +++++++++++++++++-----------------------------------
3 files changed, 48 insertions(+), 92 deletions(-)
diff --git a/content/api.js b/content/api.js
index 01ae1ed..de31e28 100644
--- a/content/api.js
+++ b/content/api.js
@@ -1412,7 +1412,7 @@ var wot_api_comments = {
pref_pending_name = _this.PENDING_REMOVAL_SID + target;
// try to restore pending submission first
- var state_json = wot_prefs.getChar(pref_pending_name);
+ var state_json = wot_prefs.getChar(pref_pending_name, null);
var state = state_json ? JSON.parse(state_json) : {
target: target,
tries: 0
diff --git a/content/config.js b/content/config.js
index b312ef9..d97bb60 100644
--- a/content/config.js
+++ b/content/config.js
@@ -260,14 +260,14 @@ const wot_prefs_bool = [
[ "my_cookies", true ],
[ "prefetch", false ],
[ "private_disable", false ],
+ [ "search_ignore_0", false ],
[ "search_ignore_4", true ],
[ "search_scripts", true ],
[ "show_application_0", true ],
- [ "show_application_1", false ],
- [ "show_application_2", false ],
+ [ "show_application_1", false ],
+ [ "show_application_2", false ],
[ "show_application_3", false ],
[ "show_application_4", true ],
-// [ "show_application_5", false ],
[ "show_search_popup", true ],
[ "use_search_level", false ],
[ "ninja_donuts", false ],
@@ -276,11 +276,11 @@ const wot_prefs_bool = [
[ "warning_unknown_2", false ],
[ "warning_unknown_3", false ],
[ "warning_unknown_4", false ],
-// [ "warning_unknown_5", false ],
[ "feedback_enabled", true ],
[ "feedback_optedout", false ],
[ "show_fulllist", false ],
- [ "super_showtestimonies", false ] // show my rating on the search popup at bottom corners of the popup
+ [ "super_showtestimonies", false ], // show my rating on the search popup at bottom corners of the popup
+ [ "settingsui_parental", false ] // this is should not be considered by the add-on. Only to render prefs on the settings page
];
const wot_prefs_char = [
@@ -294,10 +294,12 @@ const wot_prefs_char = [
[ "partner", "" ],
[ "status_level", "" ],
[ "update_checked", "0" ],
- [ "warning_opacity", "" ],
+ [ "warning_opacity", "0.7" ],
[ "witness_id", "" ],
[ "witness_key", "" ],
- [ "feedback_lasttimeasked", "" ]
+ [ "feedback_lasttimeasked", "" ],
+ [ "settingsui_warnlevel", "normal" ], // this is should not be considered by the add-on. Only to render prefs on the settings page
+ [ "settingsui_searchlevel", "normal" ]
];
const wot_prefs_int = [
@@ -314,13 +316,11 @@ const wot_prefs_int = [
[ "warning_level_2", WOT_DEFAULT_WARNING_LEVEL ],
[ "warning_level_3", WOT_DEFAULT_WARNING_LEVEL ],
[ "warning_level_4", 0 ],
-// [ "warning_level_5", WOT_DEFAULT_WARNING_LEVEL ],
[ "warning_type_0", WOT_WARNING_DOM ],
[ "warning_type_1", WOT_WARNING_DOM ],
[ "warning_type_2", WOT_WARNING_DOM ],
[ "warning_type_3", WOT_WARNING_NONE ],
[ "warning_type_4", WOT_WARNING_NONE ]
-// [ "warning_type_5", WOT_WARNING_NONE ]
];
/* Search rules */
diff --git a/content/settings.js b/content/settings.js
index a914289..b2b0196 100644
--- a/content/settings.js
+++ b/content/settings.js
@@ -205,31 +205,23 @@ var wot_settings =
}
},
- loadinputs: function(content)
- {
+ loadinputs: function(content) {
try {
var inputs = content.getElementsByTagName("input");
for (var i = 0; i < inputs.length; ++i) {
- var preftype = inputs[i].getAttribute("wotpref");
+ var preftype = inputs[i].getAttribute("wotpref"),
+ id, value, type;
- if (!preftype) {
- continue;
- }
-
- var id = inputs[i].getAttribute("id");
+ if (!preftype) continue;
- if (!id || this.disallowed[id]) {
- continue;
- }
-
- var type = inputs[i].getAttribute("type");
+ id = inputs[i].getAttribute("id");
+ if (!id || this.disallowed[id]) continue;
- if (!type) {
- continue;
- }
-
- var value = null;
+ type = inputs[i].getAttribute("type");
+ if (!type) continue;
+
+ value = null;
if (preftype == "bool") {
value = wot_prefs.getBool(id, null);
@@ -238,49 +230,37 @@ var wot_settings =
} else if (preftype == "string") {
value = wot_prefs.getChar(id, null);
} else {
- dump("wot_settings.loadinputs: invalid preftype " +
- preftype + "\n");
+ wdump("wot_settings.loadinputs: invalid preftype " + preftype);
continue;
}
- if (value == null) {
- continue;
- }
+ if (value == null) continue;
- if ((type == "checkbox" || type == "radio") &&
- preftype == "bool") {
+ if ((type == "checkbox" || type == "radio") && preftype == "bool") {
inputs[i].checked = value;
} else {
inputs[i].setAttribute("value", value.toString());
}
}
return true;
+
} catch (e) {
dump("wot_settings.loadinputs: failed with " + e + "\n");
}
return false;
},
- loadsearch: function(content)
- {
+ loadsearch: function(content) {
try {
- var search = content.getElementById("wotsearch");
+ var search = content.getElementById("search-services");
- if (!search) {
- return true;
- }
+ if (!search) return true;
- var preftype = search.getAttribute("wotpref");
+ var rules = [],
+ j = 0,
+ i = 0;
- if (!preftype || preftype != "input") {
- return false;
- }
-
- var rules = [];
-
- var j = 0;
-
- for (var i in wot_search.rules) {
+ for (i in wot_search.rules) {
if (!wot_search.rules[i].display ||
!wot_search.rules[i].display.length) {
continue;
@@ -289,55 +269,31 @@ var wot_settings =
}
rules.sort();
+ var search_rules = [];
+
for (j = 0; j < rules.length; ++j) {
- for (var i in wot_search.rules) {
- if (wot_search.rules[i].display != rules[j]) {
+ for (i in wot_search.rules) {
+ var item = wot_search.rules[i];
+ if (item.display != rules[j]) {
continue;
}
- var id = WOT_SEARCH + "." + wot_search.rules[i].rule +
- "." + WOT_SEARCH_ENABLED;
-
- var input = content.createElement("input");
-
- if (!input) {
- break;
- }
-
- input.setAttribute("id", id);
- input.setAttribute("type", "checkbox");
- input.setAttribute("wotpref", "bool");
- input.checked = wot_search.rules[i].enabled;
-
- var label = content.createElement("label");
-
- if (!label) {
- break;
- }
-
- label.setAttribute("for", id);
-
- var text = content.createTextNode(wot_search.rules[i].display);
-
- if (!text) {
- break;
- }
-
- var br = content.createElement("br");
-
- if (!br) {
- break;
- }
-
- label.appendChild(text);
- search.appendChild(input);
- search.appendChild(label);
- search.appendChild(br);
+ var id = WOT_SEARCH + "-" + item.rule;
+
+ search_rules.push({
+ id: id,
+ display: item.display,
+ name: item.rule,
+ state: item.enabled
+ });
}
}
+
+// wdump(JSON.stringify(search_rules));
+ wot_settings.addscript(content, "build_search_rules('"+JSON.stringify(search_rules)+"')");
return true;
} catch (e) {
- dump("wot_settings.loadsearch: failed with " + e + "\n");
+ wdump("wot_settings.loadsearch: failed with " + e);
}
return false;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/wot.git
More information about the Pkg-mozext-commits
mailing list