diff options
-rw-r--r-- | lib/bzpage.js | 67 | ||||
-rw-r--r-- | lib/rhbzpage.js | 2 |
2 files changed, 31 insertions, 38 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js index 537a3f6..b8c38b8 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -415,9 +415,18 @@ BZPage.prototype.addToCommentsDropdown = function addToCommentsDropdown (pkg, cm * @param Boolean breakBefore if there should be a <br> element before. * @return none */ -BZPage.prototype.createDeadLink = function createDeadLink (id, text, parent, callback, params, breakBefore, accesskey) { +BZPage.prototype.createDeadLink = function createDeadLink (id, text, parent, callback, params, before, covered, accesskey) { var that = this; params = util.valToArray(params); + var locParent = {}; + + // Yes, I want != here, not !== + if (covered != null) { + locParent = this.doc.createElement(covered); + parent.appendChild(locParent); + } else { + locParent = parent; + } var newAElem = this.doc.createElement("a"); newAElem.setAttribute("id", id); @@ -433,10 +442,13 @@ BZPage.prototype.createDeadLink = function createDeadLink (id, text, parent, cal evt.preventDefault(); }, false); - if (breakBefore) { - parent.appendChild(this.doc.createElement("br")); + if ((before === "br") || (before === true)) { + locParent.appendChild(this.doc.createElement("br")); + } else if (before === "dash") { + locParent.appendChild(this.doc.createTextNode("\u00A0-\u00A0")); } - parent.appendChild(newAElem); + + locParent.appendChild(newAElem); }; @@ -935,44 +947,25 @@ BZPage.prototype.setUpLogging = function setUpLogging () { this.submitHandlerInstalled = true; } - var generateTimeSheetUI = this.doc.createElement("li"); - generateTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='' id='generateTSButton'>" - + "Generate TS</a>"; - additionalButtons.appendChild(generateTimeSheetUI); - this.doc.getElementById("generateTSButton").addEventListener( - "click", - function(evt) { + // (id, text, parent, callback, params, before, covered, accesskey) + this.createDeadLink("generateTSButton", "Generate TS", additionalButtons, + function(evt) { that.log.createBlankPage.call(that.log, "TimeSheet", that.log.generateTimeSheet); - evt.stopPropagation(); - evt.preventDefault(); - }, false); + }, [], "dash", "li"); - var clearLogsUI = this.doc.createElement("li"); - clearLogsUI.innerHTML = "\u00A0-\u00A0<a href='' id='clearLogs'>" - + "Clear TS</a>"; - additionalButtons.appendChild(clearLogsUI); - var clearLogAElem = this.doc.getElementById("clearLogs"); - clearLogAElem.addEventListener("click", function(evt) { - that.log.clearStore(this); - console.log("this.store wiped out!"); - evt.stopPropagation(); - evt.preventDefault(); - }, false); + this.createDeadLink("clearLogs", "Clear TS", additionalButtons, + function(evt) { + that.log.clearStore(this); + }, [], "dash", "li"); - var ImportTimeSheetUI = this.doc.createElement("li"); - ImportTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='' id='importTSButton'>" - + "Import TS</a>"; - additionalButtons.appendChild(ImportTimeSheetUI); - this.doc.getElementById("importTSButton").addEventListener( - "click", - function(evt) { - jsonPaths = prompts.promptFileOpenPicker(that.win); - that.log.importOtherStore(jsonPaths, clearLogAElem); - evt.stopPropagation(); - evt.preventDefault(); - }, false); + this.createDeadLink("importTSButton", "Import TS", additionalButtons, + function(evt) { + jsonPaths = prompts.promptFileOpenPicker(that.win); + that.log.importOtherStore(jsonPaths, clearLogAElem); + }, [], "dash", "li"); + var clearLogAElem = this.doc.getElementById("clearLogs"); if (this.log.isEmpty()) { clearLogAElem.style.color = this.log.EmptyLogsColor; clearLogAElem.style.fontWeight = "normal"; diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index d63257b..20dac39 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -464,7 +464,7 @@ RHBugzillaPage.prototype.markBadAttachments = function() { Array.forEach(badAttachments, function(x) { this.fixAttachById(x[1]); }, that); - }, [], false, "f"); + }, [], false, null, "f"); badAttachments.forEach(function(x, i, a) { this.addTextLink(x); }, this); |