[Pkg-mozext-commits] [wot] 96/226: "close" icon now alive, preferences are saved from RW.
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 0f2190c2bea5fe3d18e889bef7a9b69b49083497
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Fri Aug 2 17:04:14 2013 +0300
"close" icon now alive, preferences are saved from RW.
---
content/prefs.js | 20 +++++++++++++++
content/ratingwindow.js | 66 +++++++++++--------------------------------------
content/rw/proxies.js | 5 ++++
3 files changed, 40 insertions(+), 51 deletions(-)
diff --git a/content/prefs.js b/content/prefs.js
index c2ada5e..d6322ec 100644
--- a/content/prefs.js
+++ b/content/prefs.js
@@ -233,6 +233,26 @@ var wot_prefs =
}
},
+ setSmart: function (name, value) {
+ // Looks up through preferences names and call the proper function to set the value of the named preference
+ var prefs_sets = [
+ [wot_prefs_char, wot_prefs.setChar],
+ [wot_prefs_int, wot_prefs.setInt ],
+ [wot_prefs_bool, wot_prefs.setBool]
+ ];
+
+ for (var s = 0; s < prefs_sets.length; s++) {
+ var pset = prefs_sets[s][0];
+ for (var i = 0; i < pset.length; ++i) {
+ if (pset[i][0] === name) {
+ var func = prefs_sets[s][1];
+ func.call(wot_prefs, name, value);
+ return;
+ }
+ }
+ }
+ },
+
sync: function()
{
try {
diff --git a/content/ratingwindow.js b/content/ratingwindow.js
index a107d8c..d235b25 100644
--- a/content/ratingwindow.js
+++ b/content/ratingwindow.js
@@ -25,6 +25,7 @@ var wot_rw = {
is_inited: false,
CHAN_ELEM_ID: "wot-comm-channel",
CHAN_EVENT_ID: "wotrw",
+ IGNORED_PREFS: ["ratingwindow_shown"],
get_rw_window: function () {
var rw_frame = document.getElementById(this.FRAME_ID);
@@ -87,6 +88,9 @@ var wot_rw = {
} else {
wot_rw.update(); // RW is already loaded so we need to just update it
}
+
+ // We ignore attempts of RW to increase the counter. Instead, we increase it here.
+ wot_prefs.setInt("ratingwindow_shown", wot_prefs.ratingwindow_shown + 1);
},
update_messages: function () {
@@ -116,55 +120,6 @@ var wot_rw = {
}
},
- update_user_info: function () {
-
-// wot_api_query.users[0]
-// .bar - header
-// .label - activity score?
-// .length
-// .url
-// .notice
-// .text
-//
-
-// if (wot_api_query.users[i].bar &&
-// wot_api_query.users[i].length != null &&
-// wot_api_query.users[i].label) {
-// header.value = wot_api_query.users[i].bar;
-// label.value = wot_api_query.users[i].label;
-// bar.setAttribute("length", wot_api_query.users[i].length);
-// bar.hidden = false;
-// } else {
-// header.value = "";
-// label.value = "";
-// bar.hidden = true;
-// }
-//
-// if (wot_api_query.users[i].url) {
-// content.setAttribute("url", wot_api_query.users[i].url);
-// } else {
-// content.removeAttribute("url");
-// }
-//
-// if (wot_api_query.users[i].notice) {
-// notice.value = wot_api_query.users[i].notice;
-// notice.hidden = false;
-// } else {
-// notice.hidden = true;
-// }
-//
-// if (wot_api_query.users[i].text) {
-// text.value = wot_api_query.users[i].text;
-// user.hidden = false;
-// ++j;
-// } else {
-// text.value = "";
-// user.hidden = true;
-// }
-// }
- wdump(JSON.stringify(wot_api_query.users[0]));
- },
-
update: function () {
// Updates content of Rating Window. RW must be already initialized (locales, categories info, etc).
wdump("RW.update()");
@@ -228,7 +183,6 @@ var wot_rw = {
wot_rw.push_preferences(rw, wot_rw.get_preferences()); // update preferences every time before showing RW
wot_rw.update_messages();
- wot_rw.update_user_info();
// set the user's activity score additionally to bg.wot.core.
// FIXME: use activity score provided by preferences in RW instead of direct manupulation of core.usercontent[]
@@ -249,7 +203,7 @@ var wot_rw = {
prefs = {
accessible: wot_prefs.accessible,
show_fulllist: wot_prefs.show_fulllist,
- ratingwindow_shown: wot_prefs.ratingwindow_shown,
+ ratingwindow_shown: wot_prefs.ratingwindow_shown, // this has special processing
activity_score: wot_prefs.activity_score
};
@@ -304,6 +258,16 @@ var wot_rw = {
wot_browser.open_wotsite(data.url, "", "", data.context, true, true);
wot_rw.hide_ratingwindow();
break;
+
+ case "prefs:set":
+ if (data.key && wot_rw.IGNORED_PREFS.indexOf(data.key) < 0) { // ignore special prefs
+ wot_prefs.setSmart(data.key, data.value); // not good to assume Char type here, so be careful
+ }
+ break;
+
+ case "close":
+ wot_rw.hide_ratingwindow();
+ break;
}
return true;
diff --git a/content/rw/proxies.js b/content/rw/proxies.js
index 35396e3..53c2019 100644
--- a/content/rw/proxies.js
+++ b/content/rw/proxies.js
@@ -155,6 +155,11 @@ var wot_bg = { // background page object
};
+// IN order to allow RatingWindow to close itself we redefine the global method (what a nasty life!).
+window.close = function() {
+ wot_bg.wot.core.moz_send("close", null);
+};
+
var chrome = {
extension: {
getBackgroundPage: function () {
--
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