[Pkg-mozext-commits] [wot] 87/226: tiny code cleaning
David Prévot
taffit at moszumanska.debian.org
Fri May 1 00:35:37 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 57b71e0670261221597d201acc949a29b6cbfe20
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Thu Jul 25 13:55:57 2013 +0300
tiny code cleaning
---
content/config.js | 14 +++++++-------
content/core.js | 41 ++++++-----------------------------------
content/ui.js | 34 +++-------------------------------
content/warning.js | 2 +-
4 files changed, 17 insertions(+), 74 deletions(-)
diff --git a/content/config.js b/content/config.js
index 1d40ad5..943065d 100644
--- a/content/config.js
+++ b/content/config.js
@@ -35,13 +35,13 @@ const WOT_MIN_REPUTATION_3 = 40;
const WOT_MIN_REPUTATION_2 = 20;
const WOT_REPUTATIONLEVELS = [
- { name: "rx", min: -2 },
- { name: "r0", min: -1 },
- { name: "r1", min: 0 },
- { name: "r2", min: WOT_MIN_REPUTATION_2 },
- { name: "r3", min: WOT_MIN_REPUTATION_3 },
- { name: "r4", min: WOT_MIN_REPUTATION_4 },
- { name: "r5", min: WOT_MIN_REPUTATION_5 }
+ { level: "x", name: "rx", min: -2 },
+ { level: "0", name: "r0", min: -1 },
+ { level: "1", name: "r1", min: 0 },
+ { level: "2", name: "r2", min: WOT_MIN_REPUTATION_2 },
+ { level: "3", name: "r3", min: WOT_MIN_REPUTATION_3 },
+ { level: "4", name: "r4", min: WOT_MIN_REPUTATION_4 },
+ { level: "5", name: "r5", min: WOT_MIN_REPUTATION_5 }
];
/* Confidence values */
diff --git a/content/core.js b/content/core.js
index a21e4bf..3fa1d6e 100644
--- a/content/core.js
+++ b/content/core.js
@@ -366,23 +366,12 @@ var wot_core =
param += "r";
}
- var r = wot_cache.get(hostname, "reputation_" + i);
-
- if (wot_cache.get(hostname, "excluded_" + i)) {
- param += "x";
- } else if (r >= WOT_MIN_REPUTATION_5) {
- param += "5";
- } else if (r >= WOT_MIN_REPUTATION_4) {
- param += "4";
- } else if (r >= WOT_MIN_REPUTATION_3) {
- param += "3";
- } else if (r >= WOT_MIN_REPUTATION_2) {
- param += "2";
- } else if (r >= 0) {
- param += "1";
- } else {
- param += "0";
- }
+ var r = wot_cache.get(hostname, "reputation_" + i),
+ x = wot_cache.get(hostname, "excluded_" + i);
+
+ r = x ? -2 : r; // if excluded, then set level to -2
+
+ param += wot_util.get_level(WOT_REPUTATIONLEVELS, r).level;
if (wot_prefs.accessible) {
param += "a";
@@ -716,24 +705,6 @@ var wot_core =
return this.force_https ? WOT_SERVICE_SECURE : WOT_SERVICE_NORMAL;
},
- get_level: function(r) {
- if (r >= WOT_MIN_REPUTATION_5) {
- return 5;
- } else if (r >= WOT_MIN_REPUTATION_4) {
- return 4;
- } else if (r >= WOT_MIN_REPUTATION_3) {
- return 3;
- } else if (r >= WOT_MIN_REPUTATION_2) {
- return 2;
- } else if (r >= 0) {
- return 1;
- } else if (r == -1){
- return 0;
- } else {
- return "x";
- }
- },
-
clean_search_rules: function () {
// removes search rules from preferences
wot_prefs.deleteBranch(WOT_SEARCH);
diff --git a/content/ui.js b/content/ui.js
index 9c82f3d..c61d206 100644
--- a/content/ui.js
+++ b/content/ui.js
@@ -83,20 +83,7 @@ var wot_status = {
status = "excluded";
description = "";
} else {
- if (reputation >= WOT_MIN_REPUTATION_5) {
- status = "5";
- } else if (reputation >= WOT_MIN_REPUTATION_4) {
- status = "4";
- } else if (reputation >= WOT_MIN_REPUTATION_3) {
- status = "3";
- } else if (reputation >= WOT_MIN_REPUTATION_2) {
- status = "2";
- } else if (reputation >= 0) {
- status = "1";
- } else {
- status = "0";
- }
-
+ status = wot_util.get_level(WOT_REPUTATIONLEVELS, reputation).level;
description = wot_util.getstring("description_rating_" + status);
}
@@ -512,23 +499,8 @@ var wot_ui = {
geticonurl: function(r, size, plain)
{
- var image = "r0";
-
- if (r >= WOT_MIN_REPUTATION_5) {
- image = "r5";
- } else if (r >= WOT_MIN_REPUTATION_4) {
- image = "r4";
- } else if (r >= WOT_MIN_REPUTATION_3) {
- image = "r3";
- } else if (r >= WOT_MIN_REPUTATION_2) {
- image = "r2";
- } else if (r >= 0) {
- image = "r1";
- } else if (r < -1) {
- image = "rx";
- }
-
- var base = "chrome://wot/skin/fusion/";
+ var image = wot_util.get_level(WOT_REPUTATIONLEVELS, r).name,
+ base = "chrome://wot/skin/fusion/";
if (r >= -1 && wot_prefs.accessible) {
base += "accessible/";
diff --git a/content/warning.js b/content/warning.js
index 40edd94..7bf2f84 100644
--- a/content/warning.js
+++ b/content/warning.js
@@ -378,7 +378,7 @@ var wot_warning =
}
- var r_level = wot_core.get_level(r);
+ var r_level = wot_util.get_level(WOT_REPUTATIONLEVELS, r).level;
if (r_level >= 0) {
replaces.push([ "RATING" + i, "r" + r_level ]);
--
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