[Pkg-mozext-commits] [wot] 85/226: Finished search popup; fixed bug with decrypting normalised name;
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 53687ae961c02b4a7fc81684aaa3922232c7d23b
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Wed Jul 24 16:42:37 2013 +0300
Finished search popup; fixed bug with decrypting normalised name;
---
content/cache.js | 13 +-
content/categories.js | 130 ++++++++++++-
content/config.js | 41 +++-
content/popup.js | 351 ++++++++++++++++++++--------------
content/util.js | 71 ++++++-
locale/en-US/wot.properties | 4 +-
locale/ru-RU/wot.properties | 8 +-
skin/b/bubl_speech_c_150.png | Bin 0 -> 2844 bytes
skin/b/bubl_speech_l_150.png | Bin 0 -> 3499 bytes
skin/b/bubl_speech_r_150.png | Bin 0 -> 3404 bytes
skin/b/confidence_150dpi.png | Bin 0 -> 17768 bytes
skin/b/donuts_150.png | Bin 0 -> 25005 bytes
skin/include/popup.css | 446 ++++++++++++++++++++++++++++++++++---------
13 files changed, 818 insertions(+), 246 deletions(-)
diff --git a/content/cache.js b/content/cache.js
index 00e037d..130fc6c 100644
--- a/content/cache.js
+++ b/content/cache.js
@@ -327,8 +327,17 @@ var wot_cache =
this.create(name);
}
- var normalized_attr = target.attributes.getNamedItem(WOT_SERVICE_XML_QUERY_TARGET_NORMAL);
- this.set(name, "normalized", normalized_attr ? normalized_attr.value : "");
+ var normalized_attr = target.attributes.getNamedItem(WOT_SERVICE_XML_QUERY_TARGET_NORMAL),
+ normalized = null;
+
+ if (normalized_attr && normalized_attr.value != null) {
+ normalized = wot_crypto.decrypt(normalized_attr.value, nonce, -1); // index = 0 since nonce already has it
+ if (!/^[\x00-\xFF]*$/.test(normalized)) {
+ normalized = null;
+ }
+ }
+
+ this.set(name, "normalized", normalized);
var child = target.firstChild;
diff --git a/content/categories.js b/content/categories.js
index 2e79fd4..de67d40 100644
--- a/content/categories.js
+++ b/content/categories.js
@@ -22,7 +22,7 @@ var wot_categories = {
PREF_CATEGORY: "category",
PREF_GROUPINGS: "groupings",
- category_threshold: 3, // confidence level to show a category as identified
+ CATEGORY_THRESHOLD: 3, // confidence level to show a category as identified
inited: false,
loading: false,
categories: {},
@@ -151,8 +151,134 @@ var wot_categories = {
} catch (e) {
wdump("wot_search.init_categories(): failed with " + e);
}
- }
+ },
+
+ get_category: function (cat_id) {
+ var cid = String(cat_id),
+ cat = {};
+ if (this.categories && this.categories[cid]) {
+ cat = this.categories[cid];
+ cat.id = cid;
+ }
+ return cat;
+ },
+
+ get_category_name: function (cat_id, is_short) {
+ var cat = this.get_category(cat_id);
+ var text = is_short ? cat.shorttext : cat.text;
+ return wot_util.htmlescape(text ? text : cat.text); // if no short name is known, return full name
+ },
+
+ get_category_css: function (cat_id) {
+ var type = wot_util.htmlescape(this.get_category(cat_id).type);
+ return type !== null ? "c-" + type : "";
+ },
+
+ target_categories: function (target) {
+ // return categories reported by API server (both identified and votes) taking them from cache.
+ // Result is an Object.
+
+ var count = wot_cache.get(target, "categories", 0),
+ cats = {},
+ attrs_list = [
+ WOT_SERVICE_XML_QUERY_CATEGORY_NAME,
+ WOT_SERVICE_XML_QUERY_CATEGORY_GROUP,
+ WOT_SERVICE_XML_QUERY_CATEGORY_C,
+ WOT_SERVICE_XML_QUERY_CATEGORY_I,
+ WOT_SERVICE_XML_QUERY_CATEGORY_VOTE
+ ];
+
+ for (var i = 0, slot=""; i < count; i++) {
+ var cat_obj = {}, val = null;
+ for (var a = 0; a < attrs_list.length; a++) {
+ slot = "category_" + i + "_" + attrs_list[a];
+ val = wot_cache.get(target, slot, null);
+ if (val !== null) {
+ cat_obj[attrs_list[a]] = val;
+ }
+ }
+ if (!wot_util.isEmpty(cat_obj)) {
+ cat_obj['id'] = cat_obj.name;
+ cats[cat_obj.name] = cat_obj;
+ }
+ }
+
+// wdump("target_categories:: " + JSON.stringify(cats));
+ return cats;
+ },
+
+ select_identified: function (target_cats) {
+ // Returns categories identified by community (unsorted!)
+ var res = {};
+ for (var i in target_cats) {
+ var cat = target_cats[i];
+ if (cat.c >= this.CATEGORY_THRESHOLD) res[i] = cat;
+ }
+// wdump("select_identified:: " + JSON.stringify(res));
+
+ return res;
+ },
+
+ rearrange_categories: function (cats_object) {
+ // sorts the categories given as object and return two arrays of category objects ordered by confidence
+ var sort_array = [],
+ cs_array = [];
+
+ if (cats_object) {
+
+ try {
+ // Make the array of objects (categories)
+ for (var key in cats_object) {
+ var cat = this.get_category(key);
+ cats_object[key].id = key;
+ cats_object[key].cs = cat.cs;
+ cats_object[key].group = cat.group;
+ sort_array.push(cats_object[key]);
+ }
+
+ // Sort the array
+ sort_array.sort(function(a, b) {
+ if (a.c != b.c) { // try to sort by confidence level
+ return a.c - b.c
+ } else { // otherwise try to sort by group id
+ if (a.group != b.group) {
+ return a.group - b.group;
+ } else {
+ return a.id > b.id;
+ }
+ }
+ });
+ sort_array.reverse();
+ } catch (e) {
+ wdump("ERROR: wot_categories.rearrange_categories(): Failed to rearrange categories / 1", e);
+ }
+
+ var alltogether = sort_array.slice(0);
+
+ try {
+ // filter out Child Safety cats to other array
+ for (var i=sort_array.length-1; i>=0; i--) {
+ if (sort_array[i].cs) {
+ cs_array.push(sort_array.splice(i, 1)[0]);
+ }
+ }
+ cs_array.reverse();
+ } catch (e) {
+ wdump("ERROR: wot_categories.rearrange_categories(): Failed to rearrange categories / 2", e);
+ }
+ }
+
+ var res = {
+ all: alltogether,
+ trustworthy: sort_array,
+ childsafety: cs_array
+ };
+
+// wdump("rearrange_categories:: " + JSON.stringify(res));
+
+ return res;
+ }
};
wot_modules.push({ name: "wot_categories", obj: wot_categories });
\ No newline at end of file
diff --git a/content/config.js b/content/config.js
index d5bc2e4..1d40ad5 100644
--- a/content/config.js
+++ b/content/config.js
@@ -34,6 +34,16 @@ const WOT_MIN_REPUTATION_4 = 60;
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 }
+ ];
+
/* Confidence values */
const WOT_MAX_CONFIDENCE = 100;
const WOT_MIN_CONFIDENCE_5 = 45;
@@ -42,6 +52,16 @@ const WOT_MIN_CONFIDENCE_3 = 23;
const WOT_MIN_CONFIDENCE_2 = 12;
const WOT_MIN_CONFIDENCE_1 = 6;
+const WOT_CONFIDENCELEVELS = [
+ { name: "cx", min: -2 },
+ { name: "c0", min: -1 },
+ { name: "c1", min: WOT_MIN_CONFIDENCE_1 },
+ { name: "c2", min: WOT_MIN_CONFIDENCE_2 },
+ { name: "c3", min: WOT_MIN_CONFIDENCE_3 },
+ { name: "c4", min: WOT_MIN_CONFIDENCE_4 },
+ { name: "c5", min: WOT_MIN_CONFIDENCE_5 }
+ ];
+
/* Testimony values and rounding */
const WOT_TESTIMONY_QUICK_5 = WOT_MIN_REPUTATION_5;
const WOT_TESTIMONY_QUICK_4 = WOT_MIN_REPUTATION_4;
@@ -51,8 +71,26 @@ const WOT_TESTIMONY_QUICK_1 = 0;
const WOT_TESTIMONY_ROUND = 1; /* Testimony steps */
const WOT_MIN_COMMENT_DIFF = 35;
+// reference: http://www.mywot.com/wiki/Activity_scores
+const WOT_ACTIVITYSCORE_LEVELS = [
+ { name: "rookie", min: 0 },
+ { name: "bronze", min: 1500 },
+ { name: "silver", min: 3000 },
+ { name: "gold", min: 6000 },
+ { name: "platinum", min: 10000 }
+ ];
+
+const WOT_AS_LEVELS = {
+ ROOKIE: 0,
+ BRONZE: 1500,
+ SILVER: 3000,
+ GOLD: 6000,
+ PLATINUM: 10000
+ };
+
/* Applications */
const WOT_APPLICATIONS = 5;
+const WOT_COMPONENTS = [0, 4];
/* Search */
const WOT_SAFESEARCH_OSD_URL = "https://search.mywot.com/osd/en-US.xml";
@@ -249,7 +287,8 @@ const wot_prefs_bool = [
[ "warning_unknown_4", false ],
// [ "warning_unknown_5", false ],
[ "feedback_enabled", true ],
- [ "feedback_optedout", false ]
+ [ "feedback_optedout", false ],
+ [ "super_showtestimonies", false ] // show my rating on the search popup at bottom corners of the popup
];
const wot_prefs_char = [
diff --git a/content/popup.js b/content/popup.js
index e538628..000fb86 100644
--- a/content/popup.js
+++ b/content/popup.js
@@ -18,7 +18,8 @@
along with WOT. If not, see <http://www.gnu.org/licenses/>.
*/
-const WOT_POPUP_LAYER =
+/*
+const WOT_POPUP_HTML =
"<div id=\"wot-logo\"></div>" +
"<div id=\"wot-popup-ratings-ID\" class=\"wot-popup-ratings\">" +
"<div id=\"wot-r0-stack-ID\" class=\"wot-stack\">" +
@@ -42,23 +43,57 @@ const WOT_POPUP_LAYER =
"<div id=\"wot-r4-cnf-ID\" class=\"wot-cnf\"></div>" +
"</div>" +
"</div>";
+*/
-const WOT_POPUP_STYLE =
- "@import \"chrome://wot/skin/include/popup.css\";";
+const WOT_POPUP_HTML =
+ '<div id="wot-logo">{POPUPHEADERTEXT}</div>' +
+ '<div id="wot-ratings{ID}" class="wot-ratings">' +
+ '<div id="wot-hostname"></div>' +
+ '<div id="wot-r0-stack{ID}" class="wot-stack wot-stack-left">' +
+ '<div id="wot-r0-header{ID}" class="wot-header">{POPUPTEXT0}</div>' +
+ '<div id="wot-r0-rep{ID}" class="wot-rep {ACCESSIBLE}"></div>' +
+ '<div id="wot-r0-cnf{ID}" class="wot-cnf"></div>' +
+ '<div class="rating-legend-wrapper">' +
+ '<div class="rating-legend">{REPTEXT0}</div>' +
+ '</div>' +
+
+ '</div>' +
+ '<div id="wot-r4-stack{ID}" class="wot-stack wot-stack-right">' +
+ '<div id="wot-r4-header{ID}" class="wot-header">{POPUPTEXT4}</div>' +
+ '<div id="wot-r4-rep{ID}" class="wot-rep {ACCESSIBLE}"></div>' +
+ '<div id="wot-r4-cnf{ID}" class="wot-cnf"></div>' +
+ '<div class="rating-legend-wrapper">' +
+ '<div class="rating-legend">{REPTEXT4}</div>' +
+ '</div>' +
+
+ '</div>' +
+ '</div>' +
+ '<div id="wot-categories">' +
+ '<div id="wot-cat-text">{POPUPNOCAT}</div>' +
+ '<ul id="wot-cat-list"></ul>' +
+ '</div>' +
+ '<div class="wot-corners-wrapper">' +
+ '<div id="wot-pp-tr" class="wot-pp-tr"></div>' +
+ '<div id="wot-pp-cs" class="wot-pp-cs"></div>' +
+ '</div>';
+
+const WOT_POPUP_STYLE = "@import \"chrome://wot/skin/include/popup.css\";";
var wot_popup =
{
- offsety: 15,
- offsetx: 0,
- height: 235,
- width: 137,
- ratingheight: 52,
- areaheight: 214,
+ offsety: -15,
+ offsetx: 4,
+ height: 220,
+ width: 300,
+// ratingheight: 52,
+// areaheight: 214,
barsize: 20,
offsetheight: 0,
postfix: "-" + Date.now(),
id: "wot-popup-layer",
onpopup: false,
+ layer: null,
+ MAX_CATEGORIES: 3,
load_delayed: function()
{
@@ -100,18 +135,17 @@ var wot_popup =
return false;
}
+ var replaces = [
+ { from: "ID", to: this.postfix },
+ { from: "POPUPTEXT0", to: wot_util.getstring("popup_0") },
+ { from: "POPUPTEXT4", to: wot_util.getstring("popup_4") },
+ { from: "ACCESSIBLE", to: wot_prefs.accessible ? "accessible" : "" },
+ { from: "POPUPHEADERTEXT", to: wot_util.getstring("popup_headertext") },
+ { from: "POPUPNOCAT", to: wot_util.getstring("popup_nocattext") }
+ ];
+
if (!this.layer) {
- this.layer = WOT_POPUP_LAYER;
- this.layer = this.layer.replace(/-ID/g,
- this.postfix);
- this.layer = this.layer.replace(/WOT_POPUP_TEXT_0/g,
- wot_util.getstring("popup_0") + ":");
- this.layer = this.layer.replace(/WOT_POPUP_TEXT_1/g,
- wot_util.getstring("popup_1") + ":");
- this.layer = this.layer.replace(/WOT_POPUP_TEXT_2/g,
- wot_util.getstring("popup_2") + ":");
- this.layer = this.layer.replace(/WOT_POPUP_TEXT_4/g,
- wot_util.getstring("popup_4") + ":");
+ this.layer = wot_util.processhtml(WOT_POPUP_HTML, replaces);
}
if (content.getElementById(this.id)) {
@@ -124,6 +158,8 @@ var wot_popup =
if (body && body.length) {
elem = body[0];
}
+
+ if (!elem) return false;
}
if (elem.isContentEditable) return false;
@@ -131,7 +167,7 @@ var wot_popup =
var layer = content.createElement("div");
layer.setAttribute("id", this.id);
layer.setAttribute("class", "wot-popup-layer");
- layer.setAttribute("style", "display: none; cursor: pointer;");
+ layer.setAttribute("style", "visibility: hidden;");
layer.innerHTML = this.layer;
var style = content.createElement("style");
@@ -146,8 +182,7 @@ var wot_popup =
}
layer.addEventListener("click", function() {
- wot_browser.openscorecard(layer.getAttribute("target"),
- null, WOT_URL_POPUPVIEWSC);
+ wot_browser.openscorecard(layer.getAttribute("target"), null, WOT_URL_POPUPVIEWSC);
}, false);
elem.appendChild(layer);
@@ -163,126 +198,151 @@ var wot_popup =
loadlayer: function(content, layer, target)
{
try {
- var status = wot_cache.get(target, "status");
+ var status = wot_cache.get(target, "status"),
+ tr_t, cs_t, r, c, x, t;
if (status != WOT_QUERY_OK && status != WOT_QUERY_LINK) {
return false;
}
- var cls = layer.getAttribute("class");
+ for (var i = 0; i < WOT_COMPONENTS.length; ++i) {
+ var app = WOT_COMPONENTS[i];
+ var rep_elem = content.getElementById("wot-r" + app + "-rep" + this.postfix);
+ var cnf_elem = content.getElementById("wot-r" + app + "-cnf" + this.postfix);
- if (wot_prefs.accessible) {
-
- if (!cls || !cls.length) {
- cls = "accessible";
- } else if (cls.indexOf("accessible") < 0) {
- cls += " accessible";
+ if (!rep_elem || !cnf_elem) {
+ continue;
}
- layer.setAttribute("class", cls);
- } else if (cls && cls.indexOf("accessible") >= 0) {
- cls = cls.replace(/accessible/g, "");
- layer.setAttribute("class", cls);
+ r = wot_cache.get(target, "reputation_" + app),
+ c = wot_cache.get(target, "confidence_" + app),
+ x = wot_cache.get(target, "excluded_" + app),
+ t = wot_util.get_level(WOT_REPUTATIONLEVELS, wot_cache.get(target, "testimony_" + app)).name;
+
+ r = x ? -2 : r; // if Excluded is set, select proper rep level (rx);
+ rep_elem.setAttribute("reputation", wot_util.get_level(WOT_REPUTATIONLEVELS, r).name);
+
+ c = x ? -2 : c;
+ cnf_elem.setAttribute("confidence", wot_util.get_level(WOT_CONFIDENCELEVELS, c).name);
+
+ // set testimonies for TR and CS to bottom corners of the popup testimony_
+ if (app == 0) {
+ tr_t = t;
+ } else if (app == 4) {
+ cs_t = t;
+ }
}
- for (var i = 0; i < WOT_APPLICATIONS; ++i) {
- var rep = content.getElementById("wot-r" + i + "-rep" +
- this.postfix);
- var cnf = content.getElementById("wot-r" + i + "-cnf" +
- this.postfix);
+ // set target name
+ var normalized_target = wot_cache.get(target, "normalized") || null;
- if (!rep || !cnf) {
- continue;
- }
+ var hostname_elem = content.getElementById("wot-hostname");
+ if (hostname_elem) {
+ var display_target = normalized_target && normalized_target.length ? normalized_target : target;
+ hostname_elem.textContent = wot_util.htmlescape(wot_shared.decodehostname(display_target));
+ }
- var r = wot_cache.get(target, "reputation_" + i);
- var c = wot_cache.get(target, "confidence_" + i);
- var x = wot_cache.get(target, "excluded_" + i);
-
- if (x) {
- rep.setAttribute("reputation", "excluded");
- } else if (r >= WOT_MIN_REPUTATION_5) {
- rep.setAttribute("reputation", 5);
- } else if (r >= WOT_MIN_REPUTATION_4) {
- rep.setAttribute("reputation", 4);
- } else if (r >= WOT_MIN_REPUTATION_3) {
- rep.setAttribute("reputation", 3);
- } else if (r >= WOT_MIN_REPUTATION_2) {
- rep.setAttribute("reputation", 2);
- } else if (r >= 0) {
- rep.setAttribute("reputation", 1);
- } else {
- rep.setAttribute("reputation", 0);
- }
+ // show user's ratings for the site
+ if (wot_prefs.super_showtestimonies) {
+ var tr_t_corner = content.getElementById("wot-pp-tr");
+ if (tr_t_corner && tr_t) {
+ tr_t_corner.setAttribute("r", tr_t);
+ }
+
+ var cs_t_corner = content.getElementById("wot-pp-cs");
+ if (cs_t_corner && cs_t) {
+ cs_t_corner.setAttribute("r", cs_t);
+ }
+ }
+
+ // Update categories in the popup
+ var target_cats = wot_categories.target_categories(target),
+ cats = wot_categories.select_identified(target_cats),
+ cat_list = content.getElementById("wot-cat-list"),
+ cat_text = content.getElementById("wot-cat-text");
+
+ if (cats && !wot_util.isEmpty(cats) && cat_list) {
+ var ordered_cats = wot_categories.rearrange_categories(cats);
+ cat_text.style.display = "none";
+ if (wot_popup.update_categories(cat_list, ordered_cats.all, content) > 0) {
+ wot_popup.toggle_categories(true, content); // show categories
+ } else {
+ wot_popup.toggle_categories(false, content);
+ }
+
+ } else {
+ wot_popup.toggle_categories(false, content); // hide categories list
+ }
- if (x) {
- cnf.setAttribute("confidence", 0);
- } else if (c >= WOT_MIN_CONFIDENCE_5) {
- cnf.setAttribute("confidence", 5);
- } else if (c >= WOT_MIN_CONFIDENCE_4) {
- cnf.setAttribute("confidence", 4);
- } else if (c >= WOT_MIN_CONFIDENCE_3) {
- cnf.setAttribute("confidence", 3);
- } else if (c >= WOT_MIN_CONFIDENCE_2) {
- cnf.setAttribute("confidence", 2);
- } else if (c >= WOT_MIN_CONFIDENCE_1) {
- cnf.setAttribute("confidence", 1);
- } else {
- cnf.setAttribute("confidence", 0);
- }
- }
- wot_popup.offsetheight = 0;
- var bottom = content.getElementById("wot-r0-stack" +
- this.postfix);
- if (wot_prefs.show_application_1) {
- bottom = content.getElementById("wot-r1-stack" +
- this.postfix);
- bottom.style.display = "block";
- } else {
- content.getElementById("wot-r1-stack" +
- this.postfix).style.display = "none";
- wot_popup.offsetheight -= wot_popup.ratingheight;
- }
- if (wot_prefs.show_application_2) {
- bottom = content.getElementById("wot-r2-stack" +
- this.postfix);
- bottom.style.display = "block";
- } else {
- content.getElementById("wot-r2-stack" +
- this.postfix).style.display = "none";
- wot_popup.offsetheight -= wot_popup.ratingheight;
- }
- if (wot_prefs.show_application_4) {
- bottom = content.getElementById("wot-r4-stack" +
- this.postfix);
- bottom.style.display = "block";
- } else {
- content.getElementById("wot-r4-stack" +
- this.postfix).style.display = "none";
- wot_popup.offsetheight -= wot_popup.ratingheight;
- }
- bottom.style.borderBottom = "0";
- content.getElementById("wot-popup-ratings" +
- this.postfix).style.height =
- wot_popup.offsetheight + wot_popup.areaheight + "px";
return true;
+
} catch (e) {
- dump("wot_popup.loadlayer: failed with " + e + "\n");
+ wdump("wot_popup.loadlayer: failed with " + e);
}
return false;
},
+ toggle_categories: function (show, content) {
+ var cat_list = content.getElementById("wot-cat-list"),
+ cat_text = content.getElementById("wot-cat-text");
+ if (cat_list && cat_text) {
+ if (show) {
+ cat_text.style.display = "none";
+ cat_list.style.display = "block";
+ }
+ else {
+ cat_text.style.display = "block";
+ cat_list.style.display = "none";
+ }
+ }
+ },
+
+ update_categories: function (list_node, categories, content) {
+ var cnt = 0;
+
+ // remove all list items
+ while(list_node.firstChild) {
+ list_node.removeChild(list_node.firstChild);
+ }
+
+ for (var k in categories) {
+ if (cnt >= this.MAX_CATEGORIES) break;
+
+ var cat = categories[k],
+ cid = cat.id,
+ li = content.createElement("li"),
+ cls = ["cat-item"],
+ cat_name = wot_categories.get_category_name(cid, true); // name is already htmlescaped
+
+ if (!cat_name) {
+ continue; // skip undefined categories, don't take them into account
+ }
+
+ cls.push(wot_categories.get_category_css(cid)); // css type is already htmlescaped
+ var cl = wot_util.get_level(WOT_CONFIDENCELEVELS, cat.c).name;
+ cls.push(cl);
+
+ li.textContent = cat_name;
+ li.setAttribute("class", cls.join(" "));
+
+ cnt++;
+ list_node.appendChild(li);
+ }
+
+ return cnt;
+ },
+
hidelayer: function(content, appearance)
{
try {
var layer = content.getElementById(this.id);
- if (layer && layer.style.display != "none" &&
+ if (layer && layer.style.visibility != "hidden" &&
(appearance == null || appearance == this.appearance) &&
!this.onpopup) {
- layer.style.display = "none";
+ layer.style.visibility = "hidden";
}
} catch (e) {
/* dump("wot_popup.hidelayer: failed with " + e + "\n"); */
@@ -335,15 +395,11 @@ var wot_popup =
var content = event_view.document;
- if (!content) {
- return;
- }
-
+ if (!content) return;
+
var layer = content.getElementById(wot_popup.id);
- if (!layer) {
- return;
- }
+ if (!layer) return;
wot_popup.target = wot_popup.findelem(event);
@@ -357,11 +413,10 @@ var wot_popup =
return;
}
- var attr = wot_popup.target.attributes.getNamedItem(
- wot_search.attribute);
- var target = attr.value;
+ var attr = wot_popup.target.attributes.getNamedItem(wot_search.attribute),
+ target = attr.value;
- if (layer.style.display == "block" &&
+ if (layer.style.visibility == "visible" &&
layer.getAttribute("target") == target) {
return;
}
@@ -373,21 +428,20 @@ var wot_popup =
return;
}
- var popupheight = wot_popup.height + wot_popup.offsetheight;
+ var style = event_view.getComputedStyle(layer),
+ popupheight = Math.max(isNaN(style.height) ? 0 : style.height , wot_popup.height),
+ popupwidth = style.width || wot_popup.width;
- layer.style.height = popupheight + "px";
- layer.style.width = wot_popup.width + "px";
+ var height = parseInt(event_view.innerHeight - wot_popup.barsize);
+ var width = 0 + event_view.innerWidth - wot_popup.barsize;
- var height = event_view.innerHeight - wot_popup.barsize;
- var width = event_view.innerWidth - wot_popup.barsize;
-
- if (height < popupheight || width < wot_popup.width) {
+ if (height < popupheight || width < popupwidth) {
wot_popup.hidelayer(content);
- return
+ return;
}
- var vscroll = event_view.pageYOffset;
- var hscroll = event_view.pageXOffset;
+ var vscroll = isNaN(event_view.pageYOffset) ? 0 : parseInt(event_view.pageYOffset);
+ var hscroll = isNaN(event_view.pageXOffset) ? 0 : parseInt(event_view.pageXOffset);
// more accurate way to calc position
// got from http://javascript.ru/ui/offset
@@ -396,18 +450,29 @@ var wot_popup =
var docElem = content.documentElement;
var body = content.body;
- var scrollTop = window.pageYOffset || docElem.scrollTop || body.scrollTop;
- var scrollLeft = window.pageXOffset || docElem.scrollLeft || body.scrollLeft;
+
+ var y_offset = 0; // vertical offset for the pointer (which is not implemented yet)
+
+ var scrollTop = event_view.pageYOffset || docElem.scrollTop || body.scrollTop;
+ var scrollLeft = event_view.pageXOffset || docElem.scrollLeft || body.scrollLeft;
var clientTop = docElem.clientTop || body.clientTop || 0;
var clientLeft = docElem.clientLeft || body.clientLeft || 0;
var y = box.top + scrollTop - clientTop;
var x = box.left + scrollLeft - clientLeft;
- var posy = wot_popup.offsety + y + wot_popup.target.offsetHeight;
+ var posy = wot_popup.offsety + y;// + wot_popup.target.offsetHeight;
var posx = wot_popup.offsetx + x + wot_popup.target.offsetWidth;
+ if (posy < vscroll) {
+ // if placeholder's top doesn't fit into view, align it to the view
+ posy = vscroll;
+ }
+
if (posy + popupheight > height + vscroll) {
- posy = y - popupheight - wot_popup.offsety;
+ if (posy < height + vscroll) {
+ y_offset = height + vscroll - y;
+ }
+ posy = (y - popupheight + height + vscroll + wot_popup.offsety)/2;
}
if (posx - hscroll < 0) {
@@ -418,7 +483,7 @@ var wot_popup =
var appearance = ++wot_popup.appearance;
- if (layer.style.display != "none") {
+ if (layer.style.visibility != "hidden") {
layer.style.top = posy + "px";
layer.style.left = posx + "px";
} else {
@@ -427,12 +492,12 @@ var wot_popup =
appearance == wot_popup.appearance) {
layer.style.top = posy + "px";
layer.style.left = posx + "px";
- layer.style.display = "block";
+ layer.style.visibility = "visible";
}
}, wot_prefs.popup_show_delay);
}
} catch (e) {
- dump("wot_popup.onmouseover: failed with " + e + "\n");
+ wdump("wot_popup.onmouseover: failed with " + e);
}
}
};
diff --git a/content/util.js b/content/util.js
index 9c1d52c..1177420 100644
--- a/content/util.js
+++ b/content/util.js
@@ -64,6 +64,21 @@ var wot_util =
return null;
},
+ get_level: function (levels, value, next) {
+ next = next ? next : false;
+
+ var next_level = levels[levels.length - 1];
+
+ for (var i = levels.length - 1; i >= 0; --i) {
+ if (value >= levels[i].min) {
+ return next ? next_level : levels[i];
+ }
+ next_level = levels[i];
+ }
+
+ return levels[1];
+ },
+
copy_attrs: function (node) {
var obj = {};
if (node) {
@@ -109,7 +124,33 @@ var wot_util =
} catch (e) {
return null;
}
- }
+ },
+
+ processhtml: function (html, replaces) {
+ try {
+ replaces.forEach(function(item) {
+ html = html.replace(RegExp("{" + item.from + "}", "g"),
+ item.to);
+ });
+
+ return html;
+ } catch (e) {
+ wdump("warning.processhtml: failed with " + e);
+ }
+
+ return "";
+ },
+
+ htmlescape: function(str) {
+ var tagsToReplace = {
+ '&': '&',
+ '<': '<',
+ '>': '>'
+ };
+ return str.replace(/[&<>]/g, function(symb) {
+ return tagsToReplace[symb] || symb;
+ });
+ }
};
var wot_url =
@@ -884,7 +925,33 @@ var wot_crypto =
dump("wot_crypto.islevel: failed with " + e + "\n");
}
return false;
- }
+ },
+
+ decrypt: function(data, nonce, index)
+ {
+ try {
+ if (data && nonce) {
+ var key = wot_prefs.witness_key;
+
+ if (index == null || index < 0) {
+ index = "";
+ } else {
+ index = "-" + index;
+ }
+
+ if (key) {
+ return wot_hash.bintostr(wot_arc4.crypt(
+ wot_arc4.create(wot_hash.hmac_sha1hex(key,
+ "response-" + nonce + index)),
+ wot_hash.strtobin(atob(data))));
+ }
+ }
+ } catch (e) {
+ wdump("wot_crypto.decrypt(): failed with " + e);
+ }
+
+ return null;
+ }
};
wot_modules.push({ name: "wot_crypto", obj: wot_crypto });
diff --git a/locale/en-US/wot.properties b/locale/en-US/wot.properties
index 657cbb8..e88a5a9 100644
--- a/locale/en-US/wot.properties
+++ b/locale/en-US/wot.properties
@@ -47,9 +47,9 @@ rating_1 = Vendor reliability
rating_2 = Privacy
rating_4 = Child safety
popup_0 = Trustworthiness
-popup_1 = Vendor reliability
-popup_2 = Privacy
popup_4 = Child safety
+popup_headertext = click to view details
+popup_nocattext = share your opinion about this website
user_score_title = My activity score
user_score_mypage = View my page
user_score_register = Register now
diff --git a/locale/ru-RU/wot.properties b/locale/ru-RU/wot.properties
index d48735d..3c79d4c 100644
--- a/locale/ru-RU/wot.properties
+++ b/locale/ru-RU/wot.properties
@@ -46,10 +46,10 @@ rating_0 = Заслуживает доверие
rating_1 = Надежность продавца
rating_2 = Конфиденциальность
rating_4 = Безопасность для детей
-popup_0 = Заслуж. доверия
-popup_1 = Надежн. продавца
-popup_2 = Конфиденц-ть
-popup_4 = Безоп-ть детей
+popup_0 = Заслуживает доверие
+popup_4 = Безопасность для детей
+popup_headertext = кликните, чтобы посмотреть подробности
+popup_nocattext = высказать своё мнение об этом сайте
user_score_title = Моя оценка активности
user_score_mypage = Просмотреть мою страницу
user_score_register = Зарегистрироваться сейчас
diff --git a/skin/b/bubl_speech_c_150.png b/skin/b/bubl_speech_c_150.png
new file mode 100644
index 0000000..b9595b5
Binary files /dev/null and b/skin/b/bubl_speech_c_150.png differ
diff --git a/skin/b/bubl_speech_l_150.png b/skin/b/bubl_speech_l_150.png
new file mode 100644
index 0000000..3b7f27c
Binary files /dev/null and b/skin/b/bubl_speech_l_150.png differ
diff --git a/skin/b/bubl_speech_r_150.png b/skin/b/bubl_speech_r_150.png
new file mode 100644
index 0000000..f2a94eb
Binary files /dev/null and b/skin/b/bubl_speech_r_150.png differ
diff --git a/skin/b/confidence_150dpi.png b/skin/b/confidence_150dpi.png
new file mode 100644
index 0000000..aea0cc9
Binary files /dev/null and b/skin/b/confidence_150dpi.png differ
diff --git a/skin/b/donuts_150.png b/skin/b/donuts_150.png
new file mode 100644
index 0000000..a98904f
Binary files /dev/null and b/skin/b/donuts_150.png differ
diff --git a/skin/include/popup.css b/skin/include/popup.css
index 89b465d..0ad5ba4 100644
--- a/skin/include/popup.css
+++ b/skin/include/popup.css
@@ -1,118 +1,384 @@
.wot-popup-layer {
- border: 0 ! important;
- font-family: Arial, sans-serif;
- margin: 0;
- padding: 0;
- position: absolute;
- z-index: 2147483647;
- width: 136px;
+ border: 1px solid #e4e4e4 !important;
+ font-family: Arial, sans-serif;
+ font-size: 12px;
+ margin: 0;
+ padding: 0;
+ position: absolute;
+ z-index: 2147483647;
+ max-width: 395px;
+ cursor: pointer;
+ -moz-user-select: none;
+ box-shadow: 4px 4px 6px rgba(189, 189, 189, 0.65);
+ background-color: white;
}
+
#wot-logo {
- background: url("chrome://wot/skin/fusion/popup-logo.png") top left no-repeat;
- display: block;
- height: 21px;
- margin: 0;
- padding: 0;
-}
-.accessible #wot-logo {
- background: url("chrome://wot/skin/fusion/accessible/popup-logo.png") top left no-repeat;
-}
-#wot-popup-ratings, .wot-popup-ratings {
- background: url("chrome://wot/skin/fusion/popup.png") bottom left no-repeat;
- display: block;
- height: 214px;
- margin: 0;
- padding: 0;
+ background: url("chrome://wot/skin/fusion/logo.png") top left no-repeat;
+ margin: 0;
+ text-align: right;
+ color: #A5A4A4;
+ font-size: 11px;
+ padding: 5px 5px;
+ background-position: 6px 6px;
+ background-size: 26%;
}
-.wot-stack {
- display: block;
- height: 50px;
- width: 121px;
- margin: 0px 0px 0px 2px;
- padding: 2px 0px 0px 9px;
+
+.wot-ratings {
+ display: block;
+ margin: 0;
+ padding: 0 5px 0;
+ background-color: #F9F9F9;
+ height: 97px;
+ border-top: 1px solid #D9D9D9;
+ border-bottom: 1px solid #D9D9D9;
}
+
.wot-header {
- color: #878787;
- display: block;
- font-size: 12px;
- font-weight: normal;
- line-height: 14px;
- margin: 0;
- overflow: hidden;
- padding: 0;
- text-align: left;
- white-space: nowrap;
- width: 109px;
+ color: #454545;
+ display: block;
+ font-size: 12px;
+ font-weight: normal;
+ line-height: 14px;
+ margin: 0;
+ overflow: hidden;
+ padding: 0 0 7px 0;
+ text-align: left;
+ white-space: nowrap;
+}
+
+#wot-hostname {
+ text-align: center;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ padding: 6px 0px;
+ overflow: hidden;
+ font-weight: bold;
+ color: #454545;
+}
+
+.wot-stack {
+ display: table-cell;
+ height: 50px;
+ min-width: 110px;
+}
+
+.wot-stack-left {
+ padding-left: 12px;
}
+
+.wot-stack-right {
+ padding: 0 15px;
+}
+
.wot-rep {
- background: url('chrome://wot/skin/fusion/28_28/no_rep_available.png') left top no-repeat;
- display: block;
- height: 28px;
- width: 28px;
- margin: 2px 0px 0px 1px;
- padding: 0;
- float: left;
+ background: url("chrome://wot/skin/b/donuts_150.png") left top no-repeat;
+ background-position: 0 -165px;
+ background-size: 35px 198px;
+ height: 33px;
+ width: 35px;
+ margin-left: -4px;
+ margin-top: 7px;
+ padding: 0;
+ float: left;
+}
+
+.wot-rep[reputation="r1"] {
+ background-position: 0 -132px;
}
-.wot-rep[reputation="excluded"] {
- background: url('chrome://wot/skin/fusion/28_28/excluded.png') left top no-repeat;
+
+.wot-rep[reputation="r2"] {
+ background-position: 0 -99px;
}
-.wot-rep[reputation="1"] {
- background: url('chrome://wot/skin/fusion/28_28/danger.png') left top no-repeat;
+
+.wot-rep[reputation="r3"] {
+ background-position: 0 -66px;
}
-.wot-rep[reputation="2"] {
- background: url('chrome://wot/skin/fusion/28_28/not_safe.png') left top no-repeat;
+
+.wot-rep[reputation="r4"] {
+ background-position: 0 -33px;
}
-.wot-rep[reputation="3"] {
- background: url('chrome://wot/skin/fusion/28_28/caution.png') left top no-repeat;
+
+.wot-rep[reputation="r5"] {
+ background-position: 0 0;
}
-.wot-rep[reputation="4"] {
- background: url('chrome://wot/skin/fusion/28_28/alright.png') left top no-repeat;
+
+.wot-cnf {
+ height: 42px;
+ margin-left: -2px;
+ margin-top: -5px;
+ width: 34px;
+ background: url("chrome://wot/skin/b/confidence_150dpi.png") top left no-repeat;
+ background-size: 33px auto;
+ background-position: 0 -168px;
+ padding: 0;
+ float: left;
}
-.wot-rep[reputation="5"] {
- background: url('chrome://wot/skin/fusion/28_28/trusted.png') left top no-repeat;
+
+.wot-cnf[confidence="c1"] {
+ background-position: 0 -126px;
}
-.accessible .wot-rep {
- background: url('chrome://wot/skin/fusion/accessible/28_28/no_rep_available.png') left top no-repeat;
+
+.wot-cnf[confidence="c2"] {
+ background-position: 0 -84px;
}
-.accessible .wot-rep[reputation="excluded"] {
- background: url('chrome://wot/skin/fusion/28_28/excluded.png') left top no-repeat;
+
+.wot-cnf[confidence="c3"] {
+ background-position: 0 -42px;
}
-.accessible .wot-rep[reputation="1"] {
- background: url('chrome://wot/skin/fusion/accessible/28_28/danger.png') left top no-repeat;
+
+.wot-cnf[confidence="c4"] {
+ background-position: 0 0;
}
-.accessible .wot-rep[reputation="2"] {
- background: url('chrome://wot/skin/fusion/accessible/28_28/not_safe.png') left top no-repeat;
+
+.wot-cnf[confidence="c5"] {
+ background-position: 0 -210px;
}
-.accessible .wot-rep[reputation="3"] {
- background: url('chrome://wot/skin/fusion/accessible/28_28/caution.png') left top no-repeat;
+
+.rating-legend-wrapper {
+ /*position: absolute;*/
+ background: url("chrome://wot/skin/b/bubl_speech_c_150.png") top left repeat-x;
+ background-size: 1px 24px;
+ height: 24px;
+ margin: 1px 0 auto 14px;
+ float: left;
+ position: relative;
+
+ display: none; /* don't show bubble speeches for now until we have their new styles */
}
-.accessible .wot-rep[reputation="4"] {
- background: url('chrome://wot/skin/fusion/accessible/28_28/alright.png') left top no-repeat;
+
+.rating-legend-wrapper:before {
+ position: absolute;
+ content: "";
+ height: 24px;
+ width: 17px;
+ margin-left: -17px;
+ background: url("chrome://wot/skin/b/bubl_speech_l_150.png") top left no-repeat;
+ background-size: 17px 24px;
}
-.accessible .wot-rep[reputation="5"] {
- background: url('chrome://wot/skin/fusion/accessible/28_28/trusted.png') left top no-repeat;
+
+.rating-legend-wrapper:after {
+ position: absolute;
+ content: "";
+ height: 24px;
+ width: 17px;
+ right: -17px;
+ background: url("chrome://wot/skin/b/bubl_speech_r_150.png") top left no-repeat;
+ background-size: 10px 24px;
+ top: 0px;
}
-.wot-cnf {
- background: url('chrome://wot/skin/fusion/confidence-0.png') right top no-repeat;
- display: block;
- height: 18px;
- width: 51px;
- margin: 6px 32px 0px 0px;
- padding: 0;
- float: right;
+
+.rating-legend {
+ position: relative;
+ height: 24px;
+ min-width: 48px;
+ margin: -2px 0 0em;
+ padding: 7px 4px 0 0px;
+ color: #454545;
+ font-size: 12px;
+ text-align: center;
+ white-space: nowrap;
+}
+
+#wot-categories {
+ /* Block of categories */
+ clear: both;
+}
+
+#wot-cat-text {
+ /* This element is for optional text when no categories are identified */
+ font-size: 11px;
+ color: #3073C5;
+ padding: 6px 5px;
+ text-align: center;
+ display: none;
+}
+
+#wot-cat-text:hover {
+ text-decoration: underline;
+}
+
+#wot-cat-list {
+ /* List of categories */
+ display: none;
+ padding: 0 10px 0 40px !important;
+ margin: 6px 0 !important;
+}
+
+.wot-popup-layer .cat-item {
+ font-size: 9pt;
+ color: silver;
+ list-style: none !important;
+ padding: 0.2em 0 !important;
+}
+
+.wot-popup-layer .cat-item:before {
+ width: 1em;
+ height: 1em;
+ border: 1px solid #C0C0C0;
+ background-color: #C0C0C0;
+ border-radius: 50%;
+ content: "";
+ position: absolute;
+ margin-left: -1.65em;
+ margin-top: 0px;
+}
+
+.c-neutral.cat-item:before {
+ background-color: #707070;
+ background: -webkit-radial-gradient(center, ellipse cover, #9e9c9c 0%,#707070 100%); /* Chrome10+,Safari5.1+ */
+ border-color: #7d7d7d;
+}
+
+.c-questionable.cat-item:before {
+ background-color: #ffd100;
+ background: -webkit-radial-gradient(center, ellipse cover, #f8df68 0%,#f6cd0e 100%); /* Chrome10+,Safari5.1+ */
+ border-color: #f6cd0e;
+}
+
+.c-negative.cat-item:before {
+ background-color: #f66d3f;
+ background: -webkit-radial-gradient(center, ellipse cover, #fca080 0%,#f77448 100%); /* Chrome10+,Safari5.1+ */
+ border-color: #f66d3f;
+}
+
+.c-positive.cat-item:before {
+ background-color: #68c800;
+ background: -webkit-radial-gradient(center, ellipse cover, #83d561 0%,#6dc14a 100%); /* Chrome10+,Safari5.1+ */
+ border-color: #6dc14a;
+}
+
+/* reset styles */
+.wot-popup-layer .c0,
+.wot-popup-layer .c1,
+.wot-popup-layer .c2,
+.wot-popup-layer .c3,
+.wot-popup-layer .c4,
+.wot-popup-layer .c5 {
+ height: auto;
+}
+
+.wot-popup-layer .c0 {
+ font-size: 11px !important;
+ color: #a7a7a7 !important;
+}
+
+.wot-popup-layer .c0.cat-item:before {
+ width: 4px !important;
+ height: 4px !important;
+ margin-left: -19px !important;
+ margin-top: 4px !important;
+}
+
+.wot-popup-layer .c1 {
+ font-size: 12px;
+ color: #a7a7a7;
+}
+
+.wot-popup-layer .c1.cat-item:before {
+ width: 6px;
+ height: 6px;
+ margin-left: -20px;
+ margin-top: 3px;
+}
+
+.wot-popup-layer .c2,
+.wot-popup-layer .c3 {
+ font-size: 12px;
+ color: #646464;
+}
+
+.wot-popup-layer .c2.cat-item:before,
+.wot-popup-layer .c3.cat-item:before {
+ width: 8px;
+ height: 8px;
+ margin-left: -21px;
+ margin-top: 1px;
+}
+
+.wot-popup-layer .c4,
+.wot-popup-layer .c5 {
+ font-size: 12px;
+ color: #5c5c5c;
+ font-weight: bold;
+}
+
+.wot-popup-layer .c4.cat-item:before,
+.wot-popup-layer .c5.cat-item:before {
+ width: 10px;
+ height: 10px;
+ margin-left: -22px;
+}
+
+/* small hints about user's ratings on the popup */
+
+.wot-corners-wrapper {
+ position: relative;
+}
+
+.wot-pp-tr,
+.wot-pp-cs {
+ position: absolute;
+ width: 0;
+ height: 0;
+ bottom: 0;
+ left: 0;
+ border: 4px solid transparent;
+}
+
+.wot-pp-cs {
+ right: 0;
+ left: auto;
+ margin-left: auto;
+ bottom: 0;
+}
+
+.wot-pp-tr[r="r1"] {
+ border-left-color: #fd0000;
+ border-bottom-color: #fd0000;
+}
+
+.wot-pp-cs[r="r1"] {
+ border-right-color: #fd0000;
+ border-bottom-color: #fd0000;
+}
+
+.wot-pp-tr[r="r2"] {
+ border-left-color: #ff9f75;
+ border-bottom-color: #ff9f75;
+}
+
+.wot-pp-cs[r="r2"] {
+ border-right-color: #ff9f75;
+ border-bottom-color: #ff9f75;
+}
+
+.wot-pp-tr[r="r3"] {
+ border-left-color: #ffd100;
+ border-bottom-color: #ffd100;
}
-.wot-cnf[confidence="1"] {
- background: url('chrome://wot/skin/fusion/confidence-1.png') right top no-repeat;
+
+.wot-pp-cs[r="r3"] {
+ border-right-color: #ffd100;
+ border-bottom-color: #ffd100;
}
-.wot-cnf[confidence="2"] {
- background: url('chrome://wot/skin/fusion/confidence-2.png') right top no-repeat;
+
+.wot-pp-tr[r="r4"] {
+ border-left-color: #a7df21;
+ border-bottom-color: #a7df21;
}
-.wot-cnf[confidence="3"] {
- background: url('chrome://wot/skin/fusion/confidence-3.png') right top no-repeat;
+
+.wot-pp-cs[r="r4"] {
+ border-right-color: #a7df21;
+ border-bottom-color: #a7df21;
}
-.wot-cnf[confidence="4"] {
- background: url('chrome://wot/skin/fusion/confidence-4.png') right top no-repeat;
+
+.wot-pp-tr[r="r5"] {
+ border-left-color: #68c800;
+ border-bottom-color: #68c800;
}
-.wot-cnf[confidence="5"] {
- background: url('chrome://wot/skin/fusion/confidence-5.png') right top no-repeat;
+
+.wot-pp-cs[r="r5"] {
+ border-right-color: #68c800;
+ border-bottom-color: #68c800;
}
--
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