aboutsummaryrefslogtreecommitdiffstats
path: root/lib/main.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-21 17:44:25 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-21 17:44:25 +0200
commitb5da15622a8ee84cac5c8489c72610bd24b09c29 (patch)
treeea39f899db898780e05b5d2fe7f4cc55e09ba754 /lib/main.js
parenta0756d1dbd9e8bbb37293b8b756f6aee1e205d65 (diff)
downloadbugzilla-triage-b5da15622a8ee84cac5c8489c72610bd24b09c29.tar.gz
Skipping over process pages && system notification.
Diffstat (limited to 'lib/main.js')
-rw-r--r--lib/main.js56
1 files changed, 39 insertions, 17 deletions
diff --git a/lib/main.js b/lib/main.js
index 867c3d5..7c72599 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -15,6 +15,7 @@ var util = require("util");
var logger = require("logger");
var myStorage = require("simple-storage").storage;
var browser = require("tab-browser");
+var urlMod = require("url");
var JSONURL = "http://matej.ceplovi.cz/progs/data/RH_Data-packages.json";
var TriagedDistro = 13;
@@ -27,6 +28,12 @@ config.matches = [
"https://bugzilla.mozilla.org/show_bug.cgi"
];
+config.skipMatches = [
+ "https://bugzilla.redhat.com/process_bug.cgi",
+ "https://bugzilla.redhat.com/post_bug.cgi",
+ "https://bugzilla.mozilla.org/post_bug.cgi",
+ "https://bugzilla.mozilla.org/process_bug.cgi"
+];
// ==============================================================
// https://wiki.mozilla.org/Labs/Jetpack/JEP/24
@@ -52,16 +59,7 @@ var WillBemanifest = {
]
};
-// TODO: sometime in the future we should include
-// also skip-process.js functionality and these URLs
-// "https://bugzilla.redhat.com/process_bug.cgi",
-// "https://bugzilla.redhat.com/post_bug.cgi",
-// "https://bugzilla.mozilla.org/post_bug.cgi",
-// "https://bugzilla.mozilla.org/process_bug.cgi"
function isOurPage(window, matchingURLs) {
- if ("window" in window) {
- window = window.window;
- }
var url = window.location.href;
// like ["regexp-url1", "regexp-url2"]
@@ -70,6 +68,25 @@ function isOurPage(window, matchingURLs) {
});
}
+/**
+ *
+ */
+function skipThisPage(doc) {
+ var stemURL = "https://HOSTNAME/show_bug.cgi?id=";
+ var titleStr = doc.getElementsByTagName("title")[0].textContent;
+ var REArr = new RegExp("[0-9]+").exec(titleStr);
+ var hostname = urlMod.URL(doc.location.href).host;
+ if (REArr) {
+ var bugNo = REArr[0];
+ console.log("bugNo = " + bugNo + ", hostname = " + hostname);
+ var emailsSent = doc.
+ querySelector("#bugzilla-body > dl:nth-of-type(1)").textContent;
+ emailsSent = emailsSent.replace(/^(\s*)$/mg,"");
+ util.notification(emailsSent);
+ doc.location = stemURL.replace("HOSTNAME",hostname) + bugNo;
+ }
+}
+
function initialize(callback) {
util.loadJSON(JSONURL, function(parsedData) {
config.gJSONData = parsedData;
@@ -103,14 +120,19 @@ function initialize(callback) {
exports.main = function main(options, callbacks) {
initialize(function (config) {
browser.whenContentLoaded(
- function(window) {
- var doc = window.document;
- var construct = require("rhbzpage").RHBugzillaPage;
- if (isOurPage(window, config.matches)) {
- var curPage = new construct(doc, config);
- } else {
- console.log("Not our page: " + window.location.href);
+ function(window) {
+ // is this good for anything?
+ if ("window" in window) { window = window.window; }
+ var doc = window.document;
+ var construct = require("rhbzpage").RHBugzillaPage;
+ if (isOurPage(window, config.matches)) {
+ var curPage = new construct(doc, config);
+ } else if (isOurPage(window, config.skipMatches)) {
+ skipThisPage(doc);
+ } else {
+ console.log("Not our page: " + window.location.href);
+ }
}
- });
+ );
});
};