diff options
-rw-r--r-- | lib/bzpage.js | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js index 1731b64..8b96c9c 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -687,6 +687,23 @@ BZPage.prototype.hasKeyword = function hasKeyword (str) { }; /** + */ +BZPage.prototype.getOptionTableCell = function getOptionTableCell(tableId, label) { + var cleanLabelRE = /^\s*([^. :]*):?\s*$/; + label = label.replace(cleanLabelRE,"$1").toLowerCase(); + var rows = this.doc.getElementById(tableId).getElementsByTagName("tr"); + var ourLine = Array.filter(rows, function(row) { + var curLabel = row.getElementsByTagName("td")[0].textContent.toLowerCase(); + curLabel = curLabel.replace(cleanLabelRE,"$1"); + return (curLabel === label); + }); + if (ourLine.length > 0) { + return ourLine[0].getElementsByTagName("td")[1].textContent; + } + return null; +}; + +/** * */ BZPage.prototype.getOptionValue = function getOptionValue (id) { @@ -695,8 +712,13 @@ BZPage.prototype.getOptionValue = function getOptionValue (id) { if (element) { return element.value; } else { - console.error("Failed to find element with id = " + id); - return "#NA"; + // this doesn't work on bugzilla.gnome.org + element = this.getOptionTableCell("bug_summary", id); + if (element) { + return element; + } + throw new Error("Failed to find element with id = " + id); + return null; } }; |