From 50c6825e5d1aecca1edc75b305e28fce86e12b36 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 19 Apr 2011 00:19:53 +0200 Subject: Working on analysis of bug-page-mod module. * Add some notes * remove getBugNumber and replaced with my getBugNo. --- data/lib/bug-page-mod.js | 19 +++++++------------ data/lib/util.js | 8 ++++++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/data/lib/bug-page-mod.js b/data/lib/bug-page-mod.js index 8972ee6..a8ce6de 100644 --- a/data/lib/bug-page-mod.js +++ b/data/lib/bug-page-mod.js @@ -46,8 +46,8 @@ function tweakBugzilla(d) { if (!d.getElementById("comments")) // don't process the mid-air collision pages return; - // Make the comment box bigger - var commentBox = d.querySelector("#comment"); + // Make the comment box bigger ... TODO not necessary on RH BZ, but doesn't hurt + var commentBox = d.getElementById("comment"); if (commentBox) commentBox.rows=20; @@ -58,6 +58,8 @@ function tweakBugzilla(d) { viewAttachmentSource(d); // Mark up history along right hand edge + // TODO ... not sure what does this mean ... this + // element is I suppose everywhere. var historyLink = d.querySelector("link[title='Bug Activity']"); if (!historyLink) return; @@ -479,7 +481,7 @@ var reviewBoardUrlBase = "http://reviews.visophyte.org/"; * review board magic. */ function attachmentDiffLinkify(doc) { - var bug_id = getBugNumber(doc); + var bug_id = getBugNo(doc); var table = doc.getElementById("attachment_table"); if (!table) @@ -696,7 +698,7 @@ function CheckinCommentCtor() { } CheckinCommentCtor.prototype = { initialize: function(doc, flags) { - this.bugNumber = getBugNumber(doc); + this.bugNumber = getBugNo(doc); var summarySpan = doc.getElementById("short_desc_nonedit_display"); if (summarySpan) { this.summary = summarySpan.textContent; @@ -819,7 +821,7 @@ function DataStoreCtor(doc) { DataStoreCtor.prototype = { initialize: function(doc) { - this.bugNumber = getBugNumber(doc); + this.bugNumber = getBugNo(doc); var data = this._ensureEntry(this.bugNumber, this.data); // last visited date data.visitedTime = (new Date()).getTime(); @@ -917,13 +919,6 @@ DataStoreCtor.prototype = { _reAttachmentHref: /attachment\.cgi\?id=(\d+)$/i }; -function getBugNumber(doc) { - var idField = doc.querySelector("form[name=changeform] input[name=id]"); - if (idField) { - return idField.value; - } - return null; -} function getUserName(doc) { var links = doc.querySelectorAll("#header .links li"); diff --git a/data/lib/util.js b/data/lib/util.js index 6256171..40a782f 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -64,8 +64,12 @@ function parseXMLfromString (inStuff) { * Get a bug no */ function getBugNo() { - console.log("bugNo = " + document.forms.namedItem('changeform').getElementsByName("id")[0].value); - return document.forms.namedItem('changeform').getElementsByName("id")[0].value; + var bugNoElem = document.forms.namedItem('changeform').getElementsByName("id")[0]; + if (bugNoElem) { + return bugNoElem.value; + } else { + return null; + } } /** -- cgit