[Pkg-mozext-commits] [wot] 91/226: Added locale strings from Chrome and implemented initialisation of RW with locales
David Prévot
taffit at moszumanska.debian.org
Fri May 1 00:35:38 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 3729816e467fc1ba218c8a3da36d6d48bc59c179
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Wed Jul 31 11:31:04 2013 +0300
Added locale strings from Chrome and implemented initialisation of RW with locales
---
content/api.js | 6 +-
content/commands.js | 17 -
content/core.js | 21 +-
content/overlay.xul | 184 +---
content/ratingwindow.js | 89 ++
content/rw/jquery.js | 4 +
content/rw/jquery.menu-aim.js | 331 +++++++
content/rw/keeper.js | 83 ++
content/rw/ratingwindow.html | 277 ++++++
content/rw/ratingwindow.js | 2088 +++++++++++++++++++++++++++++++++++++++++
content/rw/wot.js | 1041 ++++++++++++++++++++
content/ui.js | 2 +-
content/util.js | 28 +-
locale/en-US/wot.properties | 133 ++-
skin/b/ratingwindow.css | 1766 ++++++++++++++++++++++++++++++++++
skin/wot.css | 2 +
16 files changed, 5850 insertions(+), 222 deletions(-)
diff --git a/content/api.js b/content/api.js
index 828b487..9b5b2e5 100644
--- a/content/api.js
+++ b/content/api.js
@@ -500,14 +500,14 @@ var wot_api_register =
if (wot_browser.isoffline()) {
wot_status.set("offline",
- wot_util.getstring("description_offline"));
+ wot_util.getstring("message_offline"));
this.timeout = window.setTimeout(wot_api_register.send,
WOT_INTERVAL_REGISTER_OFFLINE);
return;
}
wot_status.set("notready",
- wot_util.getstring("description_notready"));
+ wot_util.getstring("messages_notready"));
if (!this.geteid() ||
wot_hashtable.get(WOT_REGISTER_RUNNING)) {
@@ -590,7 +590,7 @@ var wot_api_register =
{
try {
wot_status.set("error",
- wot_util.getstring("description_error_register"));
+ wot_util.getstring("message_error_register"));
wot_api_register.timeout =
window.setTimeout(wot_api_register.send,
diff --git a/content/commands.js b/content/commands.js
index 26e794c..e52e91d 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -360,23 +360,6 @@ var wot_events =
return false;
},
- /* Called when the popup window is hidden */
- hide_popup: function()
- {
- try {
- if (wot_api_query.message_id.length > 0 &&
- wot_api_query.message_id !=
- WOT_SERVICE_XML_QUERY_MSG_ID_MAINT) {
- wot_prefs.setChar("last_message", wot_api_query.message_id);
- }
-
- /* Stores any pending testimonies */
- wot_core.update();
- } catch (e) {
- dump("wot_events.hide_popup: failed with " + e + "\n");
- }
- },
-
click_title: function(event) {
try {
if (!wot_prefs.enabled) {
diff --git a/content/core.js b/content/core.js
index 3fa1d6e..f4b7097 100644
--- a/content/core.js
+++ b/content/core.js
@@ -548,12 +548,13 @@ var wot_core =
update: function()
{
+ wdump("core.update()");
try {
wot_core.hostname = null;
if (!wot_api_register.ready || !wot_core.loaded) {
wot_status.set("notready",
- wot_util.getstring("description_notready"));
+ wot_util.getstring("messages_notready"));
return;
}
@@ -586,7 +587,7 @@ var wot_core =
if (!wot_util.isenabled()) {
wot_status.set("disabled",
- wot_util.getstring("description_disabled"));
+ wot_util.getstring("message_disabled"));
return;
}
@@ -613,7 +614,7 @@ var wot_core =
if (wot_browser.isoffline()) {
/* Browser offline */
wot_status.set("offline",
- wot_util.getstring("description_offline"));
+ wot_util.getstring("message_offline"));
/* Retry after a timeout */
window.setTimeout(wot_core.update, WOT_INTERVAL_UPDATE_OFFLINE);
return;
@@ -637,14 +638,14 @@ var wot_core =
wot_cache.destroy(wot_core.hostname);
}
wot_status.set("nohost",
- wot_util.getstring("description_private"));
+ wot_util.getstring("messages_notavailable"));
return;
}
if (!wot_cache.iscached(wot_core.hostname)) {
/* No previous record of the hostname, start a new query */
wot_status.set("inprogress",
- wot_util.getstring("description_inprogress"));
+ wot_util.getstring("messages_loading"));
wot_api_query.send(wot_core.hostname);
return;
}
@@ -658,7 +659,7 @@ var wot_core =
} else {
/* Query already in progress, keep waiting */
wot_status.set("inprogress",
- wot_util.getstring("description_inprogress"));
+ wot_util.getstring("messages_loading"));
return;
}
}
@@ -668,7 +669,7 @@ var wot_core =
if (status == WOT_QUERY_OK) {
if (age > WOT_INTERVAL_CACHE_REFRESH) {
wot_status.set("inprogress",
- wot_util.getstring("description_inprogress"));
+ wot_util.getstring("messages_loading"));
wot_api_query.send(wot_core.hostname);
} else {
wot_status.update();
@@ -678,12 +679,12 @@ var wot_core =
if (status == WOT_QUERY_RETRY || status == WOT_QUERY_LINK) {
/* Retry immediately */
wot_status.set("inprogress",
- wot_util.getstring("description_inprogress"));
+ wot_util.getstring("messages_loading"));
wot_api_query.send(wot_core.hostname);
return;
} else if (age > WOT_INTERVAL_CACHE_REFRESH_ERROR) {
wot_status.set("inprogress",
- wot_util.getstring("description_inprogress"));
+ wot_util.getstring("messages_loading"));
wot_api_query.send(wot_core.hostname);
return;
}
@@ -695,7 +696,7 @@ var wot_core =
try {
/* For some reason, we failed to get anything meaningful to display */
wot_status.set("error",
- wot_util.getstring("description_error_query"));
+ wot_util.getstring("messages_failed"));
} catch (e) {
dump("wot_core.update: failed with " + e + "\n");
}
diff --git a/content/overlay.xul b/content/overlay.xul
index ae0348e..0f9c877 100644
--- a/content/overlay.xul
+++ b/content/overlay.xul
@@ -31,6 +31,7 @@
<script type="application/x-javascript" src="chrome://wot/content/commands.js"/>
<script type="application/x-javascript" src="chrome://wot/content/shared.js"/>
<script type="application/x-javascript" src="chrome://wot/content/util.js"/>
+ <script type="application/x-javascript" src="chrome://wot/content/ratingwindow.js"/>
<script type="application/x-javascript" src="chrome://wot/content/ui.js"/>
<script type="application/x-javascript" src="chrome://wot/content/prefs.js"/>
<script type="application/x-javascript" src="chrome://wot/content/my.js"/>
@@ -46,6 +47,7 @@
<script type="application/x-javascript" src="chrome://wot/content/partner.js"/>
<script type="application/x-javascript" src="chrome://wot/content/core.js"/>
+
<stringbundleset id="stringbundleset">
<stringbundle id="wot-strings" src="chrome://wot/locale/wot.properties"/>
</stringbundleset>
@@ -78,186 +80,12 @@
<popupset id="mainPopupSet">
<!-- Testimony window -->
<menupopup id="wot-popup" noautohide="true" position="after_start"
- onpopupshowing="wot_core.update();"
- onpopuphiding="wot_events.hide_popup();"
- onmouseup="wot_events.slider_up(event, -1);">
-
- <vbox id="wot-elements">
- <!-- header -->
- <hbox id="wot-header">
- <box id="wot-header-logo" onclick="wot_events.click_logo(event);"/>
- <label id="wot-title-text"/>
- <hbox id="wot-header-links">
- <label id="wot-header-link-0" class="wot-header-link" value="&wotRating.prefs;"
- onclick="wot_events.click_prefs(event);"/>
- <box id="wot-header-link-separator"/>
- <label id="wot-header-link-1" class="wot-header-link" value="&wotRating.guide;"
- onclick="wot_events.click_guide(event);"/>
- </hbox>
- <box id="wot-header-button" onclick="wot_events.popup_hide();"/>
- </hbox>
-
- <!-- hostname -->
- <vbox id="wot-hostname">
- <label id="wot-hostname-text" onclick="wot_events.click_title(event);"/>
- </vbox>
-
- <vbox id="wot-ratings-area">
- <!-- rating header -->
- <hbox id="wot-rating-header">
- <label id="wot-rating-header-wot" crop="end" value="&wotRating.wot;"/>
- <label id="wot-rating-header-my" crop="end" value="&wotRating.my;"/>
- </hbox>
-
-
-
- <!-- rating 0 -->
- <vbox id="wot-rating-0" class="wot-rating">
- <label id="wot-rating-0-header" class="wot-rating-header" crop="end"
- value="&wotRating.app0;"/>
- <hbox id="wot-rating-0-data" class="wot-rating-data">
- <box id="wot-rating-0-reputation" class="wot-rating-reputation"/>
- <box id="wot-rating-0-confidence" class="wot-rating-confidence"/>
- <vbox id="wot-rating-0-testimony" class="wot-rating-testimony">
- <stack id="wot-rating-0-stack" class="wot-rating-stack"
- onmousedown="wot_events.slider_down(event, 0);"
- onmouseup="wot_events.slider_up(event, 0);"
- onmousemove="wot_events.slider_move(event, 0);">
- <box id="wot-rating-0-slider" class="wot-rating-slider"
- onmousedown="wot_events.slider_down(event, 0);"
- onmouseup="wot_events.slider_up(event, 0);"
- onmousemove="wot_events.slider_move(event, 0);"/>
- <box id="wot-rating-0-indicator" class="wot-rating-indicator"
- onmousedown="wot_events.slider_down(event, 0);"
- onmouseup="wot_events.slider_up(event, 0);"
- onmousemove="wot_events.slider_move(event, 0);"/>
- </stack>
- <hbox id="wot-rating-0-help" class="wot-rating-help">
- <label id="wot-rating-0-help-text" class="wot-rating-help-text" crop="end"/>
- <label id="wot-rating-0-help-link" class="wot-rating-help-link" crop="end"
- onclick="wot_events.click_help(event, 0);"/>
- </hbox>
- </vbox>
- </hbox>
- </vbox>
-
- <!-- rating 4 -->
- <vbox id="wot-rating-4" class="wot-rating">
- <label id="wot-rating-4-header" class="wot-rating-header" crop="end"
- value="&wotRating.app4;"/>
- <hbox id="wot-rating-4-data" class="wot-rating-data">
- <box id="wot-rating-4-reputation" class="wot-rating-reputation"/>
- <box id="wot-rating-4-confidence" class="wot-rating-confidence"/>
- <vbox id="wot-rating-4-testimony" class="wot-rating-testimony">
- <stack id="wot-rating-4-stack" class="wot-rating-stack"
- onmousedown="wot_events.slider_down(event, 4);"
- onmouseup="wot_events.slider_up(event, 4);"
- onmousemove="wot_events.slider_move(event, 4);">
- <box id="wot-rating-4-slider" class="wot-rating-slider"
- onmousedown="wot_events.slider_down(event, 4);"
- onmouseup="wot_events.slider_up(event, 4);"
- onmousemove="wot_events.slider_move(event, 4);"/>
- <box id="wot-rating-4-indicator" class="wot-rating-indicator"
- onmousedown="wot_events.slider_down(event, 4);"
- onmouseup="wot_events.slider_up(event, 4);"
- onmousemove="wot_events.slider_move(event, 4);"/>
- </stack>
- <hbox id="wot-rating-4-help" class="wot-rating-help">
- <label id="wot-rating-4-help-text" class="wot-rating-help-text" crop="end"/>
- <label id="wot-rating-4-help-link" class="wot-rating-help-link" crop="end"
- onclick="wot_events.click_help(event, 4);"/>
- </hbox>
- </vbox>
- </hbox>
- </vbox>
-
- </vbox>
-
- <deck id="main-area" selectedIndex="0">
-
- <vbox id="wot-reputation-area"></vbox>
-
- <vbox id="wot-categories"></vbox>
+ onpopupshowing="wot_rw.on_rw_open(event);"
+ onpopuphiding="wot_rw.hide_popup();">
- </deck>
+ <iframe id="wot-rwframe" src="chrome://wot/content/rw/ratingwindow.html" type="content-primary"
+ flex="1" transparent="true" showcaret="true" width="100%" height="380px"/>
- <!-- scorecard -->
- <vbox id="wot-scorecard">
- <vbox id="wot-scorecard-content"
- onclick="wot_events.click_scorecard(event, false);">
- <label id="wot-scorecard-visit" class="wot-scorecard-text" crop="end"
- value="&wotRating.scorecard;"/>
- <box id="wot-scorecard-comment-container">
- <label id="wot-scorecard-comment" class="wot-scorecard-text" crop="end"
- value="&wotRating.comment;"
- onmouseover="document.getElementById('wot-scorecard-visit').setAttribute('inactive', true);"
- onmouseout="document.getElementById('wot-scorecard-visit').removeAttribute('inactive');"
- onclick="wot_events.click_scorecard(event, true);"/>
- </box>
- </vbox>
- </vbox>
- <!-- user 0 -->
- <vbox id="wot-user-0" class="wot-user" hidden="true">
- <hbox id="wot-user-0-content" class="wot-user-content">
- <vbox id="wot-user-0-stack" class="wot-user-stack">
- <label id="wot-user-0-header" class="wot-user-header" crop="end"/>
- <hbox id="wot-user-0-bar" class="wot-user-bar">
- <box id="wot-user-0-bar-image" class="wot-user-bar-image"/>
- <label id="wot-user-0-bar-text" class="wot-user-bar-text" crop="end"/>
- </hbox>
- </vbox>
- <box id="wot-user-0-text-container" class="wot-user-text-container">
- <label id="wot-user-0-text" class="wot-user-text" crop="end"
- onclick="wot_events.click_user(event, 0);"/>
- </box>
- </hbox>
- <label id="wot-user-0-notice" class="wot-user-notice" crop="end"/>
- </vbox>
- <!-- user 1 -->
- <vbox id="wot-user-1" class="wot-user" hidden="true">
- <hbox id="wot-user-1-content" class="wot-user-content">
- <vbox id="wot-user-1-stack" class="wot-user-stack">
- <label id="wot-user-1-header" class="wot-user-header" crop="end"/>
- <hbox id="wot-user-1-bar" class="wot-user-bar">
- <box id="wot-user-1-bar-image" class="wot-user-bar-image"/>
- <label id="wot-user-1-bar-text" class="wot-user-bar-text" crop="end"/>
- </hbox>
- </vbox>
- <box id="wot-user-1-text-container" class="wot-user-text-container">
- <label id="wot-user-1-text" class="wot-user-text" crop="end"
- onclick="wot_events.click_user(event, 1);"/>
- </box>
- </hbox>
- <label id="wot-user-1-notice" class="wot-user-notice" crop="end"/>
- </vbox>
- <!-- user 2 -->
- <vbox id="wot-user-2" class="wot-user" hidden="true">
- <hbox id="wot-user-2-content" class="wot-user-content">
- <vbox id="wot-user-2-stack" class="wot-user-stack">
- <label id="wot-user-2-header" class="wot-user-header" crop="end"/>
- <hbox id="wot-user-2-bar" class="wot-user-bar">
- <box id="wot-user-2-bar-image" class="wot-user-bar-image"/>
- <label id="wot-user-2-bar-text" class="wot-user-bar-text" crop="end"/>
- </hbox>
- </vbox>
- <box id="wot-user-2-text-container" class="wot-user-text-container">
- <label id="wot-user-2-text" class="wot-user-text" crop="end"
- onclick="wot_events.click_user(event, 2);"/>
- </box>
- </hbox>
- <label id="wot-user-2-notice" class="wot-user-notice" crop="end"/>
- </vbox>
- <!-- message -->
- <hbox id="wot-message" hidden="true"
- onclick="return wot_events.click_message(event);">
- <description id="wot-message-text" crop="end">
- </description>
- </hbox>
- <!-- partner -->
- <vbox id="wot-partner" hidden="true">
- <label id="wot-partner-text" crop="end" value="&wotRating.partner;"/>
- </vbox>
- </vbox>
</menupopup>
<!-- Indicator tooltip -->
diff --git a/content/ratingwindow.js b/content/ratingwindow.js
new file mode 100644
index 0000000..c493042
--- /dev/null
+++ b/content/ratingwindow.js
@@ -0,0 +1,89 @@
+/*
+ ratingwindow.js
+ Copyright © 2013 WOT Services Oy <info at mywot.com>
+
+ This file is part of WOT.
+
+ WOT is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ WOT is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with WOT. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+var wot_rw = {
+
+ RW_URL: "chrome://wot/content/rw/ratingwindow.html",
+ FRAME_ID: "wot-rwframe",
+ is_inited: false,
+
+ get_rw_window: function () {
+ var rw_frame = document.getElementById(this.FRAME_ID);
+ return rw_frame ? rw_frame.contentWindow : null;
+ },
+
+ get_rw_document: function () {
+ var rw_frame = document.getElementById(this.FRAME_ID);
+ return rw_frame ? rw_frame.contentDocument : null;
+ },
+
+ get_rw_wot: function () {
+ var rw = this.get_rw_window();
+ return rw ? rw.wot : null;
+ },
+
+ /* Called when the popup window is hidden */
+ hide_popup: function()
+ {
+ try {
+ if (wot_api_query.message_id.length > 0 &&
+ wot_api_query.message_id !=
+ WOT_SERVICE_XML_QUERY_MSG_ID_MAINT) {
+ wot_prefs.setChar("last_message", wot_api_query.message_id);
+ }
+
+ /* Stores any pending testimonies */
+ wot_core.update();
+ } catch (e) {
+ dump("wot_events.hide_popup: failed with " + e + "\n");
+ }
+ },
+
+ on_rw_open: function (event) {
+
+ var rw = this.get_rw_window(),
+ rw_doc = this.get_rw_document(),
+ rw_wot = this.get_rw_wot();
+
+ if (!rw || !rw_doc || !rw_wot) return;
+
+ if (!this.is_inited) {
+ this.initialize(rw, rw_doc, rw_wot);
+ }
+
+ rw_doc.getElementById("ratings-area").addEventListener("click", function(event){
+ wdump("RW area clicked");
+ }, false);
+
+ },
+
+ initialize: function (rw, rw_doc, rw_wot) {
+
+ var locale_strings = wot_util.get_all_strings();
+ rw.chrome.i18n.loadMessages(JSON.stringify(locale_strings)); // using JSON to push data to sandboxed content
+
+ rw_wot.ratingwindow.localize();
+
+ this.is_inited = true;
+ }
+
+};
+
+wot_modules.push({ name: "wot_rw", obj: wot_rw });
\ No newline at end of file
diff --git a/content/rw/jquery.js b/content/rw/jquery.js
new file mode 100644
index 0000000..198b3ff
--- /dev/null
+++ b/content/rw/jquery.js
@@ -0,0 +1,4 @@
+/*! jQuery v1.7.1 jquery.com | jquery.org/license */
+(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"<!doctype html>":"")+"<html><body>"),cm.close();d=cm.createElement( [...]
+f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k<c.length;k++){l=A.exec(c[k])||[],m=l[1],n=(l[2]||"").split(".").sort(),s=f.event.special[m]| [...]
+{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replac [...]
\ No newline at end of file
diff --git a/content/rw/jquery.menu-aim.js b/content/rw/jquery.menu-aim.js
new file mode 100755
index 0000000..995365b
--- /dev/null
+++ b/content/rw/jquery.menu-aim.js
@@ -0,0 +1,331 @@
+/**
+ * menu-aim is a jQuery plugin for dropdown menus that can differentiate
+ * between a user trying hover over a dropdown item vs trying to navigate into
+ * a submenu's contents.
+ *
+ * menu-aim assumes that you have are using a menu with submenus that expand
+ * to the menu's right. It will fire events when the user's mouse enters a new
+ * dropdown item *and* when that item is being intentionally hovered over.
+ *
+ * __________________________
+ * | Monkeys >| Gorilla |
+ * | Gorillas >| Content |
+ * | Chimps >| Here |
+ * |___________|____________|
+ *
+ * In the above example, "Gorillas" is selected and its submenu content is
+ * being shown on the right. Imagine that the user's cursor is hovering over
+ * "Gorillas." When they move their mouse into the "Gorilla Content" area, they
+ * may briefly hover over "Chimps." This shouldn't close the "Gorilla Content"
+ * area.
+ *
+ * This problem is normally solved using timeouts and delays. menu-aim tries to
+ * solve this by detecting the direction of the user's mouse movement. This can
+ * make for quicker transitions when navigating up and down the menu. The
+ * experience is hopefully similar to amazon.com/'s "Shop by Department"
+ * dropdown.
+ *
+ * Use like so:
+ *
+ * $("#menu").menuAim({
+ * activate: $.noop, // fired on row activation
+ * deactivate: $.noop // fired on row deactivation
+ * });
+ *
+ * ...to receive events when a menu's row has been purposefully (de)activated.
+ *
+ * The following options can be passed to menuAim. All functions execute with
+ * the relevant row's HTML element as the execution context ('this'):
+ *
+ * .menuAim({
+ * // Function to call when a row is purposefully activated. Use this
+ * // to show a submenu's content for the activated row.
+ * activate: function() {},
+ *
+ * // Function to call when a row is deactivated.
+ * deactivate: function() {},
+ *
+ * // Function to call when mouse enters a menu row. Entering a row
+ * // does not mean the row has been activated, as the user may be
+ * // mousing over to a submenu.
+ * enter: function() {},
+ *
+ * // Function to call when mouse exits a menu row.
+ * exit: function() {},
+ *
+ * // Selector for identifying which elements in the menu are rows
+ * // that can trigger the above events. Defaults to "> li".
+ * rowSelector: "> li",
+ *
+ * // You may have some menu rows that aren't submenus and therefore
+ * // shouldn't ever need to "activate." If so, filter submenu rows w/
+ * // this selector. Defaults to "*" (all elements).
+ * submenuSelector: "*",
+ *
+ * // Direction the submenu opens relative to the main menu. Can be
+ * // left, right, above, or below. Defaults to "right".
+ * submenuDirection: "right"
+ * });
+ *
+ * https://github.com/kamens/jQuery-menu-aim
+*/
+(function($) {
+
+ $.fn.menuAim = function(opts) {
+ // Initialize menu-aim for all elements in jQuery collection
+ this.each(function() {
+ init.call(this, opts);
+ });
+
+ return this;
+ };
+
+ function init(opts) {
+ var $menu = $(this),
+ activeRow = null,
+ mouseLocs = [],
+ lastDelayLoc = null,
+ timeoutId = null,
+ options = $.extend({
+ rowSelector: "> li",
+ submenuSelector: "*",
+ submenuDirection: "right",
+ active_selector: ".maintainHover",
+ tolerance: 75, // bigger = more forgivey when entering submenu
+ enter: $.noop,
+ exit: $.noop,
+ activate: $.noop,
+ deactivate: $.noop,
+ exitMenu: $.noop
+ }, opts);
+
+ var MOUSE_LOCS_TRACKED = 5, // number of past mouse locations to track
+ DELAY = 90, // ms delay when user appears to be entering submenu
+ ACTIVATE_DELAY = 5; // ms delay when user appears to hovering sections
+
+ /**
+ * Keep track of the last few locations of the mouse.
+ */
+ var mousemoveDocument = function(e) {
+ mouseLocs.push({x: e.pageX, y: e.pageY});
+
+ if (mouseLocs.length > MOUSE_LOCS_TRACKED) {
+ mouseLocs.shift();
+ }
+ };
+
+ /**
+ * Cancel possible row activations when leaving the menu entirely
+ */
+ var mouseleaveMenu = function() {
+ if (timeoutId) {
+ clearTimeout(timeoutId);
+ }
+
+ // If exitMenu is supplied and returns true, deactivate the
+ // currently active row on menu exit.
+ if (options.exitMenu(this)) {
+ if (activeRow) {
+ options.deactivate(activeRow);
+ }
+
+ activeRow = null;
+ }
+ };
+
+ /**
+ * Trigger a possible row activation whenever entering a new row.
+ */
+ var mouseenterRow = function() {
+ if (timeoutId) {
+ // Cancel any previous activation delays
+ clearTimeout(timeoutId);
+ }
+
+ options.enter(this);
+ possiblyActivate(this);
+ },
+ mouseleaveRow = function() {
+ options.exit(this);
+ };
+
+ var get_active = function() {
+ return $(options.active_selector, $menu).first();
+ };
+
+ /**
+ * Activate a menu row.
+ */
+ var activate = function(row) {
+ activeRow = get_active();
+ if (row == activeRow) {
+ return;
+ }
+
+ if (activeRow) {
+ options.deactivate(activeRow);
+ }
+
+ options.activate(row);
+// activeRow = row;
+ };
+
+ /**
+ * Possibly activate a menu row. If mouse movement indicates that we
+ * shouldn't activate yet because user may be trying to enter
+ * a submenu's content, then delay and check again later.
+ */
+ var possiblyActivate = function(row) {
+ var delay = activationDelay();
+
+ if (delay) {
+ timeoutId = setTimeout(function() {
+ possiblyActivate(row);
+ }, delay);
+ } else {
+ activate(row);
+ }
+ };
+
+ /**
+ * Return the amount of time that should be used as a delay before the
+ * currently hovered row is activated.
+ *
+ * Returns 0 if the activation should happen immediately. Otherwise,
+ * returns the number of milliseconds that should be delayed before
+ * checking again to see if the row should be activated.
+ */
+ var activationDelay = function() {
+
+ if (!activeRow) {
+ activeRow = get_active();
+ }
+
+ if (!activeRow || !$(activeRow).is(options.submenuSelector)) {
+ // If there is no other submenu row already active, then
+ // go ahead and activate immediately.
+ return 0;
+ }
+
+ var offset = $menu.offset(),
+ upperLeft = {
+ x: offset.left,
+ y: offset.top - options.tolerance
+ },
+ upperRight = {
+ x: offset.left + $menu.outerWidth(),
+ y: upperLeft.y
+ },
+ lowerLeft = {
+ x: offset.left,
+ y: offset.top + $menu.outerHeight() + options.tolerance
+ },
+ lowerRight = {
+ x: offset.left + $menu.outerWidth(),
+ y: lowerLeft.y
+ },
+ loc = mouseLocs[mouseLocs.length - 1],
+ prevLoc = mouseLocs[0];
+
+ if (!loc) {
+ return ACTIVATE_DELAY;
+ }
+
+ if (!prevLoc) {
+ prevLoc = loc;
+ }
+
+ if (prevLoc.x < offset.left || prevLoc.x > lowerRight.x ||
+ prevLoc.y < offset.top || prevLoc.y > lowerRight.y) {
+ // If the previous mouse location was outside of the entire
+ // menu's bounds, immediately activate.
+ return ACTIVATE_DELAY;
+ }
+
+ if (lastDelayLoc &&
+ loc.x == lastDelayLoc.x && loc.y == lastDelayLoc.y) {
+ // If the mouse hasn't moved since the last time we checked
+ // for activation status, immediately activate.
+ return 0;
+ }
+
+ // Detect if the user is moving towards the currently activated
+ // submenu.
+ //
+ // If the mouse is heading relatively clearly towards
+ // the submenu's content, we should wait and give the user more
+ // time before activating a new row. If the mouse is heading
+ // elsewhere, we can immediately activate a new row.
+ //
+ // We detect this by calculating the slope formed between the
+ // current mouse location and the upper/lower right points of
+ // the menu. We do the same for the previous mouse location.
+ // If the current mouse location's slopes are
+ // increasing/decreasing appropriately compared to the
+ // previous's, we know the user is moving toward the submenu.
+ //
+ // Note that since the y-axis increases as the cursor moves
+ // down the screen, we are looking for the slope between the
+ // cursor and the upper right corner to decrease over time, not
+ // increase (somewhat counterintuitively).
+ function slope(a, b) {
+ return (b.y - a.y) / (b.x - a.x);
+ }
+
+ var decreasingCorner = upperRight,
+ increasingCorner = lowerRight;
+
+ // Our expectations for decreasing or increasing slope values
+ // depends on which direction the submenu opens relative to the
+ // main menu. By default, if the menu opens on the right, we
+ // expect the slope between the cursor and the upper right
+ // corner to decrease over time, as explained above. If the
+ // submenu opens in a different direction, we change our slope
+ // expectations.
+ if (options.submenuDirection == "left") {
+ decreasingCorner = lowerLeft;
+ increasingCorner = upperLeft;
+ } else if (options.submenuDirection == "below") {
+ decreasingCorner = lowerRight;
+ increasingCorner = lowerLeft;
+ } else if (options.submenuDirection == "above") {
+ decreasingCorner = upperLeft;
+ increasingCorner = upperRight;
+ }
+
+ var decreasingSlope = slope(loc, decreasingCorner),
+ increasingSlope = slope(loc, increasingCorner),
+ prevDecreasingSlope = slope(prevLoc, decreasingCorner),
+ prevIncreasingSlope = slope(prevLoc, increasingCorner);
+
+ if (decreasingSlope < prevDecreasingSlope &&
+ increasingSlope > prevIncreasingSlope) {
+ // Mouse is moving from previous location towards the
+ // currently activated submenu. Delay before activating a
+ // new menu row, because user may be moving into submenu.
+ lastDelayLoc = loc;
+ return DELAY;
+ }
+ else if (decreasingSlope > prevDecreasingSlope && increasingSlope < prevIncreasingSlope) {
+ // if mouse goes away from submenu but still angled, apply delay.
+ lastDelayLoc = loc;
+ return DELAY;
+ }
+
+ lastDelayLoc = null;
+ return 0;
+ };
+
+ /**
+ * Hook up initial menu events
+ */
+ $menu
+ .mouseleave(mouseleaveMenu)
+ .find(options.rowSelector)
+ .mouseenter(mouseenterRow)
+ .mouseleave(mouseleaveRow);
+ $(document).mousemove(mousemoveDocument);
+
+ }
+})(jQuery);
+
diff --git a/content/rw/keeper.js b/content/rw/keeper.js
new file mode 100644
index 0000000..c90cddb
--- /dev/null
+++ b/content/rw/keeper.js
@@ -0,0 +1,83 @@
+/*
+ comments.js
+ Copyright © 2013 - WOT Services Oy <info at mywot.com>
+
+ This file is part of WOT.
+
+ WOT is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ WOT is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with WOT. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+$.extend(wot, { keeper: {
+
+ STATUSES: {
+ LOCAL: 1,
+ SUBMITTING: 2
+ },
+
+ /* Comment-specific methods to work with Keeper */
+
+ get_comment: function (target) {
+ // returns comment data stored locally for the specified target. Comment data is {body, timestamp, votes, wcid}
+ var data = wot.keeper.get_by_name(target, "comment");
+ if (data) {
+ return data;
+ } else {
+ return {};
+ }
+ },
+
+ save_comment: function (target, comment_body, wcid, votes, status) {
+// console.log("keeper.save_comment()");
+
+ var data = {
+ timestamp: Date.now(),
+ target: target,
+ comment: comment_body,
+ wcid: wcid,
+ votes: votes, // votes as object to be able to restore them to UI
+ status: status || wot.keeper.STATUSES.LOCAL
+ };
+
+ this.store_by_name(target, "comment", data);
+ },
+
+ remove_comment: function (target) {
+// console.log("keeper.save_comment()");
+ this.remove_by_name(target, "comment");
+ },
+
+ /* Generic methods to work with Keeper */
+
+ get_by_name: function (target, name) {
+ // generic method to get data from local by target and name
+// console.log("keeper.get_by_name()", target, name);
+
+ return wot.prefs.get(wot.keeper._fullname(target, name)) || null;
+ },
+
+ store_by_name: function (target, name, data) {
+// console.log("keeper.store_by_name()", target, name, data);
+ wot.prefs.set(wot.keeper._fullname(target, name), data);
+ },
+
+ remove_by_name: function (target, name) {
+// console.log("keeper.remove_by_name()", target, name);
+ wot.prefs.clear(wot.keeper._fullname(target, name));
+ },
+
+ _fullname: function (target, name) {
+ return "keeper:" + name + ":" + target;
+ }
+
+}});
\ No newline at end of file
diff --git a/content/rw/ratingwindow.html b/content/rw/ratingwindow.html
new file mode 100644
index 0000000..984f607
--- /dev/null
+++ b/content/rw/ratingwindow.html
@@ -0,0 +1,277 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE html>
+
+<!--
+ ratingwindow.html
+ Copyright © 2009 - 2013 WOT Services Oy <info at mywot.com>
+
+ This file is part of WOT.
+
+ WOT is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ WOT is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with WOT. If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<html>
+<head>
+ <script type="text/javascript" src="chrome://wot/content/rw/jquery.js"></script>
+ <script type="text/javascript" src="chrome://wot/content/rw/jquery.menu-aim.js"></script>
+ <script type="text/javascript" src="chrome://wot/content/rw/wot.js"></script>
+ <script type="text/javascript" src="chrome://wot/content/rw/keeper.js"></script>
+ <!--<script type="text/javascript" src="ga_configure.js"></script>-->
+ <script type="text/javascript" src="chrome://wot/content/rw/ratingwindow.js"></script>
+
+ <style type="text/css">
+ @import "chrome://wot/skin/b/ratingwindow.css";
+ /*@import "skin/include/welcometips.css";*/
+ </style>
+</head>
+<body>
+<div id="wot-ratingwindow">
+
+ <div id="wot-elements">
+ <!-- header -->
+ <div id="wot-header">
+ <div id="header-line-1">
+ <div id="wot-header-logo"></div>
+ <div id="wot-header-links">
+ <div id="wot-header-link-profile" class="wot-header-link"></div>
+ <div id="wot-header-link-forum" class="wot-header-link"></div>
+ <div id="wot-header-link-guide" class="wot-header-link"></div>
+ <div id="wot-header-link-settings" class="wot-header-link"></div>
+ </div>
+ <div id="wot-header-close"></div>
+ </div>
+ <div id="header-line-2">
+ <span id="wot-title-text"></span>
+ <span id="hostname-text"></span>
+ </div>
+ </div>
+
+ <div id="ratings-area">
+ <!-- rating header -->
+ <div id="wot-myratings-header">
+ <div id="myrating-header"></div>
+ <div id="wot-myrating-0-header"></div>
+ <div id="wot-myrating-4-header"></div>
+ </div>
+ <!-- rating 0 / Trustworthiness -->
+ <div id="wot-rating-0" class="wot-rating">
+ <div id="wot-rating-0-data" class="wot-rating-data" component="0">
+ <div id="wot-rating-0-testimony" class="wot-rating-testimony">
+ <div id="wot-rating-0-help" class="wot-rating-help">
+ <div id="wot-rating-0-helptext" class="wot-rating-helptext"></div>
+ <div id="wot-rating-0-helplink" class="wot-rating-helplink"></div>
+ </div>
+ <div class="wot-rating-bounds">
+ <div id="wot-rating-0-boundleft" class="rating-bound-left"></div>
+ <div id="wot-rating-0-boundright" class="rating-bound-right"></div>
+ </div>
+ <div id="wot-rating-0-stack" class="wot-rating-stack" component="0">
+ <div id="wot-rating-0-slider" class="wot-rating-slider"></div>
+ <div id="wot-rating-0-indicator" class="wot-rating-indicator"></div>
+ </div>
+ <div id="wot-rating-0-delete" class="rating-delete">
+ <div id="wot-rating-0-deleteicon" class="rating-delete-icon"></div>
+ <!--<div id="wot-rating-0-deletelabel" class="rating-deletelabel"></div>-->
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- rating 4 / Child Safety -->
+ <div id="wot-rating-4" class="wot-rating">
+ <div id="wot-rating-4-data" class="wot-rating-data" component="4">
+ <div id="wot-rating-4-testimony" class="wot-rating-testimony">
+ <div id="wot-rating-4-help" class="wot-rating-help">
+ <div id="wot-rating-4-helptext" class="wot-rating-helptext"></div>
+ <div id="wot-rating-4-helplink" class="wot-rating-helplink"></div>
+ </div>
+ <div class="wot-rating-bounds">
+ <div id="wot-rating-4-boundleft" class="rating-bound-left"></div>
+ <div id="wot-rating-4-boundright" class="rating-bound-right"></div>
+ </div>
+ <div id="wot-rating-4-stack" class="wot-rating-stack" component="4">
+ <div id="wot-rating-4-slider" class="wot-rating-slider"></div>
+ <div id="wot-rating-4-indicator" class="wot-rating-indicator"></div>
+ </div>
+ <div id="wot-rating-4-delete" class="rating-delete">
+ <div id="wot-rating-4-deleteicon" class="rating-delete-icon"></div>
+ <!--<div id="wot-rating-4-deletelabel" class="rating-deletelabel"></div>-->
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="user-comm-activity">
+ <div id="wot-user-0-header" class="wot-user-header"></div>
+ <div id="user-activityscore"></div>
+ <div id="wot-user-0-notice" class="wot-user-notice"></div>
+ </div>
+
+ <div id="rated-votes">
+ <div id="voted-categories">
+ <div id="voted-categories-content"></div>
+ </div>
+ <div id="change-ratings"></div>
+ </div>
+ </div>
+
+ <div id="main-area" class="view-mode">
+ <div id="reputation-info">
+ <div id="wot-rating-header-wot"></div>
+ <div class="rep-info-sections">
+ <div id="rep-block">
+
+ <div id="rep-0" class="rep-tr-block">
+ <div id="wot-rating-0-header" class="wot-rating-header"></div>
+ <div class="rating-values">
+ <div id="wot-rating-0-reputation" class="wot-rating-reputation"></div>
+ <div id="wot-rating-0-confidence" class="wot-rating-confidence"></div>
+ <div class="rating-legend-wrapper">
+ <div class="rating-legend"></div>
+ </div>
+ </div>
+ </div>
+
+ <div id="rep-4" class="rep-cs-block">
+ <div id="wot-rating-4-header" class="wot-rating-header"></div>
+ <div class="rating-values">
+ <div id="wot-rating-4-reputation" class="wot-rating-reputation"></div>
+ <div id="wot-rating-4-confidence" class="wot-rating-confidence"></div>
+ <div class="rating-legend-wrapper">
+ <div class="rating-legend"></div>
+ </div>
+ </div>
+ </div>
+
+ <!-- TODO: simplify this -->
+ <div id="wot-scorecard">
+ <div id="wot-scorecard-content">
+ <span id="wot-scorecard-visit" class="wot-scorecard-text"></span>
+ </div>
+ </div>
+ </div>
+
+ <div class="categories-area" style="display: block;">
+ <ul id="tr-categories-list"></ul>
+ </div>
+ </div>
+
+ </div>
+
+ <!-- Welcome Tip area -->
+ <div id="wot-welcometip">
+ <!--<div class="wt-rw-header">-->
+ <!--<span class="wt-rw-header-text">Share your experiences!</span>-->
+ <!--<div class="wt-rw-close"></div>-->
+ <!--</div>-->
+ <!--<div class="wt-rw-body">-->
+ <!--<p>WOT shows website reputations based on experiences from millions of users.</p>-->
+ <!--<p>Leave your own rating by clicking the colored bars to indicate what you think of the site. Your rating helps other users surf safer.</p>-->
+ <!--<p class="wot-c"><a id='wt-learnmore-link'>Learn more</a> about WOT.</p>-->
+ <!--</div>-->
+ </div>
+
+ <!-- Rate mode: categories selector area -->
+ <div id="categories-selection-area">
+ <div class="category-description"></div>
+ <div class="category-title"></div>
+ <div class="category-selector">
+ <ul class="dropdown-menu"></ul>
+ </div>
+ </div>
+
+ <div id="commenting-area">
+ <div class="comment-title"></div>
+ <div id="comment-side-hint"></div>
+ <div id="comment-register">
+ <div id="comment-register-text"></div><br/>
+ <div><span id="comment-register-link"></span></div>
+ </div>
+ <div id="comment-captcha">
+ <div id="comment-captcha-text"></div><br/>
+ <div><span id="comment-captcha-link"></span></div>
+ </div>
+ <div class="user-comment-wrapper">
+ <textarea id="user-comment" placeholder=""></textarea>
+ <div id="comment-bottom-hint"></div>
+ </div>
+ </div>
+
+ <div id="thanks-area">
+ <div class="thanks-text"></div>
+ <div class="thanks-activityscore">
+ <span class="thanks-activityscore-text"></span>
+ <span class="thanks-activityscore-number"></span>
+ </div>
+ <div class="thanks-ratemore"></div>
+ </div>
+ </div>
+
+ <div id="bottom-area">
+
+ <div id="user-communication">
+ <div class="user-comm-social">
+ <!-- message -->
+ <div id="wot-message">
+ <div id="wot-message-text"></div>
+ </div>
+ <div class="social-buttons">
+
+ </div>
+ </div>
+ </div>
+
+ <div id="rate-buttons">
+ <div class="buttons-wrapper">
+ <div class="left-side">
+ <div id="btn-delete" title="">
+ <div class="btn-delete_icon"></div>
+ <div class="btn-delete_label"></div>
+ </div>
+ </div>
+ <div class="right-side">
+ <div id="btn-comment" class="rw-button" title=""></div>
+ <div id="btn-cancel" class="rw-button" title=""></div>
+ <div id="btn-submit" class="rw-button btn-submit disabled" title=""></div>
+ </div>
+ </div>
+ </div>
+
+ <div id="ok-button">
+ <div class="buttons-wrapper">
+ <div class="left-side"></div>
+ <div class="right-side">
+ <div id="btn-thanks-ok" class="rw-button" title=""></div>
+ </div>
+ </div>
+ </div>
+
+ </div>
+
+ <!-- Old trash here -->
+ <div id="wot-user-0-text" class="wot-user-text" style="display: none;"></div>
+
+ <div id="wot-user-0-bar" class="wot-user-bar" style="display: none;">
+ <div id="wot-user-0-bar-image" class="wot-user-bar-image"></div>
+ </div>
+
+ <div id="wot-user-0-stack" class="wot-user-stack" style="display: none;"></div>
+ <div id="wot-user-0-text-container" class="wot-user-text-container" style="display: none;"></div>
+
+ </div>
+
+</div>
+<script type="text/javascript" src="ga_init.js"></script>
+</body>
+</html>
diff --git a/content/rw/ratingwindow.js b/content/rw/ratingwindow.js
new file mode 100644
index 0000000..9350720
--- /dev/null
+++ b/content/rw/ratingwindow.js
@@ -0,0 +1,2088 @@
+/*
+ ratingwindow.js
+ Copyright © 2009 - 2013 WOT Services Oy <info at mywot.com>
+
+ This file is part of WOT.
+
+ WOT is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ WOT is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with WOT. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+var chrome = {
+ extension: {
+ getBackgroundPage: function () {
+ return { // background page object
+
+ wot: {
+ prefs: {
+ get: function (k) {return k;}
+ }
+ }
+
+ };
+ }
+ },
+
+ i18n: {
+
+ messages: {},
+
+ getMessage: function(c) {
+ return chrome.i18n.messages[c];
+ },
+
+ loadMessages: function (json_data) {
+ chrome.i18n.messages = JSON.parse(json_data);
+ }
+
+ }
+};
+
+$.extend(wot, { ratingwindow: {
+ MAX_VOTED_VISIBLE: 4, // how many voted categories we can show in one line
+ sliderwidth: 154,
+ slider_shift: -4, // ajustment
+ opened_time: null,
+ was_in_ratemode: false,
+ timer_save_button: null,
+ state: {}, // rating state
+ local_comment: null,
+ is_registered: false, // whether user has an account on mywot.com
+ delete_action: false, // remembers whether user is deleting rating
+ prefs: {}, // shortcut for background preferences
+
+ get_bg: function () {
+ // just a shortcut
+ return chrome.extension.getBackgroundPage();
+ },
+
+ is_rated: function (state) {
+ var ratings = wot.ratingwindow.getcached().value,
+ is_rated = false;
+
+// console.log("is_rated()", state, ratings);
+
+ state = state ? state : ratings;
+
+ // Detect if the website is rated by user, to activate proper mode
+ wot.components.forEach(function (i) {
+ var name = i.name;
+// console.log(name, state[name]);
+ if (state[name] && state[name].t >= 0) {
+ is_rated = true;
+ return false;
+ }
+ });
+
+ return is_rated;
+ },
+
+ updatestate: function(target, data)
+ {
+ /* initialize on target change */
+ if (this.state.target != target) {
+ this.finishstate(false);
+ this.state = { target: target, down: -1 };
+ }
+
+ var state = {};
+
+ /* add existing ratings to state */
+ if (data && data.status == wot.cachestatus.ok) {
+ wot.components.forEach(function(item) {
+
+ var datav = data.value[item.name];
+
+ if (datav && datav.t >= 0) {
+ state[item.name] = { t: datav.t };
+ }
+ });
+ }
+
+ /* remember previous state */
+ this.state = $.extend(state, this.state);
+ },
+
+ setstate: function (component, t) {
+ // This only changes the user's testimonies' state
+ var new_value = {};
+ if (t >= 0) {
+ new_value = { t: parseInt(t) };
+ } else {
+ new_value = { t: -1 };
+ }
+
+ this.state[component] = new_value;
+ this.update_catsel_state();
+ },
+
+ delete_testimony: function(component) {
+ var _rw = wot.ratingwindow;
+ _rw.setstate(component, -1);
+ _rw.state.down = -1;
+ _rw.rate_control.updateratings({ name: component, t: -1 });
+ },
+
+ update_catsel_state: function () {
+ // update category selector based on user's testimonies
+ var cache = wot.ratingwindow.getcached();
+ var identified = (cache.value && cache.value.cats) ? cache.value.cats : [];
+ wot.ratingwindow.cat_selector.set_state(this.state, identified);
+ },
+
+ cat_difference: function (is_rated) {
+ var _rw = wot.ratingwindow;
+ var cache = _rw.getcached(),
+ cached_cats = (cache.value && cache.value.cats) ? cache.value.cats : {};
+ var old_votes = wot.select_voted(cached_cats), // from the cache. Object.
+ new_votes_arr = [], // user's votes. Array.
+ new_votes_obj = {},
+ diff = {}, // the difference in votes
+ cat = {};
+
+ // If user removed testimonies, we have to remove votes also. Otherwise take votes from the category selector
+ if (is_rated) {
+ new_votes_arr = _rw.cat_selector.get_user_votes(false); // get votes as array
+ }
+
+// console.log("old", old_votes);
+// console.log("new", new_votes_arr);
+
+ for(var i in new_votes_arr) {
+ cat = new_votes_arr[i];
+ new_votes_obj[cat.id] = cat.v;
+ // if the category voted the same previously, skip it
+ if (!(old_votes[cat.id] && old_votes[cat.id].v == cat.v)) {
+ diff[cat.id] = cat.v; // the category hasn't been voted previously
+ }
+ }
+
+ // look for removals of votes
+ for(cat in old_votes) {
+ if (new_votes_obj[cat] === undefined) {
+ // the category has been unvoted in current session
+ diff[cat] = 0;
+ }
+ }
+
+// console.log("diff", diff);
+ return diff;
+ },
+
+ _make_votes: function (diff) {
+ var votes = [];
+ for (var cat in diff) {
+ votes.push(String(cat) + ":" + diff[cat]);
+ }
+
+// console.log("votes", votes);
+
+ if (votes.length > 0) {
+ return votes.join("/") + "/";
+ } else {
+ return "";
+ }
+
+ },
+
+ has_votes: function () {
+ var _rw = wot.ratingwindow,
+ votes = _rw.cat_selector.get_user_votes(false);
+ return votes.length > 0;
+ },
+
+ finishstate: function(unload)
+ {
+ var rw = wot.ratingwindow,
+ bg = rw.get_bg();
+
+ try {
+ var bgwot = bg.wot, // shortage for perfomance and readability
+ target = "",
+ is_rated = false,
+ testimonies_changed = false,
+ comment_changed = false,
+ has_comment = false,
+ user_comment = $("#user-comment").val().trim(),
+ user_comment_id = 0,
+ cached = {},
+ changed_votes = {}, // user votes diff as an object
+ changed_votes_str = "", // user's votes diff for categories as string
+ votes = rw.cat_selector.get_user_votes(true), // user's votes for categories as object {cat_id : vote }
+ has_up_votes = rw.has_1upvote(votes),
+ votes_changed = false; // just a flag that votes have been changed
+
+ /* message was shown */
+
+ // on unload finishing, restore previous message or remove current
+ if (unload && bgwot.core.usermessage && bgwot.core.usermessage.previous) {
+ bgwot.core.usermessage = bgwot.core.usermessage.previous;
+ }
+
+ if (bgwot.core.unseenmessage()) {
+ bgwot.prefs.set("last_message", bg.wot.core.usermessage.id);
+ }
+
+ if (rw.state.target) {
+ target = rw.state.target;
+ cached = rw.getcached();
+ is_rated = rw.is_rated(rw.state);
+ changed_votes = rw.cat_difference(is_rated);
+ votes_changed = !wot.utils.isEmptyObject(changed_votes);
+
+ // Whether ratings OR categories were changed?
+ testimonies_changed = (rw.was_in_ratemode && (bgwot.cache.cacheratingstate(target, rw.state, changed_votes) || votes_changed));
+
+ has_comment = (user_comment.length > 0);
+
+ if (cached.comment && cached.comment.comment && cached.comment.comment.length > 0) {
+ user_comment_id = cached.comment.wcid;
+ comment_changed = (cached.comment.comment != user_comment);
+ } else {
+ comment_changed = has_comment; // since there was no comment before
+ user_comment_id = 0; // no previous comment, set cid to zero
+ }
+ }
+
+// bg.console.log("testimonies_changed:", testimonies_changed);
+// bg.console.log("comment_changed:", comment_changed);
+// bg.console.log("is_rated:", is_rated);
+// bg.console.log("has_comment:", has_comment);
+
+ /* if user's testimonies or categories were changed, store them in the cache and submit */
+ if (testimonies_changed) {
+
+ // don't show warning screen immediately after rating and set "expire to" flag
+ var warned_expire = (new Date()).getTime() + wot.expire_warned_after;
+ bgwot.cache.setflags(target, {warned: true, warned_expire: warned_expire });
+
+ /* submit new ratings */
+ var params = {};
+
+ wot.components.forEach(function(item) {
+ if (rw.state[item.name]) {
+ params["testimony_" + item.name] =
+ rw.state[item.name].t;
+ }
+ });
+
+ if (votes_changed) {
+ params.votes = rw._make_votes(changed_votes);
+ }
+
+ bgwot.api.submit(target, params);
+
+ // count testimony event
+ // TODO: add either label or number to count voted categories AND/OR whether ratings were deleted
+ bgwot.ga.fire_event(wot.ga.categories.RW, wot.ga.actions.RW_TESTIMONY);
+ } else {
+// bg.console.log("No testimonies & votes to submit them. Ignored.");
+ }
+
+ if (unload) { // RW was closed by browser (not by clicking "Save")
+// bg.console.log("RW triggered finish state during Unload");
+
+ if ((comment_changed)) {
+// bg.console.log("The comment seems to be changed");
+ // when comment body is changed, we might want to store it locally
+ bgwot.keeper.save_comment(target, user_comment, user_comment_id, votes, wot.keeper.STATUSES.LOCAL);
+ }
+
+ } else { // User clicked Save
+ if ((comment_changed || votes_changed) && has_up_votes) {
+ // Comment should be submitted, if (either comment OR categories votes were changed) AND at least one up vote is given
+ if (has_comment) {
+// bg.console.log("SUBMIT COMMENT");
+
+ // If user can't leave a comment for a reason, accept the comment locally, otherwise submit it silently
+ var keeper_status = (rw.comments.allow_commenting && rw.is_registered) ? wot.keeper.STATUSES.SUBMITTING : wot.keeper.STATUSES.LOCAL;
+ bgwot.keeper.save_comment(target, user_comment, user_comment_id, votes, keeper_status);
+
+ if (rw.comments.allow_commenting && rw.is_registered) {
+ // TODO: send GA signal about submitting a comment
+ bgwot.api.comments.submit(target, user_comment, user_comment_id, rw._make_votes(votes));
+ }
+
+ } else {
+ if (comment_changed) {
+ // remove the comment
+// bg.console.log("REMOVE COMMENT");
+ bgwot.keeper.remove_comment(target);
+ if (rw.is_registered) {
+ bgwot.api.comments.remove(target);
+ // TODO: send GA signal about removing a comment
+ }
+ }
+ }
+ }
+ }
+
+ /* update all views */
+ bgwot.core.update(false); // explicitly told to not update the rating window
+ } catch (e) {
+ bg.console.log("ratingwindow.finishstate: failed with ", e);
+ }
+ },
+
+ /* helpers */
+
+ navigate: function(url, context, fragment, keep_opened)
+ {
+ try {
+ fragment = fragment ? "#" + fragment : "";
+ var contextedurl = wot.contextedurl(url, context) + fragment;
+ chrome.tabs.create({ url: contextedurl, active:!keep_opened },
+ function(tab) {
+ if (!keep_opened) wot.ratingwindow.hide();
+ }
+ );
+ if (!keep_opened) wot.ratingwindow.hide();
+ } catch (e) {
+ console.error("ratingwindow.navigate: failed with ", e);
+ }
+ },
+
+ getcached: function()
+ {
+ var _rw = wot.ratingwindow;
+ if (_rw.current.target && _rw.current.cached &&
+ _rw.current.cached.status == wot.cachestatus.ok) {
+ return _rw.current.cached;
+ }
+ return { value: {} };
+ },
+
+ getrating: function(e, stack)
+ {
+ var noopinion_threshold = 102;
+ try {
+ if (this.getcached().status == wot.cachestatus.ok) {
+ var slider = $(".wot-rating-slider", stack);
+
+ /* rating from slider position */
+ var position = 100 * (wot.ratingwindow.slider_shift + e.clientX - slider.offset().left) /
+ wot.ratingwindow.sliderwidth;
+
+ if (e.type == "mouseleave") position = noopinion_threshold + 1;
+
+ /* sanitize the rating value */
+ if (position < 0) {
+ position = 0;
+ } else if (position >= 100 && position <= noopinion_threshold) {
+ position = 100;
+ } else if (position > noopinion_threshold) {
+ position = -1;
+ } else {
+ position = position.toFixed();
+ }
+
+ return position;
+ }
+ } catch (e) {
+ console.log("ratingwindow.getrating: failed with ", e);
+ }
+
+ return -1;
+ },
+
+ /* user interface */
+
+ current: {},
+
+ updatecontents: function()
+ {
+ var bg = chrome.extension.getBackgroundPage();
+ var cached = this.getcached(),
+ visible_hostname = "",
+ rw_title = "";
+
+ /* update current rating state */
+ this.updatestate(this.current.target, cached);
+ var normalized_target = cached.value.normalized ? cached.value.normalized : this.current.target;
+
+ var $_hostname = $("#hostname-text"),
+ $_wot_title_text = $("#wot-title-text");
+
+ /* target */
+ if (this.current.target && cached.status == wot.cachestatus.ok) {
+ visible_hostname = bg.wot.url.decodehostname(normalized_target);
+ rw_title = wot.i18n("messages", "ready");
+ } else if (cached.status == wot.cachestatus.busy) {
+ rw_title = wot.i18n("messages", "loading");
+ } else if (cached.status == wot.cachestatus.error) {
+ rw_title = wot.i18n("messages", "failed");
+ } else {
+ rw_title = wot.i18n("messages", this.current.status || "notavailable");
+ }
+
+ $_hostname.text(visible_hostname);
+ $_wot_title_text.text(rw_title);
+
+ /* reputations */
+ /* ratings */
+
+ wot.components.forEach(function(item) {
+
+ var cachedv = cached.value[item.name];
+ var rep_level = (cached.status == wot.cachestatus.ok) ?
+ wot.getlevel(wot.reputationlevels,
+ (cachedv && cachedv.r != null) ? cachedv.r : -1).name : "r0";
+
+ $("#wot-rating-" + item.name + "-reputation").attr("reputation", rep_level);
+
+ $("#wot-rating-" + item.name + "-confidence").attr("confidence",
+ (cached.status == wot.cachestatus.ok) ?
+ wot.getlevel(wot.confidencelevels,
+ (cachedv && cachedv.c != null)? cachedv.c : -1).name : "c0");
+
+ var $_rep_legend = $("#rep-" + item.name + " .rating-legend");
+ $_rep_legend.attr("r", rep_level);
+ $_rep_legend.text(wot.get_level_label(item.name, rep_level, false));
+
+ });
+ this.rate_control.updateratings();
+
+ /* message */
+
+ var msg = bg.wot.core.usermessage; // usual case: show a message from WOT server
+ var $_wot_message = $("#wot-message");
+ // if we have something to tell a user
+ if (msg.text) {
+ var status = msg.type || "";
+ $("#wot-message-text")
+ .attr("url", msg.url || "")
+ .attr("status", status)
+ .text(msg.text);
+
+ $_wot_message.attr("status", status).attr("msg_id", msg.id).show();
+ } else {
+ $_wot_message.hide();
+ }
+
+ /* content for user (messages / communications) */
+ $(".wot-user").hide();
+
+ // TODO: rewrite below
+ var index = 0,
+ item = (bg.wot.core.usercontent && bg.wot.core.usercontent.length > 0) ? bg.wot.core.usercontent[0] : {},
+ user_header = wot.i18n("activityscore","text"),
+ user_as = "",
+ $_user_text = $("#wot-user-0-text"),
+ as_notice = wot.i18n("activityscore", "next");
+
+ if (item.label) {
+ user_as = item.label;
+ }
+
+ // insert next level name
+ var level_name = '<span class="user-level">' +
+ wot.i18n("activityscore", wot.get_user_level(user_as, true).name) +
+ '</span>';
+
+ as_notice = as_notice.replace("{NEXT_LEVEL}", level_name);
+
+ $("#wot-user-0-header").text(wot.i18n("activityscore", "text"));
+ $("#user-activityscore").text(user_as);
+
+ $(".thanks-activityscore-text").text(user_header); // on the "Thank you" screen
+ $(".thanks-activityscore-number").text(user_as); // on the "Thank you" screen
+ $(".thanks-ratemore").html(as_notice || ""); // on the "Thank you" screen
+
+ $_user_text.attr("url", item.url || "");
+
+ if (user_as < wot.AS_LEVELS.PLATINUM) {
+ $("#wot-user-0-notice").html(as_notice).show();
+ } else {
+ $("#wot-user-0-notice").hide();
+ }
+
+ if (item.text) {
+ $_user_text.text(item.text);
+ $("#wot-user-0").css("display", "block");
+ }
+
+ /* partner */
+ $("#wot-partner").attr("partner", wot.partner || "");
+ },
+
+ insert_categories: function (cat_list, $_target) {
+ $_target.hide(); // to prevent blinking during modification
+ $("li", $_target).remove(); // clean the list
+
+ for (var i in cat_list) {
+ var cdata = cat_list[i];
+ var cat_id = cdata.id,
+ cat_conf = wot.getlevel(wot.confidencelevels, cdata.c).name,
+ cgroup_style = wot.get_category_css(cat_id),
+ $_new_cat = $("<li class='cat-item'></li>"),
+ cat_text = wot.get_category_name(cat_id, true),
+ $_ico = $("<div class='ico'></div>");
+
+ if (cat_text) {
+ $_new_cat.text(cat_text);
+ $_new_cat.addClass([cgroup_style, cat_conf].join(" ")); // set group style, confidence style
+ $_ico.addClass([cgroup_style, cat_conf].join(" "));
+ $_new_cat.prepend($_ico);
+ $_target.append($_new_cat);
+ }
+ }
+ $_target.show();
+ },
+
+ update_categories: function () {
+// console.log("wot.ratingwindow.update_categories()");
+ var _rw = wot.ratingwindow,
+ cached = _rw.getcached(),
+ $_tr_list = $("#tr-categories-list");
+
+ try {
+ // delete categories from the visible area
+ _rw.insert_categories({}, $_tr_list);
+
+ if (this.current.target && cached.status == wot.cachestatus.ok && cached.value) {
+ var cats = cached.value.cats;
+ if (cats != null) {
+ var sorted = wot.rearrange_categories(wot.select_identified(cats)); // sort categories and split into two parts (TR, CS)
+ _rw.insert_categories(sorted.all, $_tr_list);
+ }
+ }
+ } catch (e) {
+ console.error("Failed to render categories", e);
+ }
+ },
+
+ update: function(target, data)
+ {
+ chrome.windows.getCurrent(function(obj) {
+ chrome.tabs.getSelected(obj.id, function(tab) {
+ var _rw = wot.ratingwindow;
+ try {
+ if (tab.id == target.id) {
+ // TODO: check whether target is changed. If not, then don't update
+ _rw.current = data || {};
+ _rw.updatecontents();
+ _rw.update_categories();
+
+ if (_rw.is_registered) {
+ // ask server if there is my comment for the website
+ _rw.comments.get_comment(data.target);
+ } else {
+ var bg = chrome.extension.getBackgroundPage();
+ bg.wot.core.update_ratingwindow_comment(); // don't allow unregistered addons to comment
+ }
+
+ _rw.modes.reset();
+ _rw.modes.auto();
+ }
+ } catch (e) {
+ console.log("ratingwindow.update: failed with ", e);
+ }
+ });
+ });
+ },
+
+ update_comment: function (cached, local_comment, captcha_required) {
+ wot.log("update_comment()", cached);
+
+ var _rw = wot.ratingwindow,
+ _comments = wot.ratingwindow.comments,
+ data = {},
+ bg = chrome.extension.getBackgroundPage(),
+ is_unsubmitted = false;
+
+ _rw.current.cached = cached; // update current cached state
+ _rw.local_comment = local_comment; // keep locally stored comment
+
+ if (cached && cached.comment) {
+ data = cached.comment;
+ _rw.comments.captcha_required = captcha_required || false;
+ }
+
+ var error_code = data.error_code || 0;
+
+ _comments.allow_commenting = ([
+ wot.comments.error_codes.AUTHENTICATION_FAILED,
+ wot.comments.error_codes.COMMENT_NOT_ALLOWED,
+ wot.comments.error_codes.IS_BANNED
+ ].indexOf(error_code) < 0); // if none of these codes are found
+
+ _comments.is_banned = (error_code == wot.comments.error_codes.IS_BANNED);
+
+ // If there is a locally stored comment, use it if it's newer than server-stored one
+ if (local_comment && !wot.utils.isEmptyObject(local_comment)) {
+
+ // If server-side comment is newer, than drop locally stored one
+ if (local_comment.timestamp && data.timestamp && data.timestamp >= local_comment.timestamp) {
+ // Remove a comment from keeper
+ bg.wot.keeper.remove_comment(local_comment.target);
+ _rw.local_comment = null;
+ } else {
+ data.comment = local_comment.comment;
+ data.timestamp = local_comment.timestamp;
+ data.wcid = data.wcid === undefined ? 0 : data.wcid;
+ is_unsubmitted = true;
+ }
+ }
+
+ // check whether comment exists: "comment" should not be empty, and wcid should not be null (but it can be zero)
+ if (data && data.comment && data.wcid !== undefined) {
+ _comments.posted_comment = data;
+ _comments.set_comment(data.comment);
+ $("#rated-votes").addClass("commented");
+
+ // switch to commenting mode if we have unfinished comment
+ if (is_unsubmitted) {
+ _rw.modes.comment.activate();
+ }
+
+ } else {
+// bg.console.log("no comment to show");
+
+ _comments.set_comment("");
+ $("#rated-votes").removeClass("commented");
+ _comments.posted_comment = {};
+ }
+
+ // change appearance of commenting area regarding to permissions
+ if (!_rw.is_registered) {
+ // show the invitation to create an account
+ _rw.comments.show_register_invitation();
+
+ } else {
+ if (_rw.comments.captcha_required) {
+ _rw.comments.show_captcha_invitation();
+
+ } else if (_rw.comments.is_banned) {
+ // this is considered below
+ }
+ }
+
+ _comments.update_button(_rw.modes.current_mode, _comments.allow_commenting && !_comments.is_banned);
+ },
+
+ hide: function()
+ {
+ window.close();
+ },
+
+ count_window_opened: function () {
+ // increase amount of times RW was shown (store to preferences)
+
+ wot.log("RW: count_window_opened");
+
+ var bg = chrome.extension.getBackgroundPage();
+ var counter = bg.wot.prefs.get(wot.engage_settings.invite_to_rw.pref_name);
+ counter = counter + 1;
+ bg.wot.prefs.set(wot.engage_settings.invite_to_rw.pref_name, counter);
+ },
+
+ reveal_ratingwindow: function (no_animation) {
+ var $wtip = $("#wot-welcometip");
+ if (no_animation) {
+ $wtip.hide();
+ } else {
+ $wtip.animate({"height": 0, "opacity": 0.2}, {
+ duration: 100,
+ complete: function(){
+ $wtip.hide();
+ }
+ });
+ }
+ },
+
+ show_welcome_tip: function (type) {
+ // use small delay to allow GA script to initialize itself
+ window.setTimeout(function(){
+
+ $("#wot-welcometip").addClass(type).fadeIn();
+
+ // fire the event to GA, providing amount of minutes from installation to opening rating window
+ var bg = chrome.extension.getBackgroundPage();
+ var timesincefirstrun = Math.round((bg.wot.time_sincefirstrun() + 0.5) / wot.DT.MINUTE);
+ wot.ga.fire_event(wot.ga.categories.WT, wot.ga.actions.WT_RW_SHOWN, String(timesincefirstrun));
+ }, 500);
+ },
+
+ localize: function () {
+ /* texts */
+ wot.components.forEach(function(item) {
+ var n = item.name;
+ $("#wot-rating-" + n + "-header").text(wot.i18n("components", n));
+ $("#wot-myrating-"+ n +"-header").text(wot.i18n("ratingwindow", "question" + n));
+
+ $("#wot-rating-" + n + "-boundleft").text(wot.i18n("testimony", item.name + "_levels_" + wot.getlevel(wot.reputationlevels, 0).name));
+ $("#wot-rating-" + n + "-boundright").text(wot.i18n("testimony", item.name + "_levels_" + wot.getlevel(wot.reputationlevels, 100).name));
+ });
+
+ [
+ { selector: "#myrating-header", text: wot.i18n("ratingwindow", "myrating") },
+ { selector: "#wot-header-link-guide", text: wot.i18n("ratingwindow", "guide") },
+ { selector: "#wot-header-link-forum", text: wot.i18n("ratingwindow", "forum") },
+ { selector: "#wot-header-link-settings",text: wot.i18n("ratingwindow", "settings") },
+ { selector: "#wot-header-link-profile", text: wot.i18n("ratingwindow", "profile") },
+ { selector: "#wot-title-text", text: wot.i18n("messages", "initializing") },
+ { selector: "#wot-rating-header-wot", text: wot.i18n("ratingwindow", "wotrating") },
+ { selector: "#wot-rating-header-my", text: wot.i18n("ratingwindow", "myrating") },
+ { selector: "#wot-scorecard-visit", text: wot.i18n("ratingwindow", "viewscorecard") },
+ { selector: "#wot-scorecard-comment", text: wot.i18n("ratingwindow", "addcomment") },
+ { selector: "#wot-partner-text", text: wot.i18n("ratingwindow", "inpartnership") },
+ { selector: ".wt-rw-header-text", html: wot.i18n("wt", "rw_text_hdr") },
+ { selector: ".wt-rw-body", html: wot.i18n("wt", "rw_text") },
+ { selector: "#wt-rw-btn-ok", text: wot.i18n("wt", "rw_ok") },
+ { selector: ".btn-delete_label", text: wot.i18n("buttons", "delete") },
+ { selector: "#btn-delete", title: wot.i18n("buttons", "delete_title") },
+ { selector: "#btn-cancel", text: wot.i18n("buttons", "cancel") },
+ { selector: "#btn-submit", text: wot.i18n("buttons", "save") },
+ { selector: "#btn-thanks-ok", text: wot.i18n("buttons", "ok") },
+ { selector: ".category-title", text: wot.i18n("ratingwindow", "categories") },
+ { selector: "#change-ratings", text: wot.i18n("ratingwindow", "rerate_change") },
+ { selector: ".comment-title", text: wot.i18n("ratingwindow", "comment") },
+ { selector: "#user-comment", placeholder: wot.i18n("ratingwindow", "comment_placeholder") },
+ { selector: "#comment-side-hint", html: wot.i18n("ratingwindow", "commenthints") },
+ { selector: ".thanks-text", text: wot.i18n("ratingwindow", "thankyou") },
+ { selector: "#comment-register-text", text: wot.i18n("ratingwindow", "comment_regtext") },
+ { selector: "#comment-register-link", text: wot.i18n("ratingwindow", "comment_register") },
+ { selector: "#comment-captcha-text", text: wot.i18n("ratingwindow", "comment_captchatext") },
+ { selector: "#comment-captcha-link", text: wot.i18n("ratingwindow", "comment_captchalink") }
+
+ ].forEach(function(item) {
+ var $elem = $(item.selector);
+ if (item.text) {
+ $elem.text(item.text);
+ } else if (item.html) {
+ $elem.html(item.html);
+ } else if (item.title) {
+ $elem.attr("title", item.title);
+ } else if (item.placeholder) {
+ $elem.attr("placeholder", item.placeholder);
+ }
+ });
+ },
+
+ build_voted_category_html: function (category, vote) {
+
+ var cat_name = wot.get_category_name(category.id, true); // use short name
+ var $_cat_wrapper = $('<div class="votedcategory"></div>'),
+ $_hand = $('<div class="category-hand"><div class="hand-icon"></div></div>'),
+ $_cat_text = $('<div class="category-text"></div>');
+
+ $_hand.addClass(vote == 1 ? "hand-up" : "hand-down");
+ $_hand.attr("title", wot.i18n("ratingwindow", vote == 1 ? "vote_yes" : "vote_no"));
+ $_cat_text.attr("title", cat_name);
+ $_cat_text.text(cat_name);
+ $_cat_wrapper.append($_hand);
+ $_cat_wrapper.append($_cat_text);
+
+ return $_cat_wrapper;
+ },
+
+ update_uservoted: function () {
+ var _rw = wot.ratingwindow;
+ var res = "",
+ up_voted = [],
+ down_voted = [],
+ cat = null,
+ $_change = $("#change-ratings"),
+ $_voted_content = $("#voted-categories-content"),
+ change_link_text = "";
+
+ // try to get user's votes from the category selector (if there are any)
+ var voted = _rw.cat_selector.get_user_votes();
+ if (voted.length > 0) {
+ for (var i = 0; i < voted.length; i++) {
+ cat = voted[i];
+ if (cat.v == 1) {
+ up_voted.push(_rw.build_voted_category_html(cat, cat.v));
+ } else if (cat.v == -1) {
+ down_voted.push(_rw.build_voted_category_html(cat, cat.v));
+ }
+ }
+ } else {
+ // try to get user's votes from cache (server response)
+ voted = wot.select_voted(_rw.getcached().value.cats);
+ for(cat in voted) {
+ if (voted[cat].v == 1) {
+ up_voted.push(_rw.build_voted_category_html(wot.get_category(cat), voted[cat].v));
+ } else if (voted[cat].v == -1) {
+ down_voted.push(_rw.build_voted_category_html(wot.get_category(cat), voted[cat].v));
+ }
+ }
+ }
+
+ $_voted_content.empty();
+
+ if (up_voted.length > 0) {
+
+ up_voted.forEach(function(elem) {
+ $_voted_content.append(elem);
+ });
+
+ down_voted.forEach(function(elem) {
+ $_voted_content.append(elem);
+ });
+
+ var more_voted = up_voted.length + down_voted.length - _rw.MAX_VOTED_VISIBLE;
+
+ if (more_voted > 0) {
+ var $_more = $('<div class="more-categories"></div>');
+ $_more.text("+" + more_voted + " " + wot.i18n("ratingwindow", "morecats"));
+ $_voted_content.append($_more);
+ }
+
+ change_link_text = wot.i18n("ratingwindow", "rerate_change");
+ } else {
+ res = wot.i18n("ratingwindow", "novoted");
+ $_voted_content.text(res);
+ change_link_text = wot.i18n("ratingwindow", "rerate_category");
+ }
+
+ $("#rated-votes").toggleClass("voted", (up_voted.length > 0));
+ $_change.text(change_link_text);
+ },
+
+ has_1upvote: function (votes_obj) {
+ // At least one category must be voted as YES since user gives a rating
+ var _rw = wot.ratingwindow,
+ votes = votes_obj || _rw.cat_selector.get_user_votes(true); // get votes as object {cat_id : vote }
+ for(i in votes) {
+ if (votes[i] == 1) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ is_allowed_submit: function () {
+ var _rw = wot.ratingwindow,
+ testimonies = 0,
+ passed = false,
+ has_1upvote = _rw.has_1upvote(),
+ has_comment = _rw.comments.is_commented(),
+ has_valid_comment = _rw.comments.has_valid_comment();
+
+ // 1. Either TR or CS are rated, OR none of them are rated (e.g. "delete my ratings")
+ for (i in wot.components) {
+ var cmp = wot.components[i].name;
+ if (_rw.state[cmp] && _rw.state[cmp].t !== null && _rw.state[cmp].t >= 0) {
+ testimonies++;
+ }
+ }
+
+ if (has_1upvote) {
+ // if there is a comment, it must be valid, otherwise disallow the submit
+ if ((testimonies > 0 && !has_comment) || has_valid_comment) { // if rated OR commented, then OK
+ passed = true;
+ }
+ } else {
+ if (testimonies == 0 && has_comment == false) {
+ passed = true; // no cats, no testimonies, no comment := "Delete everything" (if there are changes)
+ }
+ }
+
+ return passed;
+ },
+
+ update_submit_button: function (enable) {
+ var _rw = wot.ratingwindow,
+ $_submit = $("#btn-submit"),
+ delete_action = false;
+
+ _rw.timer_save_button = null;
+
+ if (enable) {
+ $_submit.removeClass("disabled");
+ } else if (enable === false) {
+ $_submit.addClass("disabled");
+ } else {
+ enable = _rw.is_allowed_submit();
+ $_submit.toggleClass("disabled", !enable);
+
+ // If user wants to delete ratings, change the text of the button and hide "Delete ratings" button
+ if (enable && !_rw.is_rated(_rw.state) && !_rw.comments.has_valid_comment()) {
+ $_submit.text(wot.i18n("testimony", "delete"));
+ $("#btn-delete").hide();
+ delete_action = true; // remember the reverse of the label
+ }
+ }
+
+ if (!delete_action) {
+ $_submit.text(wot.i18n("buttons", "save"));
+ $("#btn-delete").show();
+ }
+ _rw.delete_action = delete_action;
+ },
+
+ onload: function()
+ {
+ var _rw = wot.ratingwindow;
+ var bg = chrome.extension.getBackgroundPage();
+
+ _rw.opened_time = new Date(); // remember time when RW was opened (for UX measurements)
+ _rw.prefs = bg.wot.prefs; // shortcut
+ wot.cache_locale();
+
+ var first_opening = !_rw.prefs.get(wot.engage_settings.invite_to_rw.pref_name);
+
+ wot.init_categories(_rw.prefs);
+
+ _rw.is_registered = bg.wot.core.is_level("registered");
+
+ /* accessibility */
+ // TODO: use only 1 "global" style on the most top element to specify accessible mode for all children elements
+ $("#wot-header-logo, " +
+ "#wot-header-close, " +
+ ".wot-header-link, " +
+ "#hostname-text, " +
+ ".wot-rating-reputation, " +
+ ".wot-rating-slider, " +
+ ".wot-rating-helplink, " +
+ "#wot-scorecard-content, " +
+ ".wot-scorecard-text, " +
+ ".wot-user-text, " +
+ "#wot-message-text")
+ .toggleClass("accessible", bg.wot.prefs.get("accessible"));
+
+ _rw.localize();
+
+ /* user interface event handlers */
+ var wurls = wot.urls;
+
+ var $_wot_header_logo = $("#wot-header-logo");
+
+ $_wot_header_logo.bind("click", function(event) {
+ if (event.shiftKey) {
+ event.preventDefault();
+ }
+ else {
+ wot.ratingwindow.navigate(wurls.base, wurls.contexts.rwlogo);
+ }
+ });
+
+ $_wot_header_logo.bind("dblclick", function(event) {
+ if (event.shiftKey) {
+ wot.ratingwindow.navigate(chrome.extension.getURL("/settings.html"), wurls.contexts.rwlogo);
+ }
+ });
+
+ $("#wot-header-link-settings").bind("click", function() {
+ wot.ratingwindow.navigate(wurls.settings, wurls.contexts.rwsettings);
+ });
+
+ $("#wot-header-link-profile").bind("click", function() {
+ wot.ratingwindow.navigate(wurls.profile, wurls.contexts.rwprofile);
+ });
+
+ $("#wot-header-link-guide").bind("click", function() {
+ wot.ratingwindow.navigate(wurls.tour, wurls.contexts.rwguide);
+ });
+
+ $("#wot-header-link-forum").bind("click", function() {
+ wot.ratingwindow.navigate(wurls.base + "forum", wurls.contexts.rwforum);
+ });
+
+ $("#wot-header-close").bind("click", function() {
+ bg.wot.ga.fire_event(wot.ga.categories.RW, wot.ga.actions.RW_BTN_CLOSE);
+ _rw.hide();
+ });
+
+ $("#wot-scorecard-content").bind("click", function() {
+ if (wot.ratingwindow.current.target) {
+ wot.ratingwindow.navigate(wot.urls.scorecard +
+ encodeURIComponent(wot.ratingwindow.current.target),
+ wurls.contexts.rwviewsc);
+ }
+ });
+
+ $(".wot-user-text").bind("click", function() {
+ var url = $(this).attr("url");
+ if (url) {
+ wot.ratingwindow.navigate(url, wurls.contexts.rwprofile);
+ }
+ });
+
+ $("#wot-message").bind("click", function() {
+ var url = $("#wot-message-text").attr("url");
+ if (url) {
+ var label = wot.i18n("locale") + "__" + $(this).attr("msg_id");
+ bg.wot.ga.fire_event(wot.ga.categories.RW, wot.ga.actions.RW_MSG_CLICKED, label);
+ wot.ratingwindow.navigate(url, wurls.contexts.rwmsg);
+ }
+ });
+
+ $(".rating-delete-icon, .rating-deletelabel").bind("click", _rw.rate_control.on_remove);
+
+ $("#user-comment").bind("change keyup", function() {
+ window.setTimeout(function(){
+ wot.ratingwindow.comments.update_hint();
+
+ // set the timeout to update save button when user stops typing the comment
+ if (wot.ratingwindow.timer_save_button) {
+ window.clearTimeout(wot.ratingwindow.timer_save_button);
+ }
+ wot.ratingwindow.timer_save_button = window.setTimeout(wot.ratingwindow.update_submit_button, 200);
+
+ }, 20); // to react on any keyboard event after the text was changed
+ });
+
+ // Rate mode event handlers
+ $("#btn-comment").bind("click", _rw.on_comment_button);
+ $("#btn-submit").bind("click", _rw.on_submit);
+ $("#btn-thanks-ok").bind("click", _rw.on_thanks_ok);
+ $("#btn-cancel").bind("click", _rw.on_cancel);
+ $("#btn-delete").bind("click", _rw.on_delete_button);
+ $("#change-ratings, #voted-categories-content").bind("click", _rw.on_change_ratings);
+
+
+ $("#comment-register-link").bind("click", function() {
+ wot.ratingwindow.navigate(wurls.signup, wurls.contexts.rwcommreg);
+ });
+
+ $("#comment-captcha-link").bind("click", function() {
+ if (wot.ratingwindow.current.target) {
+ wot.ratingwindow.navigate(wot.urls.scorecard +
+ encodeURIComponent(wot.ratingwindow.current.target + "/rate"),
+ wurls.contexts.rwcaptcha, "rate");
+ }
+ });
+
+ $(window).unload(wot.ratingwindow.on_unload);
+
+ _rw.rate_control.init(); // init handlers of rating controls
+ bg.wot.core.update(true); // this starts main data initialization (e.g. before it, there is no "cached" data)
+
+ var wt = bg.wot.wt,
+ locale = bg.wot.i18n("locale");
+
+ // Welcome Tip button "close"
+ $(".wt-rw-close").click(function (e){
+ wot.ratingwindow.reveal_ratingwindow();
+ wot.ratingwindow.count_window_opened();
+
+ wt.settings.rw_ok = true;
+ wt.save_setting("rw_ok");
+
+ var time_before_click = Math.round(wot.time_since(wot.ratingwindow.opened_time));
+ wot.ga.fire_event(wot.ga.categories.WT, wot.ga.actions.WT_RW_OK, String(time_before_click));
+ });
+
+ // Welcome Tip "learn more" link handler
+ $("#wt-learnmore-link").click(function (){
+ var time_before_click = Math.round(wot.time_since(wot.ratingwindow.opened_time));
+ wot.ga.fire_event(wot.ga.categories.WT, wot.ga.actions.WT_RW_LEARN, String(time_before_click));
+ bg.wot.core.open_mywot(wot.urls.tour_rw, wot.urls.contexts.wt_rw_lm);
+ });
+
+ // TODO: uncomment and test after public beta launch:
+// var is_rtip_neutral = false; // default style for welcome tip = sticker
+//
+// var tts_wtip = (locale === "ru" || locale === "en") &&
+// first_opening &&
+// !(wt.settings.rw_ok || wt.settings.rw_shown > 0) &&
+// wot.is_defined(["rw_text", "rw_text_hdr", "rw_ok"], "wt");
+//
+// tts_wtip = tts_wtip && (wot.get_activity_score() < bg.wot.wt.activity_score_max);
+//
+// if (tts_wtip && bg.wot.exp) {
+// // important to run experiment only no Tips were shown before
+// tts_wtip = bg.wot.exp.is_running("wtip-on");
+// }
+//
+// if (bg.wot.prefs.get("super_wtips")) tts_wtip = true; // override by super-setting
+//
+// if (tts_wtip) {
+//
+// var tip_type = "rtip-sticker"; // default style
+//
+// // Decide what to show: normal rating window or welcome tip?
+// if (bg.wot.exp) {
+// is_rtip_neutral = bg.wot.exp.is_running("rtip-neu");
+// tip_type = is_rtip_neutral ? "rtip-neutral" : "rtip-sticker"; // reference to CSS style
+// }
+//
+// // RW is opened first time - show welcome tip
+// _rw.show_welcome_tip(tip_type);
+//
+// // set all welcome tip's preferences (== wt was shown)
+// wt.settings.rw_shown = wt.settings.rw_shown + 1;
+// wt.settings.rw_shown_dt = new Date();
+// wt.save_setting("rw_shown");
+// wt.save_setting("rw_shown_dt");
+// }
+
+ // increment "RatingWindow shown" counter
+ _rw.count_window_opened();
+
+ // shown RatingWindow means that we shown a message => remove notice badge from the button
+ // this was commented on 24.06.2013 to avoid concurrent changing of the badge
+// if (bg.wot.core.badge_status && bg.wot.core.badge_status.type == wot.badge_types.notice.type) {
+// bg.wot.core.set_badge(null, false); // hide badge
+// }
+ },
+
+ on_comment_button: function (e) {
+ var _rw = wot.ratingwindow;
+
+ if ($(this).hasClass("disable")) return; // do nothing of the button is disabled
+
+ switch (_rw.modes.current_mode) {
+ case "rate":
+ if (!_rw.comments.allow_commenting) return;
+ _rw.update_uservoted();
+ _rw.modes.comment.activate();
+ break;
+ case "comment":
+ _rw.modes.rate.activate();
+ break;
+ }
+ },
+
+ on_delete_button: function () {
+// console.log("on_delete_button()");
+ var _rw = wot.ratingwindow,
+ bg = _rw.get_bg();
+
+ wot.components.forEach(function(item){
+ _rw.delete_testimony(item.name);
+ });
+
+ bg.wot.keeper.remove_comment(_rw.state.target);
+ _rw.comments.set_comment(""); // clear the comment
+ _rw.local_comment = null;
+ _rw.comments.update_hint();
+
+ wot.ratingwindow.finishstate(false);
+ _rw.modes.auto(); // switch RW mode according to current state
+ },
+
+ on_cancel: function () {
+
+ var _rw = wot.ratingwindow,
+ cached = _rw.getcached(),
+ bg = chrome.extension.getBackgroundPage();
+
+ // restore previous testimonies
+ wot.components.forEach(function(item){
+ var a = item.name;
+ var t = (cached.value[a] && cached.value[a].t !== undefined) ? cached.value[a].t : -1;
+ if (_rw.state[a]) {
+ _rw.state[a].t = t;
+ } else {
+ _rw.state[a] = { t: t };
+ }
+ });
+
+ _rw.cat_selector.init_voted(); // restore previous votes
+ _rw.rate_control.updateratings(_rw.state); // restore user's testimonies visually
+
+ bg.wot.keeper.remove_comment(_rw.state.target); // remove locally saved comment
+ _rw.update_comment(cached, null); // restore comment to server-side version
+
+ _rw.modes.auto(); // switch RW mode according to current state
+ },
+
+ on_submit: function (e) {
+// console.log("on_submit()");
+
+ if ($(e.currentTarget).hasClass("disabled")) return; // do nothing is "Save" is not allowed
+
+ var _rw = wot.ratingwindow;
+ wot.ratingwindow.finishstate(false);
+ if (_rw.delete_action) {
+ _rw.modes.auto(); // switch RW mode according to current state
+ } else {
+ _rw.modes.thanks.activate();
+ }
+ },
+
+ on_thanks_ok: function () {
+ wot.ratingwindow.modes.auto();
+ },
+
+ on_change_ratings: function () {
+ wot.ratingwindow.modes.rate.activate();
+ },
+
+ on_unload: function () {
+ wot.ratingwindow.finishstate(true);
+ },
+
+ rate_control: {
+
+ init: function() {
+ var _this = wot.ratingwindow;
+
+ // Rating control events handlers
+ $(".wot-rating-stack").bind({
+ mousedown: _this.rate_control.on_mousedown,
+ mouseup: _this.rate_control.on_mouseup,
+ mousemove: _this.rate_control.on_mousemove,
+ mouseleave: _this.rate_control.on_mousemove
+ });
+ },
+
+ on_mousemove: function (e) {
+ var _rw = wot.ratingwindow;
+
+// if (_rw.state.down == -1) return;
+ var c = $(this).attr("component");
+ var t = _rw.getrating(e, this);
+
+ if (_rw.state.down == c) {
+ _rw.setstate(c, t);
+ } else {
+ _rw.state.down = -1;
+ }
+
+ _rw.rate_control.updateratings({ name: c, t: t });
+ },
+
+ on_mousedown: function (e) {
+ var _rw = wot.ratingwindow;
+
+ // skip the click if ratings are disabled
+ if ($("#ratings-area").attr("disabled")) return;
+
+ var c = $(this).attr("component");
+ var t = _rw.getrating(e, this);
+ _rw.state.down = c;
+ _rw.setstate(c, t);
+ _rw.rate_control.updateratings({ name: c, t: t });
+
+ if (!_rw.modes.is_current("comment")) _rw.modes.rate.activate(); // switch to rate mode if we are not in "comment" mode
+
+ // there is a nasty issue in Chrome & jQuery: when dragging an object, the cursor has "text select" form.
+ e.originalEvent.preventDefault(); // http://stackoverflow.com/a/9743380/954197
+ },
+
+ on_mouseup: function (e) {
+ var _rw = wot.ratingwindow;
+ _rw.state.down = -1; // no component is being rating right now
+ },
+
+ on_remove: function (e) {
+ var _rw = wot.ratingwindow;
+
+ if ($(this).closest(".rating-delete").hasClass("delete")) {
+
+ if (!_rw.modes.is_current("comment")) _rw.modes.rate.activate(); // switch to rate mode if we are not in "comment" mode
+ var c = parseInt($(this).closest(".wot-rating-data").attr("component"));
+
+ // TODO: show the warning that categories will be deleted also (?)
+ _rw.delete_testimony(c);
+ }
+ },
+
+ update_ratings_visibility: function (mode) {
+ var _rw = wot.ratingwindow,
+ $_ratingarea = $("#ratings-area");
+
+ if (mode == "unrated") {
+ var cached = _rw.getcached();
+ if (cached.value && cached.value.target) {
+ $_ratingarea.attr("disabled", null);
+ } else {
+ $_ratingarea.attr("disabled", "disabled");
+ // TODO: show some text to explain that there is nothing to rate
+ }
+ } else {
+ $_ratingarea.attr("disabled", null);
+ }
+ },
+
+ updateratings: function(state)
+ {
+ /* indicator state */
+ state = state || {};
+
+ var _rw = wot.ratingwindow;
+
+ /* update each component */
+ wot.components.forEach(function(item) {
+ if (state.name != null && state.name != item.name) {
+ return;
+ }
+
+ var elems = {},
+ rep = wot.getlevel(wot.reputationlevels, -1).name,
+ t = -1,
+ wrs = _rw.state[item.name];
+
+ ["stack", "slider", "indicator", "deleteicon", "deletelabel",
+ "helptext", "helplink", "data"].forEach(function(elem) {
+ elems[elem] = $("#wot-rating-" + item.name + "-" + elem);
+ });
+
+ t = (wrs && wrs.t != null) ? wrs.t : t;
+
+ if (t >= 0) {
+ /* rating */
+ rep = wot.getlevel(wot.reputationlevels, t).name;
+ elems.indicator.css("left", (t * _rw.sliderwidth / 100).toFixed() + "px");
+ elems.stack.addClass("testimony").removeClass("hover");
+ elems.deletelabel.text(wot.i18n("testimony", "delete"));
+ elems.deleteicon.closest(".rating-delete").removeClass("unrated");
+ elems.deleteicon.closest(".rating-delete").addClass("delete");
+
+ } else if (state.name != null && state.t >= 0) {
+ /* temporary indicator position */
+ rep = wot.getlevel(wot.reputationlevels, state.t).name;
+// elems.indicator.css("left", (state.t * _rw.sliderwidth / 100).toFixed() + "px");
+ elems.stack.removeClass("testimony").addClass("hover");
+
+ } else {
+ elems.indicator.css("left", ""); // reset the x-position
+ elems.stack.removeClass("testimony").removeClass("hover");
+ elems.deletelabel.text(wot.i18n("testimony", "unrated"));
+ elems.deleteicon.closest(".rating-delete").addClass("unrated");
+ elems.deleteicon.closest(".rating-delete").removeClass("delete");
+ }
+
+ if (rep) {
+ elems.stack.attr("r", rep);
+ if (state.down != -1) {
+ elems.indicator.attr("r", rep);
+ elems.data.attr("r", rep);
+ }
+ }
+
+ var helptext = wot.get_level_label(item.name, rep, true);
+
+ if (helptext.length) {
+ elems.helptext.text(helptext).show();
+ elems.helptext.attr("r", rep);
+ } else {
+ elems.helptext.hide();
+ }
+ });
+
+ _rw.update_submit_button();
+ }
+ },
+
+ /* Modes are only visual helpers to render proper content in the Rating Window */
+ modes: {
+
+ current_mode: "",
+
+ unrated: {
+ visible: ["#reputation-info", "#user-communication", ".user-comm-social"],
+ invisible: ["#rate-buttons", "#categories-selection-area", "#rated-votes",
+ "#commenting-area", "#thanks-area", "#ok-button"],
+ addclass: "view-mode unrated",
+ removeclass: "rated commenting thanks rate",
+
+ activate: function () {
+ if (!wot.ratingwindow.modes._activate("unrated")) return false;
+ return true;
+ }
+ },
+
+ rated: {
+ visible: ["#reputation-info", "#user-communication", "#rated-votes", ".user-comm-social"],
+ invisible: ["#rate-buttons", "#categories-selection-area",
+ "#commenting-area", "#thanks-area", "#ok-button"],
+ addclass: "view-mode rated",
+ removeclass: "unrated commenting thanks rate",
+
+ activate: function () {
+ if (!wot.ratingwindow.modes._activate("rated")) return false;
+ wot.ratingwindow.update_uservoted();
+ return true;
+ }
+ },
+
+ rate: {
+ visible: ["#rate-buttons", "#categories-selection-area"],
+ invisible: ["#reputation-info", "#user-communication", "#rated-votes",
+ "#commenting-area", "#thanks-area", "#ok-button"],
+ addclass: "rate",
+ removeclass: "view-mode rated unrated commenting thanks",
+
+ activate: function () {
+ var _rw = wot.ratingwindow,
+ prev_mode = _rw.modes.current_mode;
+
+ if (!_rw.modes._activate("rate")) return false;
+
+ // "Comment" mode can be the first active mode in session, so we have to init things still.
+ if (prev_mode != "comment" || !_rw.cat_selector.inited) {
+ if (!_rw.cat_selector.inited) {
+ _rw.cat_selector.build();
+ _rw.cat_selector.init();
+ }
+ _rw.cat_selector.init_voted();
+ _rw.update_catsel_state(); // update the category selector with current state
+ }
+
+ _rw.update_submit_button();
+ _rw.comments.update_button("rate", true);
+ _rw.was_in_ratemode = true;
+ return true;
+ }
+ },
+
+ comment: { // Not implemented yet
+ visible: ["#rate-buttons", "#commenting-area", "#rated-votes"],
+ invisible: ["#reputation-info", "#user-communication", "#categories-selection-area",
+ "#thanks-area", "#ok-button"],
+ addclass: "commenting",
+ removeclass: "view-mode rated unrated rate thanks",
+
+ activate: function () {
+ var _rw = wot.ratingwindow,
+ prev_mode = _rw.modes.current_mode;
+ if (!wot.ratingwindow.modes._activate("comment")) return false;
+
+ // TODO: this piece of code is a duplication. Should be refactored.
+ if (prev_mode == "" || !_rw.cat_selector.inited) {
+ if (!_rw.cat_selector.inited) {
+ _rw.cat_selector.build();
+ _rw.cat_selector.init();
+ }
+ _rw.cat_selector.init_voted();
+ }
+
+ _rw.was_in_ratemode = true; // since in comment mode user is able to change rating, we should set the flag
+ _rw.comments.update_hint();
+ _rw.comments.update_button("comment", true);
+ _rw.update_submit_button();
+ _rw.comments.focus();
+ return true;
+ }
+ },
+
+ thanks: {
+ visible: ["#thanks-area", "#rated-votes", "#ok-button"],
+ invisible: ["#reputation-info", "#user-communication", "#categories-selection-area",
+ "#commenting-area", "#rate-buttons"],
+ addclass: "thanks view-mode",
+ removeclass: "rated unrated rate commenting",
+
+ activate: function () {
+ var _rw = wot.ratingwindow;
+ if (!_rw.modes._activate("thanks")) return false;
+
+ _rw.update_uservoted();
+
+ // no need to show this to platinum members
+ if ((_rw.prefs.get("activity_score") || 0) >= wot.AS_LEVELS.PLATINUM) {
+ $(".thanks-ratemore").hide();
+ }
+
+ setTimeout(function() {
+ wot.ratingwindow.modes.auto(); // switch to default mode
+ }, 6000);
+ return true;
+ }
+ },
+
+ show_hide: function (mode_name) {
+ var _modes = wot.ratingwindow.modes;
+ var visible = _modes[mode_name] ? _modes[mode_name].visible : [];
+ var invisible = _modes[mode_name] ? _modes[mode_name].invisible : [];
+
+ $(invisible.join(", ")).hide();
+ $("#wot-ratingwindow").addClass(_modes[mode_name].addclass).removeClass(_modes[mode_name].removeclass);
+ $(visible.join(", ")).show();
+ },
+
+ _activate: function (mode_name) {
+ /* Generic func to do common things for switching modes. Returns false if there is no need to switch the mode. */
+// console.log("RW.modes.activate(" + mode_name + ")");
+
+ var _rw = wot.ratingwindow;
+ if (_rw.modes.current_mode == mode_name) return false;
+ _rw.modes.show_hide(mode_name);
+ _rw.modes.current_mode = mode_name;
+ _rw.rate_control.update_ratings_visibility(mode_name);
+ return true;
+ },
+
+ auto: function () {
+ var _rw = wot.ratingwindow;
+
+ if (_rw.local_comment && _rw.local_comment.comment) {
+ _rw.modes.comment.activate();
+ } else {
+ // If no locally saved comment exists, switch modes between Rated / Unrated
+ if (_rw.is_rated()) {
+ _rw.modes.rated.activate();
+ } else {
+ _rw.modes.unrated.activate();
+ }
+ }
+ },
+
+ reset: function () {
+ wot.ratingwindow.modes.current_mode = "";
+ },
+
+ is_current: function (mode) {
+ return wot.ratingwindow.modes.current_mode == mode;
+ }
+ },
+
+ cat_selector: {
+ inited: false,
+ $_cat_selector: null,
+ short_list: true,
+ voted: {},
+
+ build: function () {
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector,
+ cats = [];
+
+ _this.$_cat_selector = $(".category-selector .dropdown-menu"); // all operations are done on the menu actually
+ $("*", _this.$_cat_selector).detach(); // remove everything if present
+
+ // cycle through grouping to create main sections
+ for (var gi = 0; gi < wot.grouping.length; gi++) {
+ var grp = wot.grouping[gi];
+ if (!grp.omnipresent && grp.text && grp.groups) {
+ var $_li = _this._build_grouping(grp.text, grp.name);
+
+ var $_popover = $("<div></div>").addClass("popover"); // container for a list of categories
+
+ // Iterate over list of groups in the grouping (section)
+ for(var a = 0; a < grp.groups.length; a++) {
+ var g = grp.groups[a], // g.name == id, g.type == css style
+ g_id = parseInt(g.name);
+
+ cats = wot.select_categories(g_id, g_id); // list if categories' IDs
+ _rw.cat_selector._build_from_list(cats, $_popover, false);
+ }
+
+ $_li.append($_popover);
+ _this.$_cat_selector.append($_li);
+ }
+ }
+
+ var _i18n_fulllist = wot.i18n("ratingwindow", "fulllist");
+
+ if (_i18n_fulllist) {
+ var chk_html = '<div class="cat-full-list">' +
+ '<input type="checkbox" id="chk-full-list" class="css-checkbox"/>' +
+ '<label for="chk-full-list" class="css-label">' + _i18n_fulllist + '</label>' +
+ '</div>';
+
+ _this.$_cat_selector.append($(chk_html));
+ }
+ },
+
+ _build_grouping: function (grouping_text, grouping_name) {
+ // Makes HTML for a grouping
+ var $_li = $("<li></li>").attr("grp-name", grouping_name); // grouping holder
+ // add section name
+ $("<span></span>").addClass("group-title").text(grouping_text).appendTo($_li);
+ return $_li;
+ },
+
+ _build_from_list: function (cat_list, $_target_popover, omni) {
+ /* Makes HTML elements of categories with all controls and inserts them into Popover wrapper */
+ var _this = wot.ratingwindow.cat_selector;
+ var textvote_yes = wot.i18n("ratingwindow", "vote_yes"),
+ textvote_no = wot.i18n("ratingwindow", "vote_no");
+
+ $(".category-breakline", $_target_popover).detach(); // remove any breaklines
+ if (cat_list.length > 0) {
+ // Iterate over a list of categories belonging to the current group
+ if (omni) {
+ $("<div></div>").addClass("category-breakline").appendTo($_target_popover); // add the separator for omni
+ }
+
+ for (var ci = 0; ci < cat_list.length; ci++) {
+ var cobj = cat_list[ci],// here we may get a category object, or simple category ID. Depends on source.
+ cid = 0;
+ cid = (typeof cobj == "object") ? cobj.id : cobj; // in case if we work with category object instead if just a number
+
+ var cat = wot.get_category(cid);
+ if (!wot.utils.isEmptyObject(cat)) {
+ var $_po_cat = $("<div></div>").addClass("category"); // container for a category
+ $_po_cat.attr("data-cat", cat.id);
+ if (omni) {
+ $_po_cat.addClass("omni");
+ }
+
+ if (cat.fullonly) {
+ $_po_cat.addClass("fullonly");
+ $_po_cat.toggleClass("invisible", _this.short_list);
+ }
+
+ $("<div></div>") // the category line
+ .text(wot.get_category_name(cat.id, true))
+ .addClass("cat-name")
+ .appendTo($_po_cat);
+
+ var $_cat_vote = $("<div></div>").addClass("cat-vote");
+
+ // TODO: use translations for strings
+ $("<div></div>").text(textvote_yes).addClass("cat-vote-left").appendTo($_cat_vote);
+ $("<div></div>").text(textvote_no).addClass("cat-vote-right").appendTo($_cat_vote);
+
+ $("<div></div>").addClass("delete-icon")
+ .appendTo($("<div></div>").addClass("cat-vote-del").appendTo($_cat_vote));
+
+ $_cat_vote.appendTo($_po_cat);
+
+ $_target_popover.append($_po_cat);
+
+ } else {
+ console.warn("Can't find category", cat_list[ci]);
+ }
+ }
+
+ }
+ return cat_list.length;
+ },
+
+ set_state: function (state, identified) {
+ // Sets the category selector into proper state taking into account user's ratings and currently identified categories.
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector;
+
+ if (!_this.inited) return; // do nothing when I'm not ready yet
+
+ if (!_rw.modes.is_current("rate")) return; // do nothing when not in Rate mode
+
+ var t0 = state[0] ? state[0].t : -1; // Trustworthiness user's testimony
+ var t4 = state[4] ? state[4].t : -1; // Child Safety user's testimony
+
+ // 1. Pre-open proper grouping
+ var grp = wot.determ_grouping(t0, null),
+ grp_id = grp.name;
+
+ var $_grouping = $("li[grp-name=" + grp_id + "]", _this.$_cat_selector).first();
+ if ($_grouping && grp_id != null) {
+ _this.deactivate_all();
+ _this.activate_submenu($_grouping);
+ }
+
+ // 2. Create omni-part with CS categories based on user's CS testimony
+ var omnigroupings = wot.determ_grouping(t0, "omnipresent");
+ var omni_categories = [], // all possible omni-categories
+ omni_to_show = [], // plain filtered list of omni-categories
+ omni_per_section = {}; // list of omni-categories per selector's section
+
+ // make a list of all categories for omni-area that we may show
+ if (omnigroupings && omnigroupings.groups) {
+ for (var gi = 0; gi < omnigroupings.groups.length; gi++) {
+ var g_id = parseInt(omnigroupings.groups[gi].name);
+ // collect all categories that are possible to show in omni-area
+ omni_categories = omni_categories.concat(wot.select_categories(g_id, g_id));
+ }
+
+ // filter out categories irrelevant to user's testimony
+ omni_to_show = omni_categories.filter(function(elem, i, arr) {
+ var cat = wot.get_category(elem);
+ return (cat.rmin !== null && cat.rmax !== null && t4 >= cat.rmin && t4 <= cat.rmax);
+ });
+ }
+
+ /* now omni_to_show[] contains all cats for the given testimony and we need to make filtered lists
+ for every section in the selector. */
+ for (var j = 0; j < wot.grouping.length; j++) {
+ if (wot.grouping[j].omnipresent) continue; // skip omni grouping for obvious reason
+ var section_id = wot.grouping[j].name;
+ omni_per_section[section_id] = omni_to_show.filter(function (elem, i , arr) {
+ var cat = wot.get_category(elem);
+ if (cat.excludegroupings) {
+ var excludegroupings = cat.excludegroupings.split(",");
+ return (excludegroupings.indexOf(section_id) < 0);
+ }
+ return true;
+ });
+ }
+
+ // 3. Build dynamic group ("Do you agree with?") filtering out categories shown in omni-area
+ var cached = _rw.getcached(),
+ cats_object = cached.value.cats,
+ dyn_cats = [],
+ dyn_grp = wot.determ_grouping(null, "dynamic"); // find the dynamic group to identify "popover" DOM element
+
+ if (dyn_grp.groups) {
+ for (var i= 0, gid; i < dyn_grp.groups.length; i++) {
+ gid = parseInt(dyn_grp.groups[i].name);
+ dyn_cats = dyn_cats.concat(wot.select_categories(gid, gid));
+ }
+ }
+
+ if (!wot.utils.isEmptyObject(cats_object)) {
+ var cats = wot.rearrange_categories(cats_object); // list of categories' IDs
+ // filter out categories that are in the omni-area already
+ // and that are only voted but not identified by community
+ var filtered_dynamic = cats.trustworthy.concat(cats.childsafety).filter(function(elem){
+ var cat_id = parseInt(elem.id);
+ var fltr = !(omni_to_show.indexOf(cat_id) >= 0);
+ fltr = fltr && elem.c; // Identified cats have "c" attribute's value greater than than zero;
+ fltr = fltr && !(dyn_cats.indexOf(cat_id) >= 0); // drop categories that are already in dyn_cats
+ return fltr;
+ });
+
+ filtered_dynamic = dyn_cats.concat(filtered_dynamic);
+
+ var $_popover = $("li[grp-name="+dyn_grp.name+"] .popover", _this.$_cat_selector).first();
+ $(".category", $_popover).detach(); // remove all previous categories from the popover
+ _rw.cat_selector._build_from_list(filtered_dynamic, $_popover, false); // fill the popover with categories
+ }
+
+ // 4. Append finally Omni Categories
+ $(".category-selector .popover .omni").detach(); // remove all previous omni groups from all popovers
+
+ // Create and attach omni categories to _all_ popovers (groupings)
+ for (var si in omni_per_section) {
+ if (omni_per_section[si]) {
+ var $_popover = $(".category-selector li[grp-name=" + si + "] .popover");
+ _this._build_from_list(omni_per_section[si], $_popover, true);
+ }
+ }
+
+ _this.highlight_identified(cats_object); // assign CSS styles to identified categories
+ _this.markup_voted(); // assign extra data to voted categories
+ },
+
+ highlight_identified: function (cats_object) {
+ // Highlights currently identified categories in the selector
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector,
+ cats = wot.select_identified(cats_object);
+
+ $(".category.identified", _this.$_cat_selector).removeClass("identified");
+
+ for(var cat_id in cats) {
+ $(".category[data-cat=" + cat_id + "]", _this.$_cat_selector)
+ .addClass("identified")
+ .removeClass("fullonly invisible"); // if a category is identified, show it in both full/short list modes and prevent to be hidden
+ }
+ },
+
+ markup_voted: function () {
+ // Hightlights user's votes for categories
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector;
+
+ $(".category", _this.$_cat_selector).removeAttr("voted");
+
+ for(var cat_id in _this.votes) {
+ $(".category[data-cat=" + cat_id + "]", _this.$_cat_selector)
+ .removeClass("fullonly invisible") // if a category is voted, show it in both full/short list modes
+ .attr("voted", _this.votes[cat_id].v);
+ }
+ },
+
+ get_user_votes: function (return_object) {
+ // Scans DOM for all visible categories in the category selector to filter out voted but invisible cats in future
+
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector,
+ voted = [],
+ voted_obj = {};
+
+ $(".category", _this.$_cat_selector).each(function (i, elem) {
+ var cid = $(this).attr("data-cat"), cat = null;
+ if (cid && $(this).attr("voted")) {
+ cid = parseInt(cid);
+ if (voted_obj[cid] === undefined) { // check for unique
+ cat = wot.get_category(cid);
+ cat.v = parseInt($(this).attr("voted"));
+ voted.push(cat);
+ voted_obj[cid] = cat.v; // to be able to get a list of unique voted categories
+ }
+ }
+ });
+
+ return return_object ? voted_obj : voted; // return either object or array
+ },
+
+ update_categories_visibility: function () {
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector;
+
+ // show / hide categories from short/full list
+ $(".category.fullonly", _this.$_cat_selector).toggleClass("invisible", _this.short_list);
+ },
+
+ init: function() {
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector;
+
+ _this.init_voted();
+
+ $(".dropdown-menu").menuAim({
+ active_selector: ".maintainHover",
+ activate: _this.activate_submenu,
+ deactivate: _this.deactivate_submenu
+ });
+
+ $(_this.$_cat_selector).on("click", ".category, .cat-vote-left, .cat-vote-right, .cat-vote-del", _this.vote);
+
+ // show description of the hovered category
+ $(_this.$_cat_selector).on("mouseenter mouseleave", ".category", _this.on_category_hover);
+
+ _this.short_list = !_rw.prefs.get("show_fulllist");
+
+ $("#chk-full-list").
+ bind("change", _this.on_show_full).
+ attr("checked", _this.short_list ? null : "checked");
+
+ _this.$_cat_selector.toggleClass("shortlist", _this.short_list); // change appearance of the list
+
+ _this.update_categories_visibility();
+
+ this.inited = true;
+ },
+
+ on_category_hover: function (e) {
+
+ var $_cat = $(e.currentTarget),
+ $_category_title = $(".category-title"),
+ $_cat_description = $(".category-description");
+
+ var cat_id = $_cat.attr("data-cat"),
+ is_hovered = (e.type == "mouseenter") && (cat_id !== undefined);
+
+ var cat_description = wot.get_category(cat_id).description;
+
+ if (is_hovered && cat_description) {
+ $_category_title.hide(0, function () {
+ $_cat_description.text(cat_description);
+ $_cat_description.show();
+ });
+
+ } else {
+ $_cat_description.hide(0, function (){
+ $_category_title.show();
+ });
+ }
+ },
+
+ on_show_full: function () {
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector;
+
+ _this.short_list = ($(this).attr("checked") != "checked");
+ _rw.prefs.set("show_fulllist", !_this.short_list); // store the value
+
+ _this.$_cat_selector.toggleClass("shortlist", _this.short_list); // change appearance of the list
+
+ _this.update_categories_visibility();
+ },
+
+ init_voted: function () {
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector;
+
+ var cached = _rw.getcached(),
+ cats_object = (cached && cached.value && cached.value.cats) ? cached.value.cats : {};
+
+ _this.votes = wot.select_voted(cats_object);
+ _this.markup_voted();
+ },
+
+ destroy: function () {
+ // destroys the selector
+ var _rw = wot.ratingwindow,
+ _this = _rw.cat_selector;
+
+ if (_this.inited) {
+ _this.votes = {};
+ _this.$_cat_selector.children().detach();
+ _this.inited = false;
+ }
+ },
+
+ activate_submenu: function(elem) {
+ var menu = $(".dropdown-menu");
+ var category_title = $(".category-title");
+ var $_external_container = $("#categories-selection-area");
+ var selected_elem = $(elem);
+ var sub_menu = selected_elem.find(".popover");
+
+ selected_elem.addClass("maintainHover");
+
+ var left_distance = 162; //menu.outerWidth() + (menu.offset().left - $_external_container.offset().left);
+ var top_distance = 10;//menu.offset().top;
+
+ //TO DO: what if user changes category manully.
+
+ // Show the submenu
+ sub_menu.css({
+ top: top_distance,
+ left: left_distance // main should overlay submenu
+ }).show();
+ },
+
+ deactivate_all: function () {
+ var _this = wot.ratingwindow.cat_selector;
+ $(".category-selector .maintainHover").each(function(i, elem){
+ _this.deactivate_submenu(elem);
+ });
+ },
+
+ deactivate_submenu: function(elem) {
+ var selected_elem = $(elem);
+ var sub_menu = selected_elem.find(".popover");
+ sub_menu.hide();
+ selected_elem.removeClass("maintainHover");
+ },
+
+ _calc_vote_result: function (vs, vy, vn, vd, vc) {
+ // Calculates the resulted vote depending on what was clicked and current vote state
+ if (vd == 1) return 0; // if "delete" is clicked
+ var fy = vy * Math.min(vy, vy - vs);
+ var fn = vn * Math.max(-1, -vn - vs);
+ var fc = vc * ((vs + 2) % 3 - 1);
+ return fy + fn + fc;
+ },
+
+ vote: function(event) {
+ // Sets attr "voted" on categories tags
+ var _this = wot.ratingwindow.cat_selector,
+ $_clicked = $(this),
+ $_current_cat = $_clicked.closest(".category").first(),
+ currently_voted = $_current_cat.attr("voted"),
+ cat_id = $_current_cat.attr("data-cat"),
+ $_cats = $(".category[data-cat="+cat_id+"]");
+
+ event.stopPropagation(); // don't bubble the event (causes undesired effects)
+
+ var vy = $_clicked.hasClass("cat-vote-left") ? 1 : 0; // clicked Yes
+ var vn = $_clicked.hasClass("cat-vote-right") ? 1 : 0; // clicked No
+ var vc = $_clicked.hasClass("category") ? 1 : 0; // Clicked Category line
+ var vd = $_clicked.hasClass("cat-vote-del") ? 1 : 0; // Clicked "delete" vote
+ var vs = currently_voted ? parseInt(currently_voted) : 0; // current vote state for the clicked category
+ var new_vote = _this._calc_vote_result(vs, vy, vn, vd, vc);
+
+ if (new_vote != 0) {
+ $_cats.attr("voted", new_vote);
+ _this.votes[cat_id] = wot.get_category(cat_id);
+ _this.votes[cat_id].v = new_vote;
+ } else {
+ $_cats.removeAttr("voted");
+ if (_this.votes[cat_id]) delete _this.votes[cat_id];
+ }
+
+ wot.ratingwindow.update_submit_button(); // enable/disable "Save" button
+ }
+ }, /* end of cat_selector {} */
+
+ /* Start of Comments API and Comments UI code */
+ comments: {
+ allow_commenting: true,
+ is_banned: false,
+ captcha_required: false,
+ MIN_LIMIT: 30,
+ MAX_LIMIT: 20000,
+ is_changed: false,
+ posted_comment: {},
+
+ is_commented: function() {
+ // comment can be there, but it can be invalid (outside of limits restrictions, etc)
+ return ($("#user-comment").val().trim().length > 0);
+ },
+
+ get_comment: function (target) {
+ var bg = wot.ratingwindow.get_bg(),
+ bgwot = bg.wot;
+
+ bg.console.log("RW: wot.ratingwindow.comments.get_comment(target)", target);
+
+ bgwot.api.comments.get(target);
+ },
+
+ remove_comment: function () {
+ // TODO: to be implemented when there will be a button "remove the comment" in UI
+ },
+
+ update_hint: function () {
+ var rw = wot.ratingwindow,
+ _this = rw.comments,
+ $_comment = $("#user-comment"),
+ $_hint = $("#comment-bottom-hint"),
+ len = $_comment.val().trim().length,
+ fix_len = 0,
+ cls = "";
+
+ if (len > 0 && len < _this.MIN_LIMIT) {
+ fix_len = String(len - _this.MIN_LIMIT).replace("-", "– "); // readability is our everything
+ cls = "error min"
+ } else if (len > _this.MAX_LIMIT) {
+ fix_len = len - _this.MAX_LIMIT;
+ cls = "error max"
+ } else {
+ // we could show here something like "looks good!"
+ }
+
+ $_hint.attr("class", cls).text(fix_len);
+ },
+
+ update_button: function (mode, enabled) {
+ var _this = wot.ratingwindow.comments,
+ $_button = $("#btn-comment");
+
+ $_button.toggleClass("disabled", !(enabled && _this.allow_commenting)); // take into account other restrictions like "banned"
+
+ switch (mode) {
+ case "rate":
+ if (_this.is_commented()) {
+ $_button.text(wot.i18n("ratingwindow", "editcomment"));
+ } else {
+ $_button.text(wot.i18n("ratingwindow", "addcomment"));
+ }
+
+ break;
+ case "comment":
+ if (wot.ratingwindow.has_1upvote()) {
+ $_button.text(wot.i18n("ratingwindow", "backtoratings"));
+ } else {
+ $_button.text(wot.i18n("ratingwindow", "backtoratings_category"));
+ }
+ break;
+ }
+
+ $_button.toggle(!_this.is_banned); // don't show this button to banned users
+ },
+
+ set_comment: function (text) {
+ $("#user-comment").val(text);
+ },
+
+ has_valid_comment: function () {
+ var comment = $("#user-comment").val().trim(),
+ _this = wot.ratingwindow.comments;
+
+ return (comment.length >= _this.MIN_LIMIT && comment.length < _this.MAX_LIMIT);
+ },
+
+ focus: function () {
+ $("#user-comment").focus();
+ },
+
+ show_register_invitation: function () {
+ $("#comment-side-hint").hide();
+ $("#user-comment").addClass("warning");
+ $("#comment-register").show();
+ },
+
+ show_captcha_invitation: function () {
+ $("#comment-side-hint").hide();
+ $("#user-comment").addClass("warning").attr("disabled", "1");
+ $("#comment-captcha").show();
+ }
+ }
+
+}});
+
+$(document).ready(function() {
+// wot.ratingwindow.onload();
+});
diff --git a/content/rw/wot.js b/content/rw/wot.js
new file mode 100644
index 0000000..a029274
--- /dev/null
+++ b/content/rw/wot.js
@@ -0,0 +1,1041 @@
+/*
+ wot.js
+ Copyright © 2009 - 2013 WOT Services Oy <info at mywot.com>
+
+ This file is part of WOT.
+
+ WOT is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ WOT is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with WOT. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+var wot = {
+ version: 20130718,
+ platform: "firefox",
+ locale: "en", // cached value of the locale
+ lang: "en-US", // cached value of the lang
+ debug: true, // when changing this, don't forget to switch ga_id value also!
+ default_component: 0,
+ enable_surveys: true, // Feedback loop engine
+
+ ga_id: "UA-35564069-1", // test: UA-35564069-1 , live: UA-2412412-8
+
+ // environment (browser, etc)
+ env: {
+ is_mailru: false,
+ is_yandex: false,
+ is_rambler: false,
+
+ is_accessible: false
+ },
+
+ components: [
+ { name: 0 },
+ { name: 4 }
+ ],
+
+ cgroups: {}, // Categories' groups and their mapping to colors and TR/CS. Initialized by calling "wot.init_categories(prefs)"
+
+ // Groupings for building category selector in Rating Window. Loaded from API server, update.xml file.
+ grouping: [],
+
+ categories: {}, // is loaded from preferences during launch and updated from server regularly
+
+ category_threshold: 3, // confidence level to show a category as identified
+
+ reputationlevels: [
+ { name: "rx", min: -2 },
+ { name: "r0", min: -1 },
+ { name: "r1", min: 0 },
+ { name: "r2", min: 20 },
+ { name: "r3", min: 40 },
+ { name: "r4", min: 60 },
+ { name: "r5", min: 80 }
+ ],
+
+ confidencelevels: [
+ { name: "cx", min: -2 },
+ { name: "c0", min: -1 },
+ { name: "c1", min: 6 },
+ { name: "c2", min: 12 },
+ { name: "c3", min: 23 },
+ { name: "c4", min: 34 },
+ { name: "c5", min: 45 }
+ ],
+
+ // reference: http://www.mywot.com/wiki/Activity_scores
+ activityscore_levels: [
+ { name: "rookie", min: 0 },
+ { name: "bronze", min: 1500 },
+ { name: "silver", min: 3000 },
+ { name: "gold", min: 6000 },
+ { name: "platinum", min: 10000 }
+ ],
+
+ AS_LEVELS: {
+ ROOKIE: 0,
+ BRONZE: 1500,
+ SILVER: 3000,
+ GOLD: 6000,
+ PLATINUM: 10000
+ },
+
+ searchtypes: {
+ optimized: 0,
+ worst: 1,
+ trustworthiness: 2
+ },
+
+ warningtypes: { /* bigger value = more severe warning */
+ none: 0,
+ notification: 1,
+ overlay: 2,
+ block: 3
+ },
+
+ warningreasons: { /* bigger value = more important reason */
+ skipped: -1,
+ none: 0,
+ unknown: 1,
+ rating: 2,
+ reputation: 3
+ },
+
+ urls: {
+ base: "http://beta.mywot.com/",
+ scorecard: "http://beta.mywot.com/scorecard/",
+ settings: "http://beta.mywot.com/settings",
+ profile: "http://beta.mywot.com/user",
+ signup: "https://beta.mywot.com/signup",
+ welcome: "http://beta.mywot.com/settings/welcome",
+ setcookies: "http://beta.mywot.com/setcookies.php",
+ setcookies2: "http://www.mywot.com/setcookies.php", // TODO: remove when Beta is finished
+ update: "http://beta.mywot.com/update",
+ tour_warning:"http://beta.mywot.com/support/tour/warningscreen",
+ tour: "http://beta.mywot.com/support/tour/",
+ tour_rw: "http://beta.mywot.com/support/tour/ratingwindow",
+ tour_scorecard: "http://beta.mywot.com/support/tour/scorecard",
+
+ contexts: {
+ rwlogo: "rw-logo",
+ rwsettings: "rw-settings",
+ rwguide: "rw-guide",
+ rwforum: "rw-forum",
+ rwviewsc: "rw-viewsc",
+ rwprofile: "rw-profile",
+ rwmsg: "rw-msg",
+ rwcommreg: "rw-commreg",
+ rwcaptcha: "rw-captcha",
+ warnviewsc: "warn-viewsc",
+ warnrate: "warn-rate",
+ popupviewsc: "popup",
+ popuprate: "popup-rate",
+ popupdonuts: "popup-donuts",
+ fbl_logo: "fbl-logo",
+ wt_intro: "wt-intro",
+ wt_rw_lm: "wt-rw-lm",
+ wt_warn_lm: "wt-warn-lm",
+ wt_warn_logo: "wt-warn-logo",
+ wt_donuts_lm: "wt-donuts-lm",
+ wt_donuts_logo: "wt-donuts-logo"
+ }
+ },
+
+ firstrunupdate: 1, /* increase to show a page after an update */
+
+ cachestatus: {
+ error: 0,
+ ok: 1,
+ busy: 2,
+ retry: 3,
+ link: 4,
+ unsubmitted: 5
+ },
+
+ badge_types: {
+ unsaved_comment: {
+ color: [255, 0, 0, 255],
+ text: "?",
+ type: "unsaved_comment",
+ priority: 1
+ },
+ notice: { // for system notifications
+ color: [240, 0, 0, 255],
+ text: "1",
+ type: "notice", // important to compare with current status type
+ priority: 2
+ },
+ message: { // for messages from another users
+ color: [160, 160, 160, 255],
+ text: "",
+ type: "message",
+ priority: 3
+ },
+ unrated: {
+ color: [255, 235, 0, 255],
+ text: "-",
+ type: "unrated",
+ priority: 4
+ },
+ nocategories: {
+ color: [200, 200, 200, 255],
+ text: "?",
+ type: "nocategories",
+ priority: 5
+ }
+ },
+
+ comments: {
+ error_codes: {
+ "0": "SUCCESS",
+ "1": "NO_ACTION_DEFINED",
+ "2": "IS_BANNED",
+ "3": "AUTHENTICATION_FAILED",
+ "4": "NO_TARGET",
+ "5": "COMMENT_NOT_FOUND",
+ "6": "COMMENT_REMOVAL_FAILED",
+ "7": "COMMENT_NOT_ALLOWED",
+ "8": "NO_COMMENTID",
+ "9": "NO_CATEGORIES_SPECIFIED",
+ "10": "NO_COMMENT_SPECIFIED",
+ "11": "AUTHENTICATION_INVALID_QUERY_PARAMETERS",
+ "12": "AUTHENTICATION_REP_SERVER_ERROR",
+ "13": "NO_QUERY_SPECIFIED",
+ "14": "QUERY_STRING_MISSING",
+ "15": "COMMENT_HAS_BEEN_ALTERED",
+ "16": "COMMENT_TOO_SHORT",
+ "17": "COMMENT_TOO_LONG",
+ "18": "COMMENT_SAVE_FAILED",
+ SUCCESS: 0,
+ NO_ACTION_DEFINED: 1,
+ IS_BANNED: 2,
+ AUTHENTICATION_FAILED: 3,
+ COMMENT_NOT_FOUND: 5,
+ COMMENT_REMOVAL_FAILED: 6,
+ COMMENT_NOT_ALLOWED: 7,
+ AUTHENTICATION_REP_SERVER_ERROR: 12,
+ COMMENT_SAVE_FAILED: 18
+ }
+ },
+
+ expire_warned_after: 20000, // number of milliseconds after which warned flag will be expired
+
+ // trusted extensions IDs
+ allowed_senders: {
+ "ihcnfeknmfflffeebijjfbhkmeehcihn": true, // dev version
+ "bhmmomiinigofkjcapegjjndpbikblnp": true, // WOT via WebStore
+ "goinjpofmboaejkhflohjoloaoebfopj": true, // WOT (m2) distributed via mywot.com
+ "hghiafbmcdglhlkgpfafjjoigpghhilc": true // Manifest-1 version of WOT addon
+ },
+
+ // engagement schedule
+ engage_settings: {
+ invite_to_rw: {
+ delay: 12 * 3600, // 12 hours after first launch
+ pref_name: "ratingwindow_shown",
+ enabled: true // this is a cache value to avoid comprehensive logic work often (in case of = false)
+ }
+ },
+
+ // Constants for playing with date & time (in seconds)
+ DT: {
+ MINUTE: 60,
+ HOUR: 3600,
+ DAY: 24 * 3600,
+ WEEK: 7 * 24 * 3600,
+ MONTH: 30 * 24 * 3600
+ },
+
+ /* logging */
+
+ log: function (s)
+ {
+ if (wot.debug) {
+ console.log(s, arguments);
+ }
+ },
+
+ /* events */
+
+ events: {},
+
+ trigger: function (name, params, once)
+ {
+ if (this.events[name]) {
+ if (wot.debug) {
+ console.log("trigger: event " + name + ", once = " + once);
+ }
+
+ this.events[name].forEach(function (obj) {
+ try {
+ obj.func.apply(null, [].concat(params).concat(obj.params));
+ } catch (e) {
+ console.log("trigger: event " + name + " failed with " +
+ e + "\n");
+ }
+ });
+
+ if (once) { /* these events happen only once per bind */
+ delete (this.events[name]);
+ }
+ }
+ },
+
+ bind: function (name, func, params)
+ {
+ if (typeof (func) == "function") {
+ this.events[name] = this.events[name] || [];
+ this.events[name].push({ func: func, params: params || [] });
+
+ if (wot.debug) {
+ console.log("bind: event " + name);
+ }
+ this.trigger("bind:" + name);
+ }
+ },
+
+ addready: function (name, obj, func)
+ {
+ obj.ready = function (setready)
+ {
+ if (typeof(func) == "function") {
+ this.isready = setready || func.apply(this);
+ } else {
+ this.isready = setready || this.isready;
+ }
+ if (this.isready) {
+ wot.trigger(name + ":ready", [], true);
+ }
+ };
+
+ obj.isready = false;
+
+ this.bind("bind:" + name + ":ready", function() {
+ obj.ready();
+ });
+ },
+
+ /* messaging */
+
+ connections: {},
+
+ triggeronmessage: function(port)
+ {
+ port.onMessage.addListener(function(data) {
+ wot.trigger("message:" + data.message, [ {
+ port: port,
+ post: function(message, data) {
+ wot.post(this.port.name, message, data, this.port);
+ }
+ }, data ]);
+ });
+ },
+
+ listen: function(names)
+ {
+ if (typeof(names) == "string") {
+ names = [ names ];
+ }
+
+ chrome.extension.onConnect.addListener(function(port) {
+ if (names.indexOf(port.name) >= 0) {
+ wot.triggeronmessage(port);
+ wot.connections[port.name] = port;
+ }
+ });
+ },
+
+ connect: function(name)
+ {
+ var port = this.connections[name];
+
+ if (port) {
+ return port;
+ }
+
+ port = chrome.extension.connect({ name: name });
+
+ if (port) {
+ this.triggeronmessage(port);
+ this.connections[name] = port;
+ }
+
+ return port;
+ },
+
+ post: function(name, message, data, port)
+ {
+ port = port || this.connect(name);
+
+ if (port) {
+ data = data || {};
+ data.message = name + ":" + message;
+ this.log("post: posting " + data.message + "\n");
+ port.postMessage(data);
+ }
+ },
+
+ is_allowed_sender: function(sender_id) {
+ return wot.allowed_senders[sender_id] || wot.debug; // allow known senders or any in
+ },
+
+ /* i18n */
+
+ i18n: function(category, id, shorter)
+ {
+ var msg = category;
+
+ if (shorter) {
+ msg += "__short";
+ }
+
+ if (id != null) {
+ msg += "_" + id;
+ }
+
+ var result = chrome.i18n.getMessage(msg);
+
+ if (result == null) {
+ result = this.debug ? "!?" : "";
+ }
+
+ // Workaround for the Chrome's issue 53628
+ // http://code.google.com/p/chromium/issues/detail?id=53628
+ var temp_workaround = {
+ "warnings_warning": "Warning!",
+ "warnings_goto": "Go to the site",
+ "warnings_leave": "Leave the site",
+ "warnings_back": "Go back"
+ };
+
+ if (result == "") {
+ var res_2 = temp_workaround[msg];
+ if (res_2 != "") return res_2;
+ }
+
+ // END of workaround / remove it when the bug will be fixed
+
+ return result;
+ },
+
+ /* helpers */
+
+ getuniques: function(list)
+ {
+ var seen = {};
+
+ return list.filter(function(item) {
+ if (seen[item]) {
+ return false;
+ } else {
+ seen[item] = true;
+ return true;
+ }
+ });
+ },
+
+ /* rules */
+
+ matchruleurl: function(rule, url)
+ {
+ try {
+ return (RegExp(rule.url).test(url) &&
+ (!rule.urlign || !RegExp(rule.urlign).test(url)));
+ } catch (e) {
+ console.log("matchurl: failed with " + e + "\n");
+ }
+
+ return false;
+ },
+
+ /* reputation and confidence */
+
+ getlevel: function(levels, n, next)
+ {
+ next = next ? next : false;
+
+ var next_level = levels[levels.length - 1];
+
+ for (var i = levels.length - 1; i >= 0; --i) {
+ if (n >= levels[i].min) {
+ return next ? next_level : levels[i];
+ }
+ next_level = levels[i];
+ }
+
+ return levels[1];
+ },
+
+ get_level_label: function (component, rep_level, my) {
+ my = my || false;
+
+ if (my) {
+ return wot.i18n("testimony", component + "_levels_" + rep_level);
+ } else {
+ return wot.i18n("reputationlevels", rep_level);
+ }
+ },
+
+ get_user_level: function (activity_score, next) {
+ activity_score = parseInt(activity_score) || 0;
+ return wot.getlevel(wot.activityscore_levels, activity_score, next);
+ },
+
+ getwarningtypeforcomponent: function(comp, data, prefs)
+ {
+ var type = prefs["warning_type_" + comp] || this.warningtypes.none;
+
+ if (!prefs["show_application_" + comp] ||
+ type == this.warningtypes.none) {
+ return null;
+ }
+
+ var r = -1, c = -1, t = -1;
+
+ if (data[comp]) {
+ r = data[comp].r;
+ c = data[comp].c;
+ t = data[comp].t;
+ }
+
+ var warninglevel = prefs["warning_level_" + comp] || 0;
+ var minconfidence = prefs["min_confidence_level"] || 0;
+ var forunknown = prefs["warning_unknown_" + comp];
+
+ var rr = (r < -1) ? 0 : r;
+ var cc = (c < -1) ? warninglevel : c;
+
+ if (((rr >= 0 && rr <= warninglevel && /* poor reputation */
+ /* and sufficient confidence */
+ (cc >= minconfidence || forunknown)) ||
+ /* or no reputation and warnings for unknown sites */
+ (rr < 0 && forunknown)) &&
+ /* and no rating that overrides the reputation */
+ (t < 0 || t <= warninglevel)) {
+ if (r < 0) {
+ return {
+ type: type,
+ reason: this.warningreasons.unknown
+ };
+ } else {
+ return {
+ type: type,
+ reason: this.warningreasons.reputation
+ };
+ }
+ }
+
+ /* or if the user has rated the site poorly */
+ if (t >= 0 && t <= warninglevel) {
+ return {
+ type: type,
+ reason: this.warningreasons.rating
+ };
+ }
+
+ return null;
+ },
+
+ getwarningtype: function(data, prefs)
+ {
+ var warning = {
+ type: this.warningtypes.none,
+ reason: this.warningreasons.none
+ };
+
+ this.components.forEach(function(item) {
+ var comp = wot.getwarningtypeforcomponent(item.name, data, prefs);
+
+ if (comp) {
+ warning.type = Math.max(warning.type, comp.type);
+ warning.reason = Math.max(warning.reason, comp.reason);
+ }
+ });
+
+ return warning;
+ },
+
+ /* paths */
+
+ getlocalepath: function(file)
+ {
+ return "_locales/" + this.i18n("locale") + "/" + file;
+ },
+
+
+ getincludepath: function(file)
+ {
+ return "skin/include/" + file;
+ },
+
+ geticon: function(r, size, accessible, options)
+ {
+ var name = "/",
+ has_subtype = false,
+ sub_type = "plain";
+
+ if (options instanceof Object) {
+ sub_type = options.subtype;
+ has_subtype = !!sub_type;
+ // todo: get other option here
+ } else {
+ // compatibility with old code (non-refactored: options is boolean)
+ has_subtype = options; // sub_type might only be "plain" if plain is true.
+ }
+
+ if (typeof(r) == "number") {
+ name += this.getlevel(this.reputationlevels, r).name;
+ } else {
+ name += r;
+ }
+
+ if (has_subtype) {
+ name = "/" + sub_type + name;
+ }
+
+ var path = "skin/fusion/";
+
+ if ((typeof(r) != "number" || r >= -1) && accessible) {
+ path += "accessible/";
+ }
+
+ return path + size + "_" + size + name + ".png";
+ },
+
+ contextedurl: function(url, context)
+ {
+ var newurl = url;
+ newurl += ( (url.indexOf("?") > 0) ? "&" : "?" );
+ newurl += "utm_source=addon&utm_content=" + context;
+ return newurl;
+ },
+
+ detect_environment: function(readonly)
+ {
+ readonly = readonly || false;
+ // try to understand in which environment we are run
+ var user_agent = window.navigator.userAgent || "";
+ wot.env.is_mailru = user_agent.indexOf("MRCHROME") >= 0;
+
+ // old yandex browser is named "Yandex Internet" (chromium 18), new browser is named "YaBrowser" (chromium 22+)
+ wot.env.is_yandex = user_agent.indexOf("YaBrowser") >= 0 || user_agent.indexOf(" YI") >= 0;
+
+ if(wot.env.is_mailru) {
+ // set param to label requests
+ wot.partner = "mailru";
+ }
+
+ if(!readonly) wot.prefs.set("partner", wot.partner);
+
+ // Is the mode "accessible" set on?
+ wot.env.is_accessible = wot.prefs.get("accessible");
+ },
+
+ cache_locale: function () {
+ wot.lang = wot.i18n("lang");
+ wot.locale = wot.i18n("locale");
+ },
+
+ time_sincefirstrun: function()
+ {
+ // gives time (in seconds) spent from very first run of the addon.
+ var starttime_str = wot.prefs.get("firstrun:time");
+ if (starttime_str) {
+ var starttime = new Date(starttime_str);
+ return (new Date() - starttime) / 1000; // in seconds;
+
+ } else {
+ return undefined;
+ }
+ },
+
+ time_since: function(a, b) {
+
+ if (typeof a === "string") {
+ a = new Date(a);
+ }
+
+ b = b || new Date();
+
+ if (typeof b === "string") {
+ b = new Date(b);
+ }
+
+ return (b - a) / 1000; // in seconds
+ },
+
+ is_defined: function (list, prefix) {
+ // test if locale strings are available (due to bug in Chrome, it is possible to get "undefined")
+ if (list instanceof Array != true) return false;
+ for(var i in list) {
+ if (wot.i18n(prefix, list[i]) === undefined) {
+ return false; // avoid showing "undefined" strings in Tips. Postpone to browser's restart (it fixes usually)
+ }
+ }
+ return true;
+ },
+
+ get_activity_score: function (onget) {
+ var pref_name = "activity_score",
+ proxy_wot = wot;
+ if (wot.core || wot.ratingwindow) {
+ // wow, we are in the background page or Rating window
+
+ if (wot.ratingwindow) {
+ // use reference to BG page
+ var bg = chrome.extension.getBackgroundPage();
+ proxy_wot = bg.wot;
+ }
+
+ if (proxy_wot.core.activity_score == 0) {
+ // lets check what we have in local storage
+ return proxy_wot.prefs.get(pref_name);
+ } else {
+ return proxy_wot.core.activity_score;
+ }
+ } else {
+ // yay, we are in a content script. Have to use functional-style
+ wot.prefs.get(pref_name, onget);
+ }
+ },
+
+ // copies and validates categories from saved preferences (actually prefs['update:state'])
+ init_categories: function (_prefs) {
+ try {
+ var update_state = (typeof _prefs.get == "function") ? _prefs.get("update:state") : _prefs["update:state"];
+
+ if (update_state && !wot.utils.isEmptyObject(update_state) &&
+ update_state.categories && update_state.categories.length > 0) {
+
+ // update groupings and groups
+ if(update_state.categories[0].grouping) {
+ var groupings = update_state.categories[0].grouping;
+ for (var k=0; k < groupings.length; k++) {
+ var grp = groupings[k];
+ grp.tmax = grp.tmax !== undefined ? parseInt(grp.tmax) : undefined;
+ grp.tmin = grp.tmin !== undefined ? parseInt(grp.tmin) : undefined;
+ grp.groups = grp.group; // change the name to comply with current implementation
+ delete grp.group;
+
+ if (grp.groups) {
+ for (var n=0; n < grp.groups.length; n++) {
+ wot.cgroups[grp.groups[n].name] = {
+ type: grp.groups[n].type
+ }
+ }
+ }
+ }
+ wot.grouping = groupings;
+ }
+
+ // update categories
+ if (update_state.categories[0].category) {
+ var cats = update_state.categories[0].category;
+ for (var m=0; m < cats.length; m++) {
+ cat = cats[m];
+ if (cat.name && cat.text != null) {
+ cat.id = parseInt(cat.name);
+ if (cat.group && wot.cgroups[cat.group] && wot.cgroups[cat.group].type) {
+ cat.type = wot.cgroups[cat.group].type;
+ }
+ cat.cs = (cat.application == "4"); // set CS flag
+ wot.categories[cat.name] = cat;
+ }
+ }
+ }
+ } else {
+ console.warn("No categories are known yet. Not good situation.");
+ }
+ } catch (e) {
+ console.error("init_categories() failed, ", e);
+ }
+ },
+
+ get_category: function (cat_id) {
+ var cid = String(cat_id),
+ cat = {};
+ if (wot.categories && wot.categories[cid]) {
+ cat = wot.categories[cid];
+ cat.id = cid;
+ }
+ return cat;
+ },
+
+ get_category_name: function (cat_id, is_short) {
+ var cat = wot.get_category(cat_id);
+ var text = is_short ? cat.shorttext : cat.text;
+ return text ? text : cat.text; // if no short name is known, return full name
+ },
+
+ get_category_group_id: function (cat_id) {
+ return wot.get_category(cat_id).group;
+ },
+
+ get_category_css: function (cat_id) {
+ var type = wot.get_category(cat_id).type;
+ return type !== undefined ? "c-" + type : "";
+ },
+
+ 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 = wot.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) {
+ console.error("Failed to rearrange categories", 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) {
+ console.error("Failed to rearrange categories", e);
+ }
+ }
+
+ return {
+ all: alltogether,
+ trustworthy: sort_array,
+ childsafety: cs_array
+ };
+ },
+
+ select_categories: function (g_from, g_to) {
+ var l = [];
+ for(var i in wot.categories) {
+ var c = wot.categories[i];
+ if (((g_from != null && c.group >= g_from) || g_from == null) &&
+ ((g_to != null && c.group <= g_to) || g_to == null)) {
+ l.push(parseInt(i));
+ }
+ }
+ return l;
+ },
+
+ select_identified: function (cat_list) {
+ // Returns categories identified by community (not sorted order)
+ var res = {};
+ for (var i in cat_list) {
+ var cat = cat_list[i];
+ if (cat.c >= wot.category_threshold) res[i] = cat;
+ }
+ return res;
+ },
+
+ select_voted: function (cat_list) {
+ // Returns categories voted by the current user (the state from server/cache)
+
+ var res = {};
+ for (var i in cat_list) {
+ var cat = cat_list[i];
+ if (cat.v != 0 && cat.v !== undefined) res[i] = cat;
+ }
+
+ return res;
+ },
+
+ determ_grouping: function (t0, type) {
+ // Return proper grouping ID for the category selector based on user's testimonies
+
+ var grp = {};
+ for (var gi=0; gi < wot.grouping.length; gi++) {
+ grp = wot.grouping[gi];
+ if ((grp.omnipresent && type === "omnipresent") || (grp.dynamic && type === "dynamic")) return grp;
+ else {
+ if (!grp.omnipresent && !type) { // skip only omnipresent, and if type is not set
+ var tmin = grp.tmin !== null ? grp.tmin : -1,
+ tmax = grp.tmax !== null ? grp.tmax : -1;
+ if ((t0 == -1 && grp.dynamic) || (t0 >= tmin && t0 <= tmax)) {
+ return grp;
+ }
+ }
+ }
+ }
+
+ return {};
+ },
+
+ is_rated: function (cached) {
+
+ if (cached && cached.value) {
+ return wot.components.some(function(item) {
+ return (cached.value[item.name] &&
+ cached.value[item.name].t >= 0);
+ });
+ }
+
+ return false;
+ }
+};
+
+
+wot.utils = {
+
+ get_document: function (frame) {
+ frame = frame || window;
+ var framed_document = frame.document || frame.contentDocument;
+ return framed_document;
+ },
+
+ get_or_create_element: function (id, tag, frame) {
+ tag = tag || "div";
+ var framed_document = wot.utils.get_document(frame);
+
+ var elem = framed_document.getElementById(id);
+
+ if(!elem) {
+ elem = framed_document.createElement(tag);
+ elem.setAttribute("id", id);
+ }
+
+ return elem;
+ },
+
+ attach_element: function (element, frame) {
+ var framed_document = wot.utils.get_document(frame);
+
+ if(framed_document) {
+ var body = framed_document.getElementsByTagName("body");
+
+ if (!element || !body || !body.length) {
+ return false;
+ }
+
+ return body[0].appendChild(element);
+ } else {
+ wot.log("Can't get document of frame");
+ return false;
+ }
+
+ },
+
+ attach_style: function (style_file_or_object, uniq_id, frame) {
+ try {
+ uniq_id = uniq_id || null;
+ var reuse_style = false;
+
+ var framed_document = wot.utils.get_document(frame);
+
+ if(!framed_document) {
+ return false;
+ }
+
+ if(uniq_id) {
+ var el = framed_document.getElementById(uniq_id);
+ if(el) {
+ // if the element exists already - remove it to update styles
+ reuse_style = true;
+ }
+ }
+
+ var head = framed_document.getElementsByTagName("head");
+
+ if (!head || !head.length) {
+ return false;
+ }
+
+ var style = reuse_style ? el : framed_document.createElement("style");
+
+ if (!style) {
+ return false;
+ }
+
+ if(uniq_id) {
+ style.setAttribute("id", uniq_id);
+ }
+
+ style.setAttribute("type", "text/css");
+
+ if (typeof style_file_or_object === "object") {
+ style.innerText = style_file_or_object.style;
+ } else {
+ style.innerText = "@import \"" +
+ chrome.extension.getURL(wot.getincludepath(style_file_or_object)) +
+ "\";";
+ }
+
+ if (!reuse_style) {
+ head[0].appendChild(style);
+ }
+
+ return true;
+ } catch (e) {
+ console.log("wot.utils.attach_style() failed with", e, "Arguments:", arguments);
+ return false;
+ }
+ },
+
+ processhtml: function (html, replaces) {
+ try {
+ replaces.forEach(function(item) {
+ html = html.replace(RegExp("{" + item.from + "}", "g"),
+ item.to);
+ });
+
+ return html;
+ } catch (e) {
+ console.log("warning.processhtml: failed with " + e);
+ }
+
+ return "";
+ },
+
+ htmlescape: function(str) {
+ var tagsToReplace = {
+ '&': '&',
+ '<': '<',
+ '>': '>'
+ };
+ return str.replace(/[&<>]/g, function(symb) {
+ return tagsToReplace[symb] || symb;
+ });
+ },
+
+ isEmptyObject: function (obj) {
+ for (var name in obj) {
+ return false;
+ }
+ return true;
+}
+};
diff --git a/content/ui.js b/content/ui.js
index 5c2835b..b2c3fb4 100644
--- a/content/ui.js
+++ b/content/ui.js
@@ -147,7 +147,7 @@ var wot_ui = {
mainwnd.setAttribute("wot-partner", partner);
}
- this.getElem("wot-partner").hidden = !partner.length;
+// this.getElem("wot-partner").hidden = !partner.length;
}
} catch (e) {
wdump("wot_ui.show_partner: failed with " + e);
diff --git a/content/util.js b/content/util.js
index c624455..c35a9a4 100644
--- a/content/util.js
+++ b/content/util.js
@@ -64,6 +64,28 @@ var wot_util =
return null;
},
+ get_all_strings: function () {
+ var res = {};
+ try {
+ if (!this.string_bundle) {
+ this.string_bundle = document.getElementById("wot-strings");
+ }
+
+ var strings = this.string_bundle.strings;
+
+ while (strings.hasMoreElements()) {
+ var property = strings.getNext().QueryInterface(Components.interfaces.nsIPropertyElement);
+ res[property.key] = property.value;
+ }
+ return res;
+
+ } catch (e) {
+ dump("wot_util.getstring: failed with " + e + "\n");
+ }
+
+ return res;
+ },
+
get_level: function (levels, value, next) {
next = next ? next : false;
@@ -301,7 +323,7 @@ var wot_url =
try {
base = base || WOT_PREF_PATH;
- var path = base + wot_util.getstring("language") +
+ var path = base + wot_util.getstring("lang") +
"/" + WOT_PLATFORM + "/" + WOT_VERSION;
var url = path;
@@ -331,7 +353,7 @@ var wot_url =
{
try {
var params = "&lang=" +
- (wot_util.getstring("language") || "en-US");
+ (wot_util.getstring("lang") || "en-US");
var partner = wot_partner.getpartner();
@@ -539,7 +561,7 @@ var wot_browser =
.getService(Components.interfaces.nsIBrowserSearchService);
var url = WOT_SAFESEARCH_OSD_URL;
- var lang = wot_util.getstring("language");
+ var lang = wot_util.getstring("lang");
if (lang) {
url = url.replace("/en-US", "/" + lang);
diff --git a/locale/en-US/wot.properties b/locale/en-US/wot.properties
index 9e670fd..b12fd0b 100644
--- a/locale/en-US/wot.properties
+++ b/locale/en-US/wot.properties
@@ -1,17 +1,18 @@
-language = en-US
+locale = en
+lang = en-US
auto_update_title = WOT Update
auto_update_message = A new version of WOT is available. Would you like to update your add-on?
auto_update_check = Enable automatic updates (recommended)
auto_update_button_yes = Update now
auto_update_button_no = Remind me later
-description_init = Initializing WOT...
-description_disabled = You have disabled the add-on; click to enable.
-description_error_query = Failed to load ratings; retrying shortly.
-description_error_register = Failed to activate the add-on; retrying shortly.
-description_inprogress = Loading ratings…
-description_notready = Activating WOT…
-description_offline = Disabled while the browser is offline.
-description_private = Ratings are not available.
+messages_initializing = Initializing WOT…
+messages_loading = Loading ratings…
+messages_notready = Activating WOT…
+messages_failed = Failed to load ratings; retrying shortly
+messages_notavailable = Ratings are not available
+message_error_register = Failed to activate the add-on; retrying shortly.
+message_offline = Disabled while the browser is offline.
+message_disabled = You have disabled the add-on; click to enable.
description_rating_5 = Excellent
description_rating_4 = Good
description_rating_3 = Unsatisfactory
@@ -71,4 +72,116 @@ bl_phishing = Phishing
bl_scam = Scam
bl_spam = SPAM
bl_tracking = Tracking
-bl_other = Other reason
\ No newline at end of file
+bl_other = Other reason
+ext_description = WOT helps you find trustworthy websites based on millions of users’ experiences and is one of Chrome’s most popular add-ons.
+components_0 = Trustworthiness
+components_1 = Vendor reliability
+components_2 = Privacy
+components_4 = Child safety
+components__short_0 = Trustworthiness
+components__short_1 = Vendor reliability
+components__short_2 = Privacy
+components__short_4 = Child safety
+reputationlevels_r0 = Unknown
+reputationlevels_r1 = Very poor
+reputationlevels_r2 = Poor
+reputationlevels_r3 = Unsatisfactory
+reputationlevels_r4 = Good
+reputationlevels_r5 = Excellent
+ratingwindow_settings = Settings
+ratingwindow_guide = Tour
+ratingwindow_forum = Forum
+ratingwindow_profile = My profile
+ratingwindow_wotrating = Website's reputation based on user ratings
+ratingwindow_myrating = My rating
+ratingwindow_viewscorecard = View details and comments
+ratingwindow_addcomment = Add a comment
+ratingwindow_editcomment = Edit the comment
+ratingwindow_backtoratings = Back to ratings
+ratingwindow_backtoratings_category = Pick a category
+ratingwindow_inpartnership = In partnership with
+ratingwindow_newversion = New version available - click to update
+ratingwindow_helptext = Your rating differs
+ratingwindow_helplink = Leave a comment?
+ratingwindow_invite_rw = You can rate websites using this tool. Click on the colored bars to express how much you trust a website.
+warnings_information = View details and comments
+warnings_ratesite = If you trust this site, please <a>rate it</a>
+warnings_gotosite = Ignore warning and go to the site
+warnings_reputation = This site has a poor reputation based on<br/>user ratings
+warnings_rating = You have given this site a poor rating,<br/>which triggered a warning
+warnings_unknown = This site has an unknown rating
+warnings_warning = Warning!
+warnings_goto = Go to the site
+warnings_leave = Exit
+warnings_back = Go back
+warnings_reasontitle = Users have identified the following issues
+warnings_noreasontitle = Users have not identified this site yet and only have rated it
+contextmenu_open_scorecard = Open WOT scorecard
+wt_learnmore_link = <a id='wt-learnmore-link'>Learn more</a> about WOT.
+wt_intro_0_msg = <img src='{ADDON_BASEURI}skin/b/welcometips/wt_intro_0.png' width='196px' height='40px'/><p class='wot-cb'>You are protected!</p><p>Safe surfing tool Web of Trust (WOT) shows which websites you can trust based on millions of users' experiences.</p><p>Click the icon {ICO1} on your browser toolbar to start using WOT.</p><p>{WT_LEARNMORE}</p>",
+wt_intro_0_btn = OK, got it
+wt_warning_text = <p class='wot-cb'>Be aware of untrustworthy sites!</p><p>Safe surfing tool WOT shows you a warning if you land on a site that has a bad reputation based on user ratings.</p><p>{WT_LEARNMORE}</p><p>If you don't want to see warnings, you can turn them off.</p>",
+wt_warning_turnoff = Turn warnings off
+wt_warning_ok = OK, got it
+wt_rw_text_hdr = Share your experiences!
+wt_rw_text = <p>WOT shows website reputations based on experiences from millions of users.</p><p>Leave your own rating by clicking the colored bars to indicate what you think of the site. Your rating helps other users surf safer.</p><p class='wot-c'><a id='wt-learnmore-link'>Learn more</a> about WOT.</p>
+wt_rw_ok = Show me rating window
+wt_donut_msg = <p class='wot-cb'>Follow the traffic lights!</p></p>Safe surfing tool WOT shows website reputations based on experiences from millions of users.</p><p>Traffic lights after web links guide you to find sites that you can trust: green for good, red for bad, yellow as a warning to be cautious.</p>
+wt_donut_btn = OK, got it
+fbl_hideforever = Hide forever
+fbl_submit = Submit
+fbl_whatisthis = What's this?
+fbl_optout_text = If you prefer not to be asked questions, click \"yes\"
+fbl_optout_yes = yes
+fbl_optout_no = No
+fbl_whatisthis_text = <a href='http://beta.mywot.com?utm_source=addon&utm_content=fbl-whatisthis' target='_blank'>Web of Trust (WOT)</a> is working to promote safety and quality across the web for millions of users. You can help by submitting your opinions whenever you see this prompt.
+fbl_final = Thank you!
+fbl_this_website = this website
+fbl_dismiss = dismiss
+ratingwindow_question0 = How much do you trust this site?
+ratingwindow_question4 = How suitable is this site for children?
+ratingwindow_categories = Pick at least one category to support your rating
+ratingwindow_comment = Leave a comment to describe your experience with this site
+ratingwindow_comment_placeholder = write your comment here...
+ratingwindow_comment_regtext = You need an account to publish your comment.
+ratingwindow_comment_register = Create an account now
+ratingwindow_comment_captchatext = You need to enter captcha on the scorecard to publish your comment.
+ratingwindow_comment_captchalink = Open scorecard now
+ratingwindow_commenthints = <p>Be precise</p><p>Give evidence or example</p><p>Comment according to your real experiences</p><p>Do not spam</p>
+ratingwindow_novoted = Click here to provide a reason for your rating by selecting a category
+ratingwindow_morecats = more
+ratingwindow_rerate_change = change
+ratingwindow_rerate_category =
+ratingwindow_fulllist = show full list
+ratingwindow_vote_yes = Yes
+ratingwindow_vote_no = No
+messages_ready = Reputation of
+testimony_0_levels_r0 = click the bar to rate
+testimony_0_levels_r1 = I don't trust
+testimony_0_levels_r2 = I don't trust
+testimony_0_levels_r3 = it is suspicious
+testimony_0_levels_r4 = I trust
+testimony_0_levels_r5 = I trust
+testimony_4_levels_r0 = click the bar to rate
+testimony_4_levels_r1 = not suitable
+testimony_4_levels_r2 = not suitable
+testimony_4_levels_r3 = be cautious
+testimony_4_levels_r4 = suitable
+testimony_4_levels_r5 = suitable
+testimony_unrated = no opinion
+testimony_delete = delete
+buttons_delete = Delete ratings
+buttons_delete_title = Delete my ratings and categories for the website
+buttons_cancel = Cancel
+buttons_save = Save
+buttons_ok = OK
+popup_headertext = click to view details
+popup_nocattext = share your opinion about this website
+ratingwindow_thankyou = Thanks for sharing your experience!
+activityscore_text = Your activity score is now
+activityscore_rookie = rookie
+activityscore_bronze = bronze
+activityscore_silver = silver
+activityscore_gold = gold
+activityscore_platinum = platinum
+activityscore_next = Keep on rating and commenting to reach {NEXT_LEVEL} level!
\ No newline at end of file
diff --git a/skin/b/ratingwindow.css b/skin/b/ratingwindow.css
new file mode 100644
index 0000000..b8fea7e
--- /dev/null
+++ b/skin/b/ratingwindow.css
@@ -0,0 +1,1766 @@
+/*
+ ratingwindow.css
+ Copyright © 2009 - 2013 WOT Services Oy <info at mywot.com>
+
+ This file is part of WOT.
+
+ WOT is free software: you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ WOT is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with WOT. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+body {
+ overflow: hidden;
+ cursor: default;
+ -webkit-user-select: none;
+ width: 580px;
+}
+
+#wot-ratingwindow {
+ display: block;
+ padding: 10px 16px 0;
+ min-height: 390px;
+}
+
+#wot-elements {
+ background: #ffffff;
+ display: block;
+ font-family: Arial, sans-serif;
+ margin: 0;
+ padding: 0;
+ /*width: 316px;*/
+}
+
+/* header, always visible */
+#wot-header {
+ position: relative;
+}
+
+/* Always visible */
+#ratings-area {
+ min-height: 94px;
+ position: relative;
+ background-color: #f9f9f9;
+ padding: 4px 10px;
+ margin: 0 -16px;
+}
+
+/* height of rating area depends on the mode:
+ low height (94px): unrated, rate
+ high height: (122px): rated, commenting, thanks
+
+ */
+.view-mode #ratings-area,
+.commenting #ratings-area {
+ min-height: 122px; /* to fit categories or activity score */
+}
+
+#ratings-area:before,
+#ratings-area:after {
+ position: absolute;
+ left: -13px;
+ width: 105%;
+ content: "";
+}
+
+#ratings-area:before {
+ border-top: 1px solid #D2D2D2;
+ top: 0;
+}
+
+#ratings-area:after {
+ border-bottom: 1px solid #D2D2D2;
+ content: "";
+ bottom: 0;
+}
+
+#ratings-area[disabled=disabled],
+#ratings-area[disabled=disabled] .wot-rating-slider {
+ filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+ */
+ -webkit-filter: grayscale(100%);
+ opacity: 0.7;
+}
+
+/* Always visible */
+#main-area {
+ min-height: 182px;
+ padding: 4px 10px;
+ margin: 0 -11px;
+}
+
+.rate #main-area {
+ min-height: 210px;
+}
+
+/* Always visible */
+#bottom-area {
+ /*min-height: 3em;*/
+ padding: 0 8px;
+}
+
+.rate #bottom-area {
+ min-height: 3em;
+}
+
+#header-line-1 {
+ min-height: 1em;
+}
+
+#header-line-2 {
+ min-height: 1.4em;
+ margin-top: -4px;
+ padding-left: 4px;
+}
+
+#wot-header-logo {
+ position: absolute;
+ top: 2px;
+ left: 0;
+ background: url("fusion/logo.png") top left no-repeat;
+ cursor: pointer;
+ display: inline-block;
+ /*float: left;*/
+ height: 17px;
+ width: 42px;
+}
+
+/* we should not modify logo in accessible mode */
+/*#wot-header-logo.accessible {*/
+/*background: url("fusion/accessible/logo.png") top left no-repeat;*/
+/*}*/
+
+#wot-header-links {
+ position: absolute;
+ top: 2px;
+ right: 14px;
+}
+
+.wot-header-link {
+ color: #8f8f8f;
+ display: table-cell;
+ /*float: right;*/
+ font-size: 11px;
+ height: 16px;
+ /*line-height: 16px;*/
+ padding: 0 0.6em;
+}
+
+.wot-header-link:hover {
+ color: #3073c5;
+ cursor: pointer;
+}
+
+.wot-header-link.accessible:hover {
+ color: #333;
+ text-decoration: underline;
+}
+
+#wot-header-close {
+ position: absolute;
+ top: -1px;
+ right: -5px;
+ height: 14px;
+ width: 14px;
+ background-color: #FFF;
+ margin: 0 0 0 1px;
+ border-radius: 3px;
+ border: 1px solid #B9B9B9;
+ cursor: pointer;
+}
+
+#wot-header-close:hover {
+ background-color: #f4f4f4;
+ border: 1px solid #939393;
+}
+
+/* Cross inside the "close" icon */
+#wot-header-close:after,
+#wot-header-close:before {
+ content: "";
+ position: absolute;
+ top: 50%;
+ z-index: 4;
+ left: 6px;
+ width: 2px;
+ height: 12px;
+ margin-top: -6px;
+ background: #A2A2A2;
+}
+
+#wot-header-close:before {
+ -webkit-transform: rotate(45deg);
+}
+
+#wot-header-close:after {
+ -webkit-transform: rotate(135deg);
+}
+
+#wot-title-text {
+ position: absolute;
+ left: 56px;
+ color: #777676;
+ font-size: 14px;
+ overflow: hidden;
+ top: 0;
+}
+
+/*#wot-title-text[status="information"] {*/
+/*color: #4e4e4e;*/
+/*}*/
+
+/* Hostname */
+#hostname-text {
+ margin-left: 52px;
+ color: #454545;
+ font-size: 13px;
+ font-weight: bold;
+ overflow: hidden;
+ -webkit-user-select: text;
+ margin-top: 5px;
+ display: block;
+}
+
+/*#hostname-text[status="information"] {*/
+/*color: #4e4e4e;*/
+/*}*/
+
+/* rating header */
+#wot-rating-header {
+ color: #878787;
+ display: none;
+ font-size: 11px;
+ height: 17px;
+ margin-left: 2px;
+ margin-right: 2px;
+ padding-left: 0;
+ padding-top: 2px;
+ width: 312px;
+}
+
+#wot-myratings-header {
+ position: relative;
+ min-height: 1em;
+ margin-top: 7px;
+ left: 14px;
+}
+
+#myrating-header {
+ margin-left: 10px;
+ font-size: 14px;
+ font-weight: bold;
+ color: #454545;
+}
+
+/* Headers for rating controls */
+#wot-myrating-0-header,
+#wot-myrating-4-header {
+ /*left: 1em;*/
+ font-size: 12px;
+ position: absolute;
+ color: #5C5C5C;
+ margin-top: 6px;
+ margin-left: 10px;
+}
+
+/* Diff for CS rating control */
+#wot-myrating-4-header {
+ left: 268px;
+ color: rgb(92, 92, 92);
+ font-size: 9pt;
+}
+
+/* rating */
+.wot-rating-border {
+ border-top: 1px solid #f4f4f4;
+ display: block;
+ height: 1px;
+ margin-left: 2px;
+ margin-right: 2px;
+ width: 312px;
+}
+.wot-rating {
+ position: absolute;
+ height: 60px;
+ margin-left: 16px;
+ margin-right: 0;
+ width: 240px;
+ -webkit-user-select: none;
+ top: 42px;
+}
+
+/* Child Safety rating control */
+#wot-rating-4 {
+ left: 278px;
+}
+
+#rated-votes {
+ margin-top: 74px;
+ font-size: 12px;
+ padding: 0px 0px 0px 25px;
+ max-height: 2em;
+ display: none;
+}
+
+#wot-ratingwindow:not(.commenting) #rated-votes.commented,
+#wot-ratingwindow:not(.commenting) #rated-votes:not(.commented):not(.voted) {
+ padding-left: 53px;
+}
+
+#rated-votes:before {
+ content: "";
+ position: absolute;
+ background-image: url(../skin/b/input-icons.png);
+ background-repeat: no-repeat;
+ background-position: 0 0;
+ background-size: 40px auto;
+ width: 21px;
+ height: 20px;
+ margin-left: -30px;
+ margin-top: 0;
+}
+
+#rated-votes:not(.commented).voted:before {
+ /* don't show icon if website is not commented */
+ /*background-position: 0 -20px;*/
+ display: none;
+}
+
+#rated-votes.voted.commented:before {
+ background-position: -20px 0px;
+ margin-top: 2px;
+}
+
+#rated-votes:not(.voted).commented:before {
+ /*background-position: 0 -62px;*/
+ background-position: 0 0;
+}
+
+.commenting #rated-votes:before {
+ /* hide icon in Commenting mode */
+ display: none;
+}
+
+#voted-categories {
+ width: 425px;
+ position: absolute;
+ overflow: hidden;
+ color: #acacac;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ padding: 1px 0;
+ height: 20px;
+}
+
+#rated-votes.voted #voted-categories {
+ color: #6A6A6A;
+}
+
+#voted-categories-content {
+ border-bottom: 1px dotted transparent;
+ cursor: pointer;
+}
+
+#rated-votes:not(.voted) #voted-categories-content {
+ color: #d14540;
+ font-weight: bold;
+ display: inline;
+}
+
+/*#rated-votes #voted-categories-content:hover {*/
+ /*border-bottom-color: #acacac;*/
+/*}*/
+
+#rated-votes:not(.voted) #voted-categories-content:hover {
+ border-bottom-color: #d14540;
+}
+
+#voted-categories-content .votedcategory {
+ width: auto;
+ border-radius: 100px;
+ -moz-border-radius: 100px;
+ -webkit-border-radius: 100px;
+ border: 1px solid #DEDEDE;
+ background-color: #DEDEDE;
+ height: 15px;
+ width: 81px;
+ float: left;
+ margin: 2px 4px 2px 0;
+}
+
+#voted-categories-content .category-text {
+ float: left;
+ font-size: 11px;
+ color: #515151;
+ padding-left: 5px;
+ line-height: 15px;
+ width: 52px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
+ cursor: pointer;
+}
+
+#voted-categories-content .more-categories {
+ font-size: 11px;
+ color: #808080;
+ padding: 5px 0;
+}
+
+.category-hand {
+ padding: 0 6px 4px 4px;
+ float: left;
+ border-radius: 100px 0 0 100px;
+ -moz-border-radius: 100px 0 0 100px;
+ -webkit-border-radius: 100px 0 0 100px;
+ height: 11px;
+ width: 8px;
+}
+
+.category-hand.hand-up {
+ background-color: #FCFCFC;
+}
+
+.category-hand.hand-down {
+ background-color: #A3A3A3;
+}
+
+.hand-up .hand-icon,
+.hand-down .hand-icon {
+ background-image: url(../skin/b/thumbs.png);
+ background-repeat: no-repeat;
+ width: 12px;
+ height: 14px;
+}
+
+
+.hand-down .hand-icon {
+ background-position: -12px 0;
+}
+
+#change-ratings {
+ position: absolute;
+ right: 50px;
+ margin-top: 5px;
+ border-bottom: 1px dotted #3163B9;
+ color: #3163B9;
+ cursor: pointer;
+}
+
+/* don't chow this link during "commenting" mode */
+.commenting #change-ratings {
+ visibility: hidden;
+}
+
+.wot-rating-header {
+ color: #454545;
+ display: block;
+ font-size: 12px;
+ margin-bottom: 0.7em;
+ margin-top: 9px;
+}
+
+.wot-rating-data {
+ display: block;
+}
+
+.rating-values {
+ position: relative;
+ min-height: 30px;
+}
+
+.rep-tr-block {
+ width: 250px;
+ position: absolute;
+ top: 0px;
+ left: 11px;
+}
+
+.rep-cs-block {
+ width: 250px;
+ position: absolute;
+ top: 0px;
+ left: 280px;
+}
+
+.wot-rating-reputation {
+ position: absolute;
+ background: url("b/donuts_150.png") top left no-repeat;
+ background-position: 0 -165px;
+ background-size: 35px 198px;
+ height: 33px;
+ width: 35px;
+ margin-left: -5px;
+ margin-top: 10px;
+}
+
+.wot-rating-reputation[reputation="rx"] {
+ background-position: 0 -165px;
+}
+
+.wot-rating-reputation[reputation="r0"] {
+ background-position: 0 -165px;
+}
+
+.wot-rating-reputation[reputation="r1"] {
+ background-position: 0 -132px;
+}
+
+.wot-rating-reputation[reputation="r2"] {
+ background-position: 0 -99px;
+}
+
+.wot-rating-reputation[reputation="r3"] {
+ background-position: 0 -66px;
+}
+
+.wot-rating-reputation[reputation="r4"] {
+ background-position: 0 -33px;
+}
+
+.wot-rating-reputation[reputation="r5"] {
+ background-position: 0 0;
+}
+
+.wot-rating-confidence {
+ position: absolute;
+ height: 42px;
+ margin-left: 26px;
+ margin-top: -2px;
+ width: 34px;
+ background: url("b/confidence_150dpi.png") top left no-repeat;
+ background-size: 33px auto;
+ background-position: 0 -168px;
+}
+
+.wot-rating-confidence[confidence="c1"] {
+ background-position: 0 -126px;
+}
+
+.wot-rating-confidence[confidence="c2"] {
+ background-position: 0 -84px;
+}
+
+.wot-rating-confidence[confidence="c3"] {
+ background-position: 0 -42px;
+}
+
+.wot-rating-confidence[confidence="c4"] {
+ background-position: 0 0;
+}
+
+.wot-rating-confidence[confidence="c5"] {
+ background-position: 0 -210px;
+}
+
+.rating-legend-wrapper {
+ position: absolute;
+ margin: 3px 0 auto 75px;
+ background: url("b/bubl_speech_c_150.png") top left repeat-x;
+ background-size: 1px 23px;
+ height: 23px;
+}
+
+.rating-legend-wrapper:before {
+ position: absolute;
+ content: "";
+ height: 23px;
+ width: 17px;
+ margin-left: -17px;
+ background: url("b/bubl_speech_l_150.png") top left no-repeat;
+ background-size: 17px 23px;
+}
+
+.rating-legend-wrapper:after {
+ position: absolute;
+ content: "";
+ height: 23px;
+ width: 17px;
+ right: -17px;
+ background: url("b/bubl_speech_r_150.png") top left no-repeat;
+ background-size: 10px 23px;
+ top: 0px;
+}
+
+.rating-legend {
+ position: relative;
+ height: 16px;
+ min-width: 48px;
+ margin: -2px 0 0em;
+ padding: 6px 4px 0 0px;
+ color: #454545;
+ font-size: 12px;
+ text-align: center;
+ white-space: nowrap;
+}
+
+/*.rating-legend:after {*/
+ /*position: absolute;*/
+ /*top: 6px;*/
+ /*right: -9px;*/
+ /*width: 9px;*/
+ /*height: 13px;*/
+ /*content: "";*/
+ /*background-image: url("b/rep-explanation.png");*/
+ /*background-repeat: no-repeat;*/
+/*}*/
+
+/*.rating-legend[r=r0] {*/
+/*}*/
+
+/*.rating-legend[r=r1],*/
+/*.rating-legend[r=r2] {*/
+ /*border-color: #f76d66;*/
+ /*background-image: -webkit-linear-gradient(top, rgba(252, 162, 162, 0.28), rgba(236, 29, 28, 0.28));*/
+/*}*/
+
+/*.rating-legend[r=r1]:after,*/
+/*.rating-legend[r=r2]:after {*/
+ /*background-position: 0 -54px;*/
+/*}*/
+
+/*.rating-legend[r=r3] {*/
+ /*border-color: #fecd35;*/
+ /*background-image: -webkit-linear-gradient(top, rgba(253, 234, 167, 0.28), rgba(246, 189, 83, 0.28));*/
+/*}*/
+
+/*.rating-legend[r=r3]:after {*/
+ /*background-position: 0 -36px;*/
+/*}*/
+
+/*.rating-legend[r=r4],*/
+/*.rating-legend[r=r5] {*/
+ /*border-color: #84ca4a;*/
+ /*background-image: -webkit-linear-gradient(top, rgba(215, 240, 179, 0.28), rgba(96, 178, 24, 0.28));*/
+/*}*/
+
+/*.rating-legend[r=r4]:after,*/
+/*.rating-legend[r=r5]:after {*/
+ /*background-position: 0 -18px;*/
+/*}*/
+
+.wot-rating-testimony {
+ display: block;
+ float: left;
+ height: 16px;
+ margin-left: 6px;
+ margin-top: 2px;
+ position: relative;
+}
+
+.wot-rating-bounds {
+ position: relative;
+ font-size: 11px;
+ height: 16px;
+ margin: 4px 48px -6px 2px;
+ color: #919191;
+ opacity: 0;
+ display: none;
+ -webkit-transition: opacity 5.5s;
+}
+
+/* show boundary labels only when rating bars are enabled */
+#ratings-area:not([disabled=disabled]) .wot-rating:hover .wot-rating-data[r=r0] .wot-rating-bounds,
+#ratings-area:not([disabled=disabled]) .wot-rating.hover .wot-rating-data[r=r0] .wot-rating-bounds {
+ opacity: 1;
+ display: block;
+}
+
+#ratings-area:not([disabled=disabled]) .wot-rating:hover .wot-rating-data[r=r0] .wot-rating-help,
+#ratings-area:not([disabled=disabled]) .wot-rating.hover .wot-rating-data[r=r0] .wot-rating-help {
+ display: none;
+}
+
+.wot-rating-data[r] .wot-rating-help {
+ opacity: 1;
+}
+
+.rating-bound-left,
+.rating-bound-right {
+ position: absolute;
+}
+
+.rating-bound-left {
+ left: 0;
+}
+
+.rating-bound-right {
+ right: 0;
+}
+
+.wot-rating-stack {
+ display: block;
+ height: 34px;
+ padding-left: 0;
+ width: 204px;
+ z-index: 5;
+ cursor: pointer;
+}
+
+#ratings-area[disabled=disabled] .wot-rating-stack {
+ cursor: default;
+}
+
+.wot-rating-slider {
+ background: url("b/slider.png") top left no-repeat;
+ background-size: auto 216px;
+ background-position: 0 -180px;
+ display: block;
+ height: 30px;
+ margin-top: 3px;
+ width: 172px;
+ cursor: pointer;
+}
+
+#ratings-area[disabled=disabled] .wot-rating-slider {
+ cursor: default;
+}
+
+.wot-rating-stack[r="r1"] .wot-rating-slider {
+ background-position: 0 -144px;
+}
+
+.wot-rating-stack[r="r2"] .wot-rating-slider {
+ background-position: 0 -108px;
+}
+
+.wot-rating-stack[r="r3"] .wot-rating-slider {
+ background-position: 0 -72px;
+}
+
+.wot-rating-stack[r="r4"] .wot-rating-slider {
+ background-position: 0 -36px;
+}
+
+.wot-rating-stack[r="r5"] .wot-rating-slider {
+ background-position: 0 0;
+}
+
+.wot-rating-indicator {
+ display: block;
+ height: 30px;
+ margin-left: -8px;
+ margin-top: -22px;
+ width: 21px;
+ float: left;
+ position: relative;
+ background: url("b/slider%20handle.png") top left no-repeat;
+ background-size: 21px auto;
+ z-index: 5;
+ left: 166px;
+}
+
+.wot-rating-stack .wot-rating-indicator {
+ background-position: 0 -140px;
+}
+
+.wot-rating-stack.testimony[r="r1"] .wot-rating-indicator {
+ background-position: 0 -112px;
+}
+
+.wot-rating-stack.testimony[r="r2"] .wot-rating-indicator {
+ background-position: 0 -84px;
+}
+
+.wot-rating-stack.testimony[r="r3"] .wot-rating-indicator {
+ background-position: 0 -56px;
+}
+
+.wot-rating-stack.testimony[r="r4"] .wot-rating-indicator {
+ background-position: 0 -28px;
+}
+
+.wot-rating-stack.testimony[r="r5"] .wot-rating-indicator {
+ background-position: 0 0;
+}
+
+/*.wot-rating-stack.testimony:hover .wot-rating-indicator,*/
+/*.wot-rating-stack.testimony .wot-rating-slider:hover + .wot-rating-indicator,*/
+/*.wot-rating-stack.testimony .wot-rating-indicator:hover,*/
+/*.wot-rating-stack.hover:hover .wot-rating-indicator,*/
+/*.wot-rating-stack.hover .wot-rating-slider:hover + .wot-rating-indicator,*/
+/*.wot-rating-stack.hover .wot-rating-indicator:hover {*/
+ /*background: url("b/slider%20handle.png") top left no-repeat;*/
+/*}*/
+
+.wot-rating-help {
+ display: block;
+
+ margin-bottom: -6px;
+ margin-left: 2px;
+ margin-right: 0;
+ margin-top: 4px;
+ width: 154px;
+ -webkit-transition: opacity 2.5s linear 2s;
+}
+
+.wot-rating-data:not([r]) .wot-rating-help {
+ opacity: 0;
+}
+
+.wot-rating-helptext,
+.wot-rating-helplink {
+ height: 16px;
+ margin-top: 3px;
+ font-size: 11px;
+ text-align: left;
+ color: #878787;
+}
+
+.wot-rating-helptext[r=r1] {
+ color: #dd2e31;
+ text-align: left;
+}
+
+.wot-rating-helptext[r=r2] {
+ color: #e25533;
+ text-align: left;
+}
+
+.wot-rating-helptext[r=r3] {
+ color: #de7c1b;
+ text-align: center;
+}
+
+.wot-rating-helptext[r=r4] {
+ color: #5bab28;
+ text-align: right;
+}
+
+.wot-rating-helptext[r=r5] {
+ color: #3b9013;
+ text-align: right;
+}
+
+#ratings-area[disabled=disabled] .wot-rating-helptext {
+ visibility: hidden;
+}
+
+.wot-rating-helplink {
+ display: none;
+}
+.wot-rating-helplink.comment {
+ color: #3073c5;
+ cursor: pointer;
+ display: block;
+}
+.wot-rating-helplink.comment.accessible {
+ color: #333;
+ text-decoration: underline;
+}
+
+.rating-delete {
+ margin-left: 160px;
+ margin-top: 20px;
+ top: 0;
+ position: absolute;
+ z-index: 1;
+}
+
+.rating-delete-icon {
+ position: relative;
+ background: url("b/delete-testimony.png") top left no-repeat;
+ background-size: auto 18px;
+ background-position: -34px 0;
+ width: 18px;
+ height: 18px;
+ margin: -2px 0 0 0;
+}
+
+/* Cross inside the "delete" icon */
+.delete .rating-delete-icon {
+ background-position: 0 0;
+}
+
+.rating-delete.delete .rating-delete-icon,
+.rating-delete.delete .rating-deletelabel {
+ cursor: pointer;
+}
+
+.rating-deletelabel {
+ font-size: 10px;
+ color: #808080;
+ margin: 4px auto 0;
+ text-align: center;
+ height: 1.4em;
+ white-space: nowrap;
+}
+
+.rating-delete.delete:hover .rating-deletelabel {
+ color: red;
+}
+
+.rating-delete.delete:hover .rating-delete-icon {
+ background-position: -17px 0;
+}
+
+/* Reputation Info area */
+
+#reputation-info {
+ padding: 0 9px;
+}
+
+.rep-info-sections {
+ position: relative;
+ padding-top: 9px;
+}
+
+#wot-rating-header-wot {
+ display: block;
+ font-size: 14px;
+ color: #454545;
+ text-align: left;
+ margin-top: 8px;
+ font-weight: bold;
+ margin-left: 11px;
+}
+
+#rep-block {
+ /*width: 200px;*/
+}
+
+/* scorecard */
+#wot-scorecard {
+ position: absolute;
+ right: 104px;
+ top: 130px;
+ z-index: 3;
+}
+
+#wot-scorecard-content {
+}
+
+.wot-scorecard-text {
+ color: #3073c5;
+ font-size: 12px;
+ cursor: pointer;
+}
+
+.wot-scorecard-text:hover {
+ text-decoration: underline;
+}
+
+#wot-scorecard-visit {
+ margin-bottom: 0px;
+ margin-top: 9px;
+}
+#wot-scorecard-comment-container {
+ display: block;
+ margin: 0;
+ width: 310px;
+}
+#wot-scorecard-comment {
+ display: block;
+ margin-bottom: 0px;
+ margin-top: 2px;
+ padding-left: 1px;
+}
+
+.categories-area {
+ position: absolute;
+ top: 76px;
+ left: 11px;
+ width: 520px;
+ height: 52px;
+}
+
+/* Categories view list */
+
+#tr-categories-list {
+ margin: 11px 0 0 0;
+ padding: 0;
+ min-height: 46px;
+ line-height: 9px;
+ column-count: 2;
+ -webkit-column-count: 2;
+}
+
+.cat-item {
+ font-size: 9pt;
+ color: silver;
+ list-style: none;
+ padding: 0.25em 0;
+ max-width: 250px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.cat-item .ico {
+ width: 1em;
+ height: 1em;
+ border: 1px solid #C0C0C0;
+ background-color: #C0C0C0;
+ border-radius: 50%;
+ content: "";
+ float: left;
+ margin: -2px 5px 0 0;
+}
+
+.cat-item .ico.c-neutral {
+ background-color: #707070;
+ background: -webkit-radial-gradient(center, ellipse cover, #9e9c9c 0%,#707070 100%); /* Chrome10+,Safari5.1+ */
+ border-color: #7d7d7d;
+}
+
+.cat-item .ico.c-questionable {
+ background-color: #ffd100;
+ background: -webkit-radial-gradient(center, ellipse cover, #f8df68 0%,#f6cd0e 100%); /* Chrome10+,Safari5.1+ */
+ border-color: #f6cd0e;
+}
+
+.cat-item .ico.c-negative {
+ background-color: #f66d3f;
+ background: -webkit-radial-gradient(center, ellipse cover, #fca080 0%,#f77448 100%); /* Chrome10+,Safari5.1+ */
+ border-color: #f66d3f;
+}
+
+.cat-item .ico.c-positive {
+ background-color: #68c800;
+ background: -webkit-radial-gradient(center, ellipse cover, #83d561 0%,#6dc14a 100%); /* Chrome10+,Safari5.1+ */
+ border-color: #6dc14a;
+}
+
+.c0 {
+ font-size: 11px !important;
+ color: #a7a7a7 !important;
+}
+
+.c0.cat-item .ico {
+ width: 4px !important;
+ height: 4px !important;
+ margin: 1px 8px 0 3px;
+}
+
+.c1 {
+ font-size: 12px;
+ color: #a7a7a7;
+}
+
+.c1.cat-item .ico {
+ width: 6px;
+ height: 6px;
+ margin: 0px 7px 0 2px;
+}
+
+.c2,
+.c3 {
+ font-size: 12px;
+ color: #646464;
+}
+
+.c2.cat-item .ico,
+.c3.cat-item .ico {
+ width: 8px;
+ height: 8px;
+ margin: -2px 6px 0 1px;
+}
+
+.c4,
+.c5 {
+ font-size: 12px;
+ color: #5c5c5c;
+ font-weight: bold;
+}
+
+.c4.cat-item .ico,
+.c5.cat-item .ico {
+ width: 10px;
+ height: 10px;
+ margin: -2px 5px 0 0;
+}
+
+.cat-cs-separator {
+ padding: 2px;
+ font-size: 0px;
+ list-style: none;
+ margin-top: 6px;
+}
+
+/*.cat-cs {*/
+ /*-webkit-transform: scale(0.9);*/
+ /*margin-left: -1.4em;*/
+/*}*/
+
+/* fix for scaled CS categories */
+/*.cat-cs.c1 {*/
+ /*margin-left: -1.65em;*/
+/*}*/
+
+/* Bottom area */
+
+/* user */
+.wot-user {
+ display: none;
+ width: 316px;
+}
+
+/* hidden by default, shown in some modes only */
+#user-communication {
+ display: none;
+}
+
+.user-comm-activity {
+ margin: 77px 25px 0;
+ position: relative;
+ display: none;
+}
+
+
+.unrated .user-comm-activity {
+ display: block;
+}
+
+.wot-user-header {
+ /* "your activity score" */
+ color: #8f8f8f;
+ display: inline;
+ font-size: 11px;
+ height: 14px;
+ line-height: 11px;
+ margin-right: 0px;
+}
+
+#user-activityscore {
+ color: #838383;
+ display: inline;
+ font-size: 11px;
+ margin-left: 1px;
+ font-weight: bold;
+}
+
+#user-activityscore:after {
+ font-weight: normal;
+ content: ".";
+}
+
+.wot-user-notice {
+ color: #8F8F8F;
+ font-size: 8pt;
+ display: inline;
+}
+
+.user-level {
+ font-weight: bold;
+}
+
+.wot-user-text {
+ /* Link to the user's profile */
+ color: #8f8f8f;
+ display: none;
+ font-size: 11px;
+ height: 23px;
+ line-height: 11px;
+}
+
+.wot-user-text[url^="http"]:hover {
+ color: #3073c5;
+ cursor: pointer;
+}
+.wot-user-text.accessible[url^="http"]:hover {
+ color: #333;
+ text-decoration: underline;
+}
+
+/* message */
+#wot-message {
+ display: none;
+ height: auto;
+ /*margin-bottom: 0.2em;*/
+ margin-top: 0.2em;
+ background-color: white;
+}
+
+#wot-message:before {
+ position: absolute;
+ height: 0px;
+ border-top: 1px solid #D9D9D9;
+ content: "";
+ width: 100%;
+ margin-top: 0px;
+ margin-left: -19px;
+}
+
+#wot-message-text {
+ color: #989898;
+ display: block;
+ font-size: 11px;
+ height: auto;
+ line-height: 13px;
+ overflow: hidden;
+ padding: 8px 20px 8px;
+ text-align: center;
+ white-space: normal;
+}
+#wot-message-text[url^="http"]:hover,
+#wot-message[status="important"] #wot-message-text[url^="http"]:hover,
+#wot-message[status="critical"] #wot-message-text[url^="http"]:hover {
+ color: #3073c5;
+ cursor: pointer;
+}
+#wot-message-text.accessible[url^="http"]:hover,
+#wot-message[status="important"] #wot-message-text.accessible[url^="http"]:hover,
+#wot-message[status="critical"] #wot-message-text.accessible[url^="http"]:hover {
+ color: #333;
+}
+#wot-message[status="important"] {
+ border-color: #ea8b2b;
+}
+#wot-message[status="critical"] {
+ border-color: #d81f27;
+}
+#wot-message[status="important"] #wot-message-text {
+ color: #ea8b2b;
+}
+#wot-message[status="critical"] #wot-message-text {
+ color: #d81f27;
+}
+/* partner */
+#wot-partner {
+ display: none;
+ height: 32px;
+ margin-bottom: 3px;
+ margin-left: 6px;
+ margin-right: 12px;
+ margin-top: 4px;
+ padding: 0;
+ text-align: left;
+ width: 298px;
+}
+/*#wot-partner[partner="name"] {
+ display: block;
+ background: url("partner/name.png") center right no-repeat;
+}*/
+#wot-partner-text {
+ color: #333;
+ display: block;
+ font-size: 11px;
+ height: 32px;
+ margin: 0;
+ padding-top: 7px;
+ width: 148px;
+}
+
+/* Hidden by default */
+#rate-buttons,
+#ok-button {
+ position: absolute;
+ bottom: 0.5em;
+ width: 529px;
+ height: 30px;
+ display: none;
+}
+
+.buttons-wrapper {
+ position: relative;
+}
+
+.right-side {
+ position: absolute;
+ right: 0;
+}
+
+.left-side {
+ position: absolute;
+ left: 8px;
+ margin-top: 0.2em;
+}
+
+.rw-button {
+ display: inline;
+ float: left;
+ border-style: solid;
+ border-width: 1px;
+ border-top-color: #DFDFDF;
+ border-right-color: #C2C2C2;
+ border-left-color: #D1CECE;
+ border-bottom-color: #AEAEAE;
+ padding: 0.3em 1.5em;
+ margin: 0.2em 0.5em;
+ border-radius: 2px;
+ font-size: 12px;
+ font-weight: bold;
+ color: #585858;
+ background-image: -webkit-linear-gradient(top, #FFF 0%, #e7e5e5 100%);
+ box-shadow: 1px 1px 5px #D2D2D2;
+ text-shadow: 1px 1px rgba(255,255,255,0.75);
+ cursor: pointer;
+}
+
+.rw-button:not(.disabled):active {
+ box-shadow: 1px 1px 1px #d2d2d2 inset;
+ text-shadow: 0px 0px #DDD;
+}
+
+.rw-button:not(.disabled):hover {
+ background-image: -webkit-linear-gradient(top, #FFF 0%,#dadada 83%, #f3f1f1 100%);
+ /*color: #6aac43;*/
+}
+
+.rw-button.disabled {
+ color: #A5A5A5;
+ text-shadow: none;
+ cursor: default;
+}
+
+#btn-delete {
+ margin-left: 0;
+ cursor: pointer;
+}
+
+.btn-delete_icon {
+ height: 18px;
+ width: 18px;
+ background: url("b/delete-myrating.png") top left no-repeat;
+ background-size: auto 18px;
+ float: left;
+ margin-right: 4px;
+}
+
+#btn-delete:hover .btn-delete_icon {
+ background-position: -19px 0;
+}
+
+.btn-delete_label {
+ font-size: 12px;
+ white-space: nowrap;
+ padding: 3px;
+ font-weight: bold;
+ color: #c33035;
+ display: none;
+}
+
+#btn-delete:hover .btn-delete_label {
+ display: block;
+}
+
+.btn-submit {
+ padding-left: 2em;
+ padding-right: 2em;
+ text-transform: capitalize;
+}
+
+.rw-buttons-expander {
+ display: inline;
+ float: left;
+ width: 38%;
+}
+
+
+/* Categorues selector style */
+
+#categories-selection-area {
+ display: none;
+ padding: 0 20px;
+ position: relative;
+ min-height: 200px;
+}
+
+.category-description {
+ display: none;
+ background-color: #e6f0f9;
+ height: 22px;
+ width: 500px;
+ margin-top: -1px;
+ font-size: 11px;
+ padding: 3px 5px 5px;
+ border-radius: 3px;
+ color: #5b5d5e;
+ line-height: 1.2em;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ border: 1px solid #D4E5FC;
+}
+
+.group-title {
+ font-size: 12px;
+ cursor: pointer;
+}
+
+.category-title,
+.comment-title {
+ font-size: 14px;
+ font-weight: bold;
+ margin-top: 5px;
+ height: 26px;
+ color: #454545;
+ /*margin-left: 10px;*/
+}
+
+.category-selector {
+ height: 210px; /* to occupy space and give other elements proper positioning */
+ position: absolute;
+ margin-top: -7px;
+}
+
+.category-selector .dropdown-menu {
+ min-height: 120px;
+ display: block;
+ float: left;
+ padding: 0;
+ list-style: none;
+ margin-top: 9px;
+}
+
+.category-selector li {
+ display: block;
+ margin: 1px 0;
+ padding: 11px 0 11px 16px;
+ width: 145px;
+ z-index: 1000;
+ list-style: none;
+ cursor: pointer;
+ border: 1px solid #ccc;
+ background: #ffffff; /* Old browsers */
+ background: -moz-linear-gradient(top, #ffffff 0%, #ebebeb 100%); /* FF3.6+ */
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ffffff), color-stop(100%, #ebebeb)); /* Chrome,Safari4+ */
+ background: -webkit-linear-gradient(top, #ffffff 0%, #ebebeb 100%); /* Chrome10+,Safari5.1+ */
+ background: -o-linear-gradient(top, #ffffff 0%, #ebebeb 100%); /* Opera 11.10+ */
+ background: linear-gradient(to bottom, #ffffff 0%, #ebebeb 100%); /* W3C */
+}
+
+.category-selector li .group-title {
+ display: block;
+ clear: both;
+ line-height: 10px;
+ color: #333333;
+ white-space: nowrap;
+ text-decoration: none;
+}
+
+.category-selector .popover {
+ position: absolute;
+ z-index: 990;
+ display: none;
+ min-height: 165px;
+ max-height: 190px;
+ width: 348px;
+ padding: 2px 0;
+ text-align: left;
+ white-space: normal;
+ background-color: #ffffff;
+ border: 1px solid #ccc;
+}
+
+.category-selector .category {
+ line-height: 13px;
+ font-weight: normal;
+ font-size: 12px;
+ padding: 3px 8px;
+ position: relative;
+ margin: 1px 4px;
+}
+
+.category-selector .shortlist .category {
+ line-height: 15px;
+}
+
+.category-selector .category:hover {
+ background: #ebebeb;
+ cursor: pointer;
+}
+
+.category-selector .category.invisible:not([voted]) {
+ /* voted and identified categories should be always visible in both short/full list modes */
+ display: none;
+}
+
+.category-selector .cat-name {
+}
+
+/* If category is identified by WOT */
+.category-selector .identified .cat-name {
+ font-weight: bold;
+ color: #747474;
+}
+
+.category-selector .cat-vote {
+ position: absolute;
+ right: 0;
+ top: 0;
+}
+
+.category-selector .cat-vote-left,
+.category-selector .cat-vote-right {
+ display: inline;
+ float: left;
+ margin: 2px 0px 0 0;
+ padding: 1px 5px 0;
+ border: 1px solid transparent;
+ text-transform: uppercase;
+ font-size: 10px;
+}
+
+.category-selector .cat-vote-left:after {
+ padding-left: 3px;
+ position: absolute;
+ color: silver;
+ content: "|";
+}
+
+/* when yes/no is hovered, hide the vertical pipe-separator */
+.category-selector .cat-vote:hover .cat-vote-left:after,
+.category-selector .category[voted] .cat-vote-left:after {
+ content: "";
+}
+
+.category-selector .cat-vote-left:hover,
+.category-selector .cat-vote-right:hover {
+ /*width: 23px;*/
+ /*height: 18px;*/
+ border: 1px solid #ccc;
+ background-color: white;
+ color: #319de7;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 4px;
+}
+
+.category-selector .category[voted="1"] .cat-vote-left,
+.category-selector .category[voted="-1"] .cat-vote-right {
+ border: 1px solid #c7ddef;
+ background: #eaf2fa;
+ -webkit-border-radius: 6px;
+ -moz-border-radius: 6px;
+ border-radius: 4px;
+}
+
+.category-selector .cat-vote-del {
+ display: inline;
+ float: left;
+ visibility: hidden;
+ height: 20px;
+}
+
+.category-selector .category[voted] .cat-vote-del {
+ visibility: visible;
+}
+
+.category-selector .delete-icon {
+ position: relative;
+ width: 12px;
+ height: 12px;
+ background-color: #f0efef;
+ margin: 3px 3px 0 3px;
+ cursor: pointer;
+ border: 1px solid #dadada;
+ border-radius: 50%;
+}
+
+/* Cross inside the "delete" icon */
+.category-selector .delete-icon:after,
+.category-selector .delete-icon:before {
+ content: "";
+ position: absolute;
+ top: 50%;
+ z-index: 10;
+ left: 5px;
+ width: 2px;
+ height: 10px;
+ margin-top: -5px;
+ background: #a5a5a5;
+}
+
+.category-selector .delete-icon:before {
+ -webkit-transform: rotate(45deg);
+}
+
+.category-selector .delete-icon:after {
+ -webkit-transform: rotate(135deg);
+}
+
+
+.category-selector .category-breakline {
+ height: 1px;
+ width: 100%;
+ background: #E1E0E0;
+ margin: 1px auto;
+}
+
+.category-selector li:first-of-type {
+ -webkit-border-radius: 6px 0 0 0;
+ border-radius: 6px 0 0 0;
+ background-clip: padding-box;
+}
+
+.category-selector li:last-of-type {
+ -webkit-border-radius: 0 0 0 6px;
+ border-radius: 0 0 0 6px;
+ -webkit-background-clip: padding-box;
+ background-clip: padding-box;
+}
+
+.category-selector .maintainHover {
+ color: #525252;
+ font-weight: bold;
+ background: #ffffff;
+}
+
+input[type=checkbox].css-checkbox {
+ display:none;
+}
+
+input[type=checkbox].css-checkbox + label.css-label {
+ padding-left:20px;
+ height:15px;
+ display:inline-block;
+ line-height:15px;
+ background-repeat:no-repeat;
+ background-position: 0 0;
+ font-size:13px;
+ vertical-align:middle;
+ cursor:pointer;
+}
+
+input[type=checkbox].css-checkbox:checked + label.css-label {
+ background-position: 0 -15px;
+}
+
+.css-label { background-image:url(b/checkbox.png); }
+
+.cat-full-list {
+ margin: 1em 0.5em;
+}
+
+.cat-full-list label {
+ color: #585858;
+}
+
+#chk-full-list {
+
+}
+
+/* The commenting feature */
+
+#commenting-area {
+ display: none; /* is shown from JS when needed */
+ margin: auto 19px;
+}
+
+.comment-title {
+ /* see the initial values at the beginning of this file */
+ padding: 3px 0 4px;
+}
+
+.user-comment-wrapper {
+ float: right;
+}
+
+#user-comment {
+ height: 115px;
+ width: 350px;
+ /*margin-right: 10px;*/
+ padding: 8px;
+ border: 1px solid #C0C0C0;
+ border-radius: 3px;
+ font-size: 13px;
+ font-family: Arial;
+ overflow-x: hidden;
+ overflow-y: auto;
+ outline-color: #DDF6FF;
+}
+
+#user-comment.warning {
+ width: 286px;
+}
+
+#user-comment[disabled] {
+ background-color: #F7F7F7;
+ color: #999;
+}
+
+#comment-side-hint {
+ padding: 10px 0 0 0;
+ float: left;
+ width: 130px;
+}
+
+#comment-side-hint p {
+ /* hints pieces */
+ margin: 0 0 8px;
+ font-size: 11px;
+ color: #666;
+}
+
+#comment-register,
+#comment-captcha {
+ display: none;
+ padding: 10px;
+ float: left;
+ width: 180px;
+ font-size: 12px;
+}
+
+#comment-register-text,
+#comment-captcha-text {
+ color: #e75159;
+ font-size: 12px;
+ font-weight: bold;
+ line-height: 1.5em;
+}
+
+#comment-register-link,
+#comment-captcha-link {
+ color: #3073c5;
+ font-size: 12px;
+ cursor: pointer;
+}
+
+#comment-register-link:hover,
+#comment-captcha-link:hover {
+ text-decoration: underline;
+}
+
+#comment-bottom-hint {
+ font-size: 14px;
+ text-align: right;
+ position: absolute;
+ bottom: 55px;
+ right: 50px;
+ background-color: #FC4B56;
+ padding: 3px 10px;
+ font-weight: normal;
+ border-radius: 8px;
+ color: #FFF;
+ display: none;
+}
+
+#comment-bottom-hint.error {
+ display: block;
+}
+
+#thanks-area {
+ display: none;
+}
+
+.thanks-text {
+ text-align: center;
+ font-size: 18px;
+ margin-top: 2em;
+}
+
+.thanks-activityscore {
+ text-align: center;
+ font-size: 13px;
+ margin-top: 1em;
+ color: #808080;
+}
+
+.thanks-activityscore-number {
+ font-weight: bold;
+ color: #808080;
+}
+
+.thanks-ratemore {
+ text-align: center;
+ font-size: 13px;
+ margin-top: 0.5em;
+ color: #808080;
+}
diff --git a/skin/wot.css b/skin/wot.css
index 14ffd95..2b26d27 100644
--- a/skin/wot.css
+++ b/skin/wot.css
@@ -398,6 +398,8 @@
padding: 0;
margin: 0;
font-family: Tahoma, Arial, sans-serif;
+ width: 580px;
+ height: 390px;
}
#wot-elements {
background: #ffffff;
--
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