From 130db374f29f442f067aa5b23843a55b6b173877 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Tue, 15 Dec 2009 12:42:21 +0100 Subject: Eliminate string "Bug " where it is not 100% necessary (to make better tab titles) and some light dejQuerization. --- bugzillaBugTriage.js | 96 +++++++++++++++++++++++++--------------------------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js index 68da4d2..3a507a7 100644 --- a/bugzillaBugTriage.js +++ b/bugzillaBugTriage.js @@ -440,7 +440,7 @@ bzPage.prototype.clickMouse = function(target) { localEvent.initMouseEvent("click", true, true, this.doc.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null); - $(target).get(0).dispatchEvent(localEvent); + target.dispatchEvent(localEvent); }; /** @@ -452,12 +452,7 @@ bzPage.prototype.clickMouse = function(target) { * Checks for the existing keywords. */ bzPage.prototype.addKeyword = function (str) { - var kwd = $('#keywords',this.doc); - if (kwd.text().length === 0) { - kwd.text(str); - }else{ - kwd.text(kwd.text() + ", " + str); - } + this.addTextToTextBox("keywords",str); }; /* Bugzilla functions.*/ @@ -490,7 +485,7 @@ bzPage.prototype.isTriaged = function() { if (this.version > 11) { return this.hasKeyword("Triaged"); } else { - return $("#bug_status", this.doc).val().toUpperCase() !== "NEW"; + return this.getElementById("bug_status").value.toUpperCase() !== "NEW"; } }; @@ -522,43 +517,44 @@ bzPage.prototype.setBranding = function () { } // Comment each of the following lines to get only partial branding - $("body", this.doc).css("background", brandColor.toString()); - $("#titles", this.doc).css("background", brandColor.toString()); - - // Make background-color of the body of bug salmon pink + this.dok.getElementsByTagName("body")[0]. + style.background = brandColor.toString() + " none"; + this.dok.getElementById("titles"). + style.background = brandColor.toString() + " none"; + + // Remove "Bug" from the title of the bug page, so we have more space with plenty of tabs + var titleElem = this.dok.getElementsByTagName("title")[0]; + titleElem.textContent = titleElem.textContent.slice(4); + // var bodyTitleElem = this.dok.querySelector("#summary_alias_container ") + var bodyTitleParent = this.dok.getElementById("summary_alias_container").parentNode; + var bodyTitleElem = bodyTitleParent.getElementsByTagName("b")[0]; + bodyTitleElem.textContent = bodyTitleElem.textContent.slice(4); + + // Make background-color of the body of bug salmon pink // for security bugs. if (this.hasKeyword("Security")) { - $("#bugzilla-body", this.doc).css({ - 'background-image' : 'none', - 'background-color' : SalmonPink.toString() - }); + this.dok.getElementById("bugzilla-body"). + style.background = SalmonPink.toString() + ' none'; } // Make it visible whether the bug has been triaged if (this.isTriaged()) { - var triagedColor = brandColor.lightColor(); - $("#bz_field_status",this.doc).css({ - 'background-image' : 'none', - 'background-color' : triagedColor.toString() - }); + this.dok.getElementById("bz_field_status"). + style.background = brandColor.lightColor().toString() + " none"; } // we should make visible whether maintCCAddr is in CCList if (isInList(this.maintCCAddr, this.CCList)) { - $("#cc_edit_area_showhide", this.doc). - css({ "color": "navy", - "font-weight": "bolder", - "text-decoration": "underline"}); + let ccEditBoxElem = this.dok.getElementById("cc_edit_area_showhide"); + ccEditBoxElem.style.color = "navy"; + ccEditBoxElem.style.fontWeight = "bolder"; + ccEditBoxElem.style.textDecoration = "underline"; } // mark suspicious components - // FIXME use https://bugzilla.redhat.com/show_bug.cgi?id=538818 for testing if (suspiciousComponents && isInList(this.component,suspiciousComponents)) { - $("#bz_component_edit_container",this.doc). - css({ - "background-color": "red", - "background-image": "none" - }); + this.dok.getElementById("bz_component_edit_container"). + style.background = "red none"; } }; @@ -639,7 +635,7 @@ bzPage.prototype.fillInWhiteBoard = function (iLine, driverStr) { } } this.addTextToTextBox("status_whiteboard",("card_"+outStr).trim()); - $("#chipmagic", this.doc).css("display","none"); + this.dok.getElementById("chipmagic").style.display = "none"; }; /** @@ -724,7 +720,7 @@ bzPage.prototype.fillInChipMagic = function () { if (interestingLineArr.length >0) { interestingArray = ChipsetRE.exec(interestingLineArr[0]); interestingLine = interestingArray[2].replace(/[\s"]+/g," ").trim(); - var whiteboardInput = $("#status_whiteboard",that.doc); + var whiteboardInput = this.dok.getElementById("status_whiteboard"); that.addNewButton(whiteboardInput,"chipmagic","Fill In", "","CHIPMAGIC", interestingLine+"\t"+interestingArray[1].toUpperCase(), @@ -843,7 +839,7 @@ bzPage.prototype.selectOption = function(id,label) { * */ bzPage.prototype.hasKeyword = function(str) { - var kwd = $('#keywords',this.doc).val().trim(); + var kwd = this.dok.getElementById('keywords').value.trim(); return (new RegExp(str).test(kwd)); }; @@ -855,12 +851,11 @@ bzPage.prototype.hasKeyword = function(str) { * @param accKey what will be the accesskey itself * @param afterText text after the accesskey character * @return modified element with the fixed accesskey - * + * FIXME isn't this closure and possible memleak? */ -bzPage.prototype.fixElement = function (rootElement,beforeText,accKey,afterText) { - elem = $(rootElement); - elem.attr("accesskey",accKey.toLowerCase()); - elem.html(beforeText + "" + accKey + "" + afterText); +bzPage.prototype.fixElement = function (elem,beforeText,accKey,afterText) { + elem.setAttribute("accesskey",accKey.toLowerCase()); + elem.innerHTML = beforeText + "" + accKey + "" + afterText; return elem; }; @@ -876,13 +871,13 @@ bzPage.prototype.changeOwner = function(newAssignee) { * Switch off setting to the default assignee */ if (!isInList(newAssignee, this.CCList)) { - $("#newcc",this.doc).text(newAssignee); + this.dok.getElementById("newcc").textContent = newAssignee; } if (newAssignee) { - this.clickMouse($("#bz_assignee_edit_action",this.doc)); - $("#set_default_assignee",this.doc).removeAttr("checked"); - $("#assigned_to", this.doc).val(newAssignee); - $("#setdefaultassigneebutton", this.doc).css("display","none"); + this.clickMouse(this.dok.getElementById("bz_assignee_edit_action")); + this.dok.getElementById("set_default_assignee").removeAttribute("checked"); + this.dok.getElementById("assigned_to").value = newAssignee; + this.dok.getElementById("setdefaultassigneebutton").style.display = "none"; } }; @@ -893,7 +888,7 @@ bzPage.prototype.changeOwner = function(newAssignee) { * @return none */ bzPage.prototype.setNeedinfoReporter = function() { - $("#needinfo",this.doc).click(); + this.clickMouse(this.dok.getElementById("needinfo")); this.selectOption("needinfo_role", "reporter"); }; @@ -906,18 +901,18 @@ bzPage.prototype.setNeedinfoReporter = function() { * @return none */ bzPage.prototype.addTextToTextBox = function(id,string2BAdded) { - var textBox = $("#"+id,this.doc); + var textBox = this.dok.getElementById(id); var separator = ", " - if (textBox.get(0).tagName.toLowerCase() == "textarea") { + if (textBox.tagName.toLowerCase() == "textarea") { separator = "\n\n"; } // don't remove the current content of the comment box, // just behave accordingly - if (textBox.val().length > 0) { - textBox.val(textBox.val() + separator); + if (textBox.value.length > 0) { + textBox.value = textBox.value + separator; } - textBox.val(textBox.val() + string2BAdded); + textBox.value = textBox.value + string2BAdded; }; /** @@ -1069,6 +1064,7 @@ bzPage.prototype.fixAllAttachments = function(list) { * * @param list Array of all bad attachmentss * @return button fixing all bad Attachments + * FIXME deJQuerize!!! */ bzPage.prototype.createFixAllButton = function (list) { var that = this; -- cgit