aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-07-23 21:33:08 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-07-23 21:33:25 +0200
commit9b3f22fd07c0cfcc1e2368c7f32a0423a3a4bd85 (patch)
tree7d02fcf6347fe51e06508080f7151c37e6dbd0d1
parent64213233a16a49bda77f5bb9384c90c7d76f7d2f (diff)
downloadbugzilla-triage-9b3f22fd07c0cfcc1e2368c7f32a0423a3a4bd85.tar.gz
More resistance to differences with bugzilla.mozilla.org
Fixes #30
-rw-r--r--lib/bzpage.js29
-rw-r--r--lib/rhbzpage.js13
2 files changed, 28 insertions, 14 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index ff84aa9..084b924 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -477,6 +477,22 @@ BZPage.prototype.setConfigurationButton = function setConfigurationButton () {
}, false);
};
+/*
+ * From <a href="mailto:email"> element diggs out just plain email
+ * address
+ *
+ * @param aElement Element with href attribute or something else
+ * @return String with the address or null
+ *
+ */
+BZPage.prototype.parseMailto = function parseMailto(aElement) {
+ if (aElement) {
+ var email = decodeURI(aElement.getAttribute("href")).
+ split(":")[1];
+ }
+ return null;
+};
+
/**
* Get the current email of the reporter of the bug.
*
@@ -485,10 +501,7 @@ BZPage.prototype.setConfigurationButton = function setConfigurationButton () {
BZPage.prototype.getReporter = function getReporter () {
var reporterElement = this.doc.
querySelector("#bz_show_bug_column_2 > table .vcard:first-of-type > a");
- if (reporterElement) {
- return reporterElement.textContent;
- }
- return "";
+ return this.parseMailto(reporterElement);
};
/**
@@ -523,8 +536,8 @@ BZPage.prototype.commentsWalker = function commentsWalker (fce) {
BZPage.prototype.checkComments = function checkComments () {
var that = this;
this.commentsWalker(function(x) {
- var email = x.getElementsByClassName("vcard")[0]
- .getElementsByTagName("a")[0].textContent;
+ var email = that.parseMailto(x.getElementsByClassName("vcard")[0]
+ .getElementsByTagName("a")[0]);
if (new RegExp(that.reporter).test(email)) {
x.style.backgroundColor = that.ReporterColor.toString();
}
@@ -667,9 +680,7 @@ BZPage.prototype.getOwner = function getOwner () {
var priorityParent = this.doc.querySelector("label[for~='target_milestone']")
.parentNode.parentNode.parentNode;
var assigneeAElement = priorityParent.querySelector("tr:nth-of-type(1) a.email");
- var assgineeHref = decodeURI(assigneeAElement.getAttribute("href"));
- var email = assgineeHref.split(":")[1];
- return email;
+ return this.parseMailto(assigneeAElement);
};
/**
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js
index 78c4f7d..61c9fc7 100644
--- a/lib/rhbzpage.js
+++ b/lib/rhbzpage.js
@@ -141,11 +141,14 @@ var RHBugzillaPage = function RHBugzillaPage(win, config) {
this.checkComments();
// set default assignee on change of the component
- this.doc.getElementById("component").addEventListener("change",
- function() {
- that.component = that.getOptionValue("component");
- that.changeAssignee("default");
- }, false);
+ var compElement = this.doc.getElementById("component");
+ if (compElement && (compElement.options)) {
+ this.doc.getElementById("component").addEventListener("change",
+ function() {
+ that.component = that.getOptionValue("component");
+ that.changeAssignee("default");
+ }, false);
+ }
}; // END OF RHBugzillaPage CONSTRUCTOR