From 3c3860cd080dec5a71ae6c3c7bc3438fa8875d94 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 25 Mar 2011 15:01:26 +0100 Subject: Starting another module ... all small embelishments to the page. --- data/lib/otherButtons.js | 158 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 data/lib/otherButtons.js (limited to 'data/lib/otherButtons.js') diff --git a/data/lib/otherButtons.js b/data/lib/otherButtons.js new file mode 100644 index 0000000..16adcea --- /dev/null +++ b/data/lib/otherButtons.js @@ -0,0 +1,158 @@ +// Released under the MIT/X11 license +// http://www.opensource.org/licenses/mit-license.php +"use strict"; + +/** + * Find default assignee based on the current component + * + * @return String what would be a default assignee if + * we haven't set it up. + */ +function getDefaultAssignee() { + return filterByRegexp(constantData.defaultAssignee, + getComponent()).toLowerCase(); +} + +/** + * Set default assignee + * + * @return none + * sets this.defaultAssignee property according to defaultAssignee list + */ +function setDefaultAssignee() { + var defAss = getDefaultAssignee(); + + // Add setting default assignee + if ((defAss.length > 0) && (defAss !== getOwner())) { + createNewButton("bz_assignee_edit_container",true, { + "name": "Def. Assignee", + "assignee": "default" + }); + } +} + +function markBugTriaged() { + // https://fedoraproject.org/wiki/BugZappers/Meetings/Minutes-2009-Oct-27 + // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\ + // /fedora-meeting.2009-11-24-15.11.log.html + // http://meetbot.fedoraproject.org/fedora-meeting/2009-11-24\ + // /fedora-meeting.2009-11-24-15.11.log.html + addStuffToTextBox("keywords","Triaged"); +} + +function addingEmbelishments(list) { + var FillMagicDoneRE = new RegExp("^\\s*\\[[0-9a-zA-Z_]*\\]"); + + var maintCCAddr = ""; + if (constantData.CCmaintainer) { + maintCCAddr = filterByRegexp(constantData.CCmaintainer, + getComponent())[0]; // filterByRegexp returns array, not string + } + + // we should make visible whether maintCCAddr is in CCList + if (maintCCAddr && isInList(maintCCAddr, getCCList())) { + var ccEditBoxElem = document.getElementById("cc_edit_area_showhide"); + ccEditBoxElem.style.color = "navy"; + ccEditBoxElem.style.fontWeight = "bolder"; + ccEditBoxElem.style.textDecoration = "underline"; + } + + // Take care of signature for Fedora bugzappers + if (config.signature && config.signature.length > 0) { + var signaturesCounter = 0; + var signatureFedoraString = config.signature; + document.forms.namedItem("changeform").addEventListener("submit", + function(aEvt) { + if (signaturesCounter < 1) { + addStuffToTextBox("comment", signatureFedoraString); + signaturesCounter += 1; + } + }, false); + } + + // set default assignee on change of the component + var compElement = document.getElementById("component"); + if (compElement && (compElement.options)) { + document.getElementById("component").addEventListener("change", + function() { + changeAssignee("default"); + }, false); + } + + // TODO Get compiz bugs as well + if ((constantData.chipNames) && + (list[0]) && + (!FillMagicDoneRE.test(getSummary())) && + (maintCCAddr === "xgl-maint@redhat.com")) { + // Add find chip magic button + var whiteboard_string = document.getElementById("status_whiteboard").value; + if (!/card_/.test(whiteboard_string)) { + fillInChipMagic(XorgLogAttList[0][1]); + } + } +} + +function setBranding(xLogAtts) { + var brandColor = {}; + var TriagedColor = {}; + + var ITbutton = document.getElementById("cf_issuetracker"); + var its = ITbutton ? ITbutton.value.trim() : ""; + + if (isEnterprise()) { + if (its && (its.length > 0)) { + brandColor = RHITColor; + } + else { + brandColor = RHColor; + } + } + else if (new RegExp("Fedora").test(document.getElementById("product").value)) { + if (document.getElementById("version").value === "rawhide") { + brandColor = RawhideColor; + } + else { + brandColor = FedoraColor; + } + } + + // Comment each of the following lines to get only partial branding + document.getElementsByTagName("body")[0].style.background = brandColor + .toString() + + " none"; + document.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 = document.getElementsByTagName("title")[0]; + + titleElem.textContent = titleElem.textContent.slice(4); + var bodyTitleParent = document.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 (hasKeyword("Security")) { + document.getElementById("bugzilla-body").style.background = SalmonPink + .toString() + ' none'; + } + + // Make it visible whether the bug has been triaged + if (isTriaged()) { + document.getElementById("bz_field_status").style.background = brandColor + .lightColor().toString() + + " none"; + } + + var compElems; + if (config.suspiciousComponents + && isInList(getComponent(), config.suspiciousComponents) + && (compElems = document + .getElementById("bz_component_edit_container"))) { + compElems.style.background = "red none"; + } + + addingEmbelishments(xLogAtts); +} -- cgit