From ea31bb39676ac5667dd6f481408280201675fcc3 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Sun, 8 Aug 2010 00:07:48 -0400 Subject: More compatibility with bugzilla.gnome.org --- lib/bzpage.js | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'lib/bzpage.js') diff --git a/lib/bzpage.js b/lib/bzpage.js index 1731b64..8b96c9c 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -686,6 +686,23 @@ BZPage.prototype.hasKeyword = function hasKeyword (str) { return (this.idContainsWord('keywords', 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; +}; + /** * */ @@ -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; } }; -- cgit