[Pkg-mozext-commits] [wot] 149/226: Fixed #54 The add-on still takes into account obsolete components to trigger Warning
David Prévot
taffit at moszumanska.debian.org
Fri May 1 00:35:45 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 f931b67e6ad882bcf3c505c1dae8dafdb78f4886
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Wed Sep 4 16:44:59 2013 +0300
Fixed #54 The add-on still takes into account obsolete components to trigger Warning
---
content/cache.js | 35 +++++++++++++++++-----------------
content/config.js | 1 -
content/core.js | 13 +++++++------
content/search.js | 56 +++++++++++++++++-------------------------------------
content/ui.js | 5 +++--
content/warning.js | 41 ++++++---------------------------------
6 files changed, 51 insertions(+), 100 deletions(-)
diff --git a/content/cache.js b/content/cache.js
index 26eef8e..8ea1d4c 100644
--- a/content/cache.js
+++ b/content/cache.js
@@ -260,20 +260,20 @@ var wot_cache =
this.set(name, "blacklists", "");
this.set(name, "votes", "");
- // FIXME: don't create redundant apps. Use only 0 and 4
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- this.set(name, "reputation_" + i, -1);
- this.set(name, "confidence_" + i, -1);
+ for (var i = 0, a = 0; a < WOT_COMPONENTS.length; ++i) {
+ a = WOT_COMPONENTS[i];
+ this.set(name, "reputation_" + a, -1);
+ this.set(name, "confidence_" + a, -1);
if (!pending) {
- this.set(name, "testimony_" + i, -1);
+ this.set(name, "testimony_" + a, -1);
}
- this.set(name, "inherited_" + i, 0);
- this.set(name, "lowered_" + i, 0);
+ this.set(name, "inherited_" + a, 0);
+ this.set(name, "lowered_" + a, 0);
}
} catch (e) {
- dump("wot_cache.create: failed with " + e + "\n");
+ wdump("wot_cache.create: failed with " + e);
}
},
@@ -295,16 +295,16 @@ var wot_cache =
this.remove(name, "blacklists");
this.remove(name, "votes");
- // FIXME: use WOT_COMPONTENTS here
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- this.remove(name, "reputation_" + i);
- this.remove(name, "confidence_" + i);
- this.remove(name, "testimony_" + i);
- this.remove(name, "inherited_" + i);
- this.remove(name, "lowered_" + i);
+ for (var i = 0, a = 0; i < WOT_COMPONENTS.length; ++i) {
+ a = WOT_COMPONENTS[i];
+ this.remove(name, "reputation_" + a);
+ this.remove(name, "confidence_" + a);
+ this.remove(name, "testimony_" + a);
+ this.remove(name, "inherited_" + a);
+ this.remove(name, "lowered_" + a);
}
} catch (e) {
- dump("wot_cache.destroy: failed with " + e + "\n");
+ wdump("wot_cache.destroy: failed with " + e);
}
},
@@ -525,6 +525,7 @@ var wot_cache =
add_question: function (hostname, target_node)
{
+ if (!target_node) return;
try {
var doc = target_node.ownerDocument;
var id_node = doc.getElementsByTagName(WOT_SERVICE_XML_QUERY_QUESTION_ID).item(0),
@@ -572,7 +573,7 @@ var wot_cache =
}
}
} catch(e) {
- wdump("Failed to extract Question data from XML");
+ wdump("Failed to extract Question data from XML " + e);
}
},
diff --git a/content/config.js b/content/config.js
index 3bcb603..b557a6d 100644
--- a/content/config.js
+++ b/content/config.js
@@ -80,7 +80,6 @@ const WOT_AS_LEVELS = {
};
/* Applications */
-const WOT_APPLICATIONS = 5;
const WOT_COMPONENTS = [0, 4];
/* Search */
diff --git a/content/core.js b/content/core.js
index 22ccac4..ff075ad 100644
--- a/content/core.js
+++ b/content/core.js
@@ -352,13 +352,14 @@ var wot_core =
var blocked = "target=" + encodeURIComponent(hostname);
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- if (!wot_prefs["show_application_" + i]) {
+ for (var i = 0, a = 0; i < WOT_COMPONENTS.length; ++i) {
+ a = WOT_COMPONENTS[i];
+ if (!wot_prefs["show_application_" + a]) {
continue;
}
var param = "";
- var reason = wot_warning.getwarningtype(hostname, i, true);
+ var reason = wot_warning.getwarningtype(hostname, a, true);
if (reason == WOT_REASON_TESTIMONY) {
param += "y";
@@ -366,8 +367,8 @@ var wot_core =
param += "r";
}
- var r = wot_cache.get(hostname, "reputation_" + i),
- x = wot_cache.get(hostname, "excluded_" + i);
+ var r = wot_cache.get(hostname, "reputation_" + a),
+ x = wot_cache.get(hostname, "excluded_" + a);
r = x ? -2 : r; // if excluded, then set level to -2
@@ -377,7 +378,7 @@ var wot_core =
param += "a";
}
- blocked += "&" + i + "=" + param;
+ blocked += "&" + a + "=" + param;
}
blocked = "?" + encodeURIComponent(btoa(blocked)) + "#" +
diff --git a/content/search.js b/content/search.js
index c93fb00..76da492 100644
--- a/content/search.js
+++ b/content/search.js
@@ -993,15 +993,16 @@ var wot_search =
target: target
};
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- rv["reputation_" + i] =
- wot_cache.get(target, "reputation_" + i);
- rv["confidence_" + i] =
- wot_cache.get(target, "confidence_" + i);
- rv["testimony_" + i] =
- wot_cache.get(target, "testimony_" + i);
- rv["excluded_" + i] =
- wot_cache.get(target, "excluded_" + i);
+ for (var i = 0, a = 0; i < WOT_COMPONENTS.length; ++i) {
+ a = WOT_COMPONENTS[i];
+ rv["reputation_" + a] =
+ wot_cache.get(target, "reputation_" + a);
+ rv["confidence_" + a] =
+ wot_cache.get(target, "confidence_" + a);
+ rv["testimony_" + a] =
+ wot_cache.get(target, "testimony_" + a);
+ rv["excluded_" + a] =
+ wot_cache.get(target, "excluded_" + a);
}
return rv;
@@ -1187,36 +1188,13 @@ var wot_search =
var r = wot_cache.get(name, "reputation_0");
- // TODO: respect "Parental control" setting and take the worst reputation between 0 and 4 in this case
-
- // TODO: remove below since we don't have this type of logic in settings any more
-// if (wot_prefs.search_type == WOT_SEARCH_TYPE_OPTIMIZED) {
-// for (var i = 1; i < WOT_APPLICATIONS; ++i) {
-// if (wot_prefs["search_ignore_" + i]) {
-// continue;
-// }
-//
-// if (wot_warning.getwarningtype(name, i, false) !=
-// WOT_WARNING_NONE) {
-// var a = wot_cache.get(name, "reputation_" + i);
-// if (r > a) {
-// r = a;
-// }
-// }
-// }
-// } else if (wot_prefs.search_type == WOT_SEARCH_TYPE_WORST) {
-// for (var i = 1; i < WOT_APPLICATIONS; ++i) {
-// if (!wot_prefs["show_application_" + i] ||
-// wot_prefs["search_ignore_" + i]) {
-// continue;
-// }
-//
-// var a = wot_cache.get(name, "reputation_" + i);
-// if (a >= 0 && a < r) {
-// r = a;
-// }
-// }
-// }
+ // respect "Parental control" setting and use the worst reputation between app0 and app4
+ if (wot_prefs.warning_level_4 > 0) {
+ var r_app4 = wot_cache.get(name, "reputation_4");
+ if (r_app4 >= 0 && r_app4 < r) {
+ r = r_app4;
+ }
+ }
return r;
} catch (e) {
diff --git a/content/ui.js b/content/ui.js
index 95d7a7b..c303e95 100644
--- a/content/ui.js
+++ b/content/ui.js
@@ -71,8 +71,9 @@ var wot_status = {
/* Set status and description */
var rep_l, rep, r_level, description, testimonies = false;
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- if (wot_cache.get(wot_core.hostname, "testimony_" + i) >= 0) {
+ for (var i = 0, a = 0; i < WOT_COMPONENTS.length; ++i) {
+ a = WOT_COMPONENTS[i];
+ if (wot_cache.get(wot_core.hostname, "testimony_" + a) >= 0) {
testimonies = true;
break;
}
diff --git a/content/warning.js b/content/warning.js
index 4560b0e..46e009b 100644
--- a/content/warning.js
+++ b/content/warning.js
@@ -193,8 +193,9 @@ var wot_warning =
// decides whether we must block page or just warn
var blocking = false;
try {
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- if (wot_prefs["warning_type_" + i] == WOT_WARNING_BLOCK) {
+ for (var i = 0, a = 0; i < WOT_COMPONENTS.length; ++i) {
+ a = WOT_COMPONENTS[i];
+ if (wot_prefs["warning_type_" + a] == WOT_WARNING_BLOCK) {
blocking = true;
break;
}
@@ -260,8 +261,9 @@ var wot_warning =
return result;
}
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- var type = wot_warning.getwarningtype(hostname, i, false);
+ for (var i = 0, a = 0; i < WOT_COMPONENTS.length; ++i) {
+ a = WOT_COMPONENTS[i];
+ var type = wot_warning.getwarningtype(hostname, a, false);
if (type > result) {
result = type;
@@ -288,37 +290,6 @@ var wot_warning =
return result;
},
- dontwarn: function(url)
- {
- try {
- var hostname = wot_url.gethostname(url);
-
- if (!hostname || !wot_cache.isok(hostname)) {
- return;
- }
-
- var testified = false;
-
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- var type = wot_warning.getwarningtype(hostname, i, false);
-
- if (type != WOT_WARNING_NONE) {
- wot_cache.set(hostname, "testimony_" + i,
- (WOT_MIN_REPUTATION_4 + WOT_MIN_REPUTATION_5) / 2);
- wot_cache.set(hostname, "pending", true);
- wot_core.pending[hostname] = true;
- testified = true;
- }
- }
-
- if (testified) {
- wot_core.update();
- }
- } catch (e) {
- dump("wot_warning.dontwarn: failed with " + e + "\n");
- }
- },
-
domcontentloaded: function(event)
{
try {
--
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