aboutsummaryrefslogtreecommitdiffstats
path: root/data/js
diff options
context:
space:
mode:
Diffstat (limited to 'data/js')
-rw-r--r--data/js/bug-page-mod.js52
-rw-r--r--data/js/cc-context.js8
-rw-r--r--data/js/checkin-context.js11
-rw-r--r--data/js/urltest.js3
4 files changed, 26 insertions, 48 deletions
diff --git a/data/js/bug-page-mod.js b/data/js/bug-page-mod.js
index 540ae2f..1e4341a 100644
--- a/data/js/bug-page-mod.js
+++ b/data/js/bug-page-mod.js
@@ -35,56 +35,9 @@
*
* ***** END LICENSE BLOCK ***** */
-exports.main = function(options, callback) {
- require("tab-browser").whenContentLoaded(
- function(window) {
- if (onBugzillaPage(window)) {
- tweakBugzilla(window.document);
- }
- }
- );
-
- // Allow toggling of CC event displays using a context menu entry
- var contextMenu = require("context-menu");
- var ccMenuItem = contextMenu.Item({
- label: "Toggle CC History",
- context: function(context) onBugzillaPage(context.window),
- onClick: function(context) {
- var style = context.document.getElementById("bztw_cc");
- style.disabled = !style.disabled;
- }
- });
- contextMenu.add(ccMenuItem);
-
- var copyCheckinCommentItem = contextMenu.Item({
- label: "Copy Check-in Comment",
- context: function(context) {
- if (!onBugzillaPage(context.window))
- return false;
- var d = context.document;
- var message = d.getElementById("__bz_tw_checkin_comment");
- return !!message;
- },
- onClick: function(context) {
- var d = context.document;
- var message = d.getElementById("__bz_tw_checkin_comment");
- require("clipboard").set(message.textContent);
- }
- });
- contextMenu.add(copyCheckinCommentItem);
-};
-
-function onBugzillaPage(window) {
- if ("window" in window) {
- window = window.window;
- }
- return window.location.protocol == "https:" &&
- /bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(window.location.href);
-}
-
function tweakBugzilla(d) {
// run on both bugzilla.m.o and bugzilla-stage-tip.m.o
- if (!/bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(d.location.href))
+ if (!onBugzillaPage(d.URL))
return;
// Put the quicksearch text in the quicksearch boxes
@@ -524,6 +477,7 @@ AttachmentFlag.prototype = {
var reAttachmentDiff = /attachment\.cgi\?id=(\d+)&action=diff$/i;
var reviewBoardUrlBase = "http://reviews.visophyte.org/";
+
/**
* Whenever we find a patch with a diff, insert an additional link to asuth's
* review board magic.
@@ -1146,3 +1100,5 @@ function tbplbotSpamCollapser(d) {
li.appendChild(a);
collapseExpandBox.appendChild(li);
}
+
+tweakBugzilla(document);
diff --git a/data/js/cc-context.js b/data/js/cc-context.js
new file mode 100644
index 0000000..38397a9
--- /dev/null
+++ b/data/js/cc-context.js
@@ -0,0 +1,8 @@
+on('click', function(node, data) {
+ var style = document.getElementById("bztw_cc");
+ style.disabled = !style.disabled;
+});
+
+on('context', function(node) {
+ return onBugzillaPage(document.URL);
+});
diff --git a/data/js/checkin-context.js b/data/js/checkin-context.js
new file mode 100644
index 0000000..4d073be
--- /dev/null
+++ b/data/js/checkin-context.js
@@ -0,0 +1,11 @@
+on('click', function(node, data) {
+ var message = document.getElementById("__bz_tw_checkin_comment");
+ postMessage(message.textContent);
+});
+
+on('context', function(node) {
+ if (!onBugzillaPage(document.URL))
+ return false;
+ var message = document.getElementById("__bz_tw_checkin_comment");
+ return !!message;
+});
diff --git a/data/js/urltest.js b/data/js/urltest.js
new file mode 100644
index 0000000..f6a379a
--- /dev/null
+++ b/data/js/urltest.js
@@ -0,0 +1,3 @@
+function onBugzillaPage(url) {
+ return /https:\/\/bugzilla(-[a-zA-Z]+)*\.mozilla\.org/.test(url);
+} \ No newline at end of file