diff options
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r-- | lib/bzpage.js | 29 |
1 files changed, 20 insertions, 9 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); }; /** |