[Pkg-mozext-commits] [wot] 39/226: fixed #2 Distinguish a context when opening mywot.com pages from an addon
David Prévot
taffit at moszumanska.debian.org
Fri May 1 00:35:32 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 c73ee1f1f61ffd35dfbcb968f904a89074640cb2
Author: Sergey Andryukhin <sorgoz at yandex.com>
Date: Fri Sep 7 16:21:08 2012 +0300
fixed #2 Distinguish a context when opening mywot.com pages from an addon
---
content/commands.js | 15 ++++++++-------
content/config.js | 15 +++++++++++++++
content/popup.js | 2 +-
content/search.js | 2 +-
content/util.js | 17 +++++++++++------
content/warning.js | 4 ++--
6 files changed, 38 insertions(+), 17 deletions(-)
diff --git a/content/commands.js b/content/commands.js
index 42b71f4..26e794c 100644
--- a/content/commands.js
+++ b/content/commands.js
@@ -196,7 +196,7 @@ var wot_commands =
my: function()
{
try {
- var url = wot_url.getwoturl("", "menu");
+ var url = wot_url.getwoturl("", WOT_URL_MENUMY);
if (url) {
getBrowser().loadURI(url);
}
@@ -224,7 +224,7 @@ var wot_commands =
{
try {
wot_browser.openscorecard(wot_commands.getcontexthostname(),
- null, "context");
+ null, WOT_URL_CTX);
} catch (e) {
}
}
@@ -339,7 +339,7 @@ var wot_events =
try {
/* Middle-click takes to scorecard */
if (event.button == 1 && wot_core.hostname) {
- wot_browser.openscorecard(wot_core.hostname, null, "button");
+ wot_browser.openscorecard(wot_core.hostname, null, WOT_URL_BTN);
}
} catch (e) {
dump("wot_events.click_button: failed with " + e + "\n");
@@ -431,7 +431,7 @@ var wot_events =
if (wot_core.hostname &&
wot_browser.openscorecard(wot_core.hostname,
- action, "window")) {
+ action, WOT_URL_RWVIEWSC)) {
this.popup_hide();
}
} catch (e) {
@@ -444,7 +444,7 @@ var wot_events =
{
try {
var browser = getBrowser();
- var url = wot_url.getwoturl("", "window");
+ var url = wot_url.getwoturl("", WOT_URL_RWLOGO);
if (browser && url) {
browser.selectedTab = browser.addTab(url);
@@ -461,8 +461,9 @@ var wot_events =
try {
var browser = getBrowser();
if (browser) {
+ var url = wot_url.getprefurl("guide", false, null, WOT_URL_RWGUIDE); // getprefurl() already considers context
browser.selectedTab =
- browser.addTab(wot_url.getprefurl("guide"));
+ browser.addTab(url);
this.popup_hide();
}
} catch (e) {
@@ -476,7 +477,7 @@ var wot_events =
try {
var browser = getBrowser();
if (browser) {
- browser.selectedTab = browser.addTab(wot_url.getprefurl());
+ browser.selectedTab = browser.addTab(wot_url.getprefurl(null, null, null, WOT_URL_RWSETTINGS));
this.popup_hide();
}
} catch (e) {
diff --git a/content/config.js b/content/config.js
index 8611531..dfad294 100644
--- a/content/config.js
+++ b/content/config.js
@@ -297,4 +297,19 @@ const WOT_SEARCH_TARGET = "target";
const WOT_SEARCH_POPUP = "popup";
const WOT_SEARCH_NINJA = "ninja";
+/* contexts for opening WOT links */
+const WOT_URL_RWLOGO = "rw-logo";
+const WOT_URL_RWSETTINGS = "rw-settings";
+const WOT_URL_RWGUIDE = "rw-guide";
+const WOT_URL_RWVIEWSC = "rw-viewsc";
+const WOT_URL_RWPROFILE = "rw-profile";
+const WOT_URL_RWMSG = "rw-msg"; // unused
+const WOT_URL_WARNVIEWSC = "warn-viewsc";
+const WOT_URL_WARNRATE = "warn-rate";
+const WOT_URL_POPUPVIEWSC = "popup";
+const WOT_URL_POPUPDONUTS = "popup-donuts";
+const WOT_URL_MENUMY = "menu-my";
+const WOT_URL_BTN = "button";
+const WOT_URL_CTX = "contextmenu";
+
var wot_modules = [];
diff --git a/content/popup.js b/content/popup.js
index 1de3fae..074da6d 100644
--- a/content/popup.js
+++ b/content/popup.js
@@ -144,7 +144,7 @@ var wot_popup =
layer.addEventListener("click", function() {
wot_browser.openscorecard(layer.getAttribute("target"),
- null, "popup");
+ null, WOT_URL_POPUPVIEWSC);
}, false);
elem.appendChild(layer);
diff --git a/content/search.js b/content/search.js
index bad84d8..6ae5d4d 100644
--- a/content/search.js
+++ b/content/search.js
@@ -1257,7 +1257,7 @@ var wot_search =
try {
var target = event.originalTarget.getAttribute(wot_search.attribute);
if (target) {
- wot_browser.openscorecard(target, null, "search");
+ wot_browser.openscorecard(target, null, WOT_URL_POPUPDONUTS);
event.stopPropagation();
}
} catch (e) {
diff --git a/content/util.js b/content/util.js
index 2869176..5b80007 100644
--- a/content/util.js
+++ b/content/util.js
@@ -185,8 +185,10 @@ var wot_url =
getwoturl: function(path, context)
{
try {
- /* We'll ignore context for now */
- return WOT_MY_URL + path;
+ var new_path = path;
+ new_path += ( (path.indexOf("?") > 0) ? "&" : "?" );
+ new_path += "utm_source=addon" + (context ? "&utm_content=" + context : "");
+ return WOT_MY_URL + new_path;
} catch (e) {
dump("wot_url.getwoturl: failed with " + e + "\n");
}
@@ -194,7 +196,7 @@ var wot_url =
return null;
},
- getprefurl: function(tab, secure, base)
+ getprefurl: function(tab, secure, base, context)
{
try {
base = base || WOT_PREF_PATH;
@@ -202,17 +204,20 @@ var wot_url =
var path = base + wot_util.getstring("language") +
"/" + WOT_PLATFORM + "/" + WOT_VERSION;
- var url = this.getwoturl(path);
+ var url = path;
if (url) {
if (tab) {
url += "/" + tab;
}
+ url = this.getwoturl(url, context);
+
if (secure || wot_core.force_https) {
url = url.replace(/^http\:/, "https:");
}
+
return url;
}
} catch (e) {
@@ -387,7 +392,7 @@ var wot_browser =
}
},
- openscorecard: function(hostname, action, content)
+ openscorecard: function(hostname, action, context)
{
try {
if (!hostname) {
@@ -401,7 +406,7 @@ var wot_browser =
}
var browser = getBrowser();
- var url = wot_url.getwoturl(path, content);
+ var url = wot_url.getwoturl(path, context);
if (browser && url) {
browser.selectedTab = browser.addTab(url);
diff --git a/content/warning.js b/content/warning.js
index f863afc..c1eb7fd 100644
--- a/content/warning.js
+++ b/content/warning.js
@@ -608,11 +608,11 @@ var wot_warning =
break;
case "wotinfobutton":
- wot_browser.openscorecard(wot_core.hostname, null, "warning");
+ wot_browser.openscorecard(wot_core.hostname, null, WOT_URL_WARNVIEWSC);
break;
case "wotrate-link":
- wot_browser.openscorecard(wot_core.hostname, WOT_SCORECARD_RATE, "warning");
+ wot_browser.openscorecard(wot_core.hostname, WOT_SCORECARD_RATE, WOT_URL_WARNRATE);
break;
case "wot-btn-leave":
--
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