// ==UserScript== // @name bugs.gentoo.org triage helper // @description Adds links above the bugs.gentoo.org comment field for stock responses. // You will need a Mozilla browser and the Greasemonkey extension // // installed to use this, or the Opera web browser. // @author Andre Klapper , // @author Christian Kirbach (Opera fixes) // @author Torsten Veller (Gentoo modification) // @version 2010-06-25 // @include https://bugs.gentoo.org/show_bug.cgi?id=* // @copyright (C) Copyright Control by the authors, 2007 and later. // @license The contents of this file are subject to the Mozilla Public // License Version 1.1 (the "License"); you may not use this file // except in compliance with the License. You may obtain a copy of // the License at http://www.mozilla.org/MPL/ // Software distributed under the License is distributed on an "AS // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or // implied. See the License for the specific language governing // rights and limitations under the License. // The Original Code is the Bugzilla Bug Tracking System. // Parts of this code come from the old GNOME Bugzilla 2.20 version located at // http://git.gnome.org/cgit/bugzilla-newer/tree/template/en/default/bug/edit.html.tmpl // The Initial Developer of the Original Code is Netscape Communications // Corporation. Portions created by Netscape are // Copyright (C) 1998 Netscape Communications Corporation. All // Rights Reserved. // Contributor(s): Gervase Markham // Vaskin Kissoyan /* HACKERS PLEASE NOTE: * 1) if you want to add individual stock responses for yourself, you have to add two things: * a) an EventHandler function (like "FooClick") * to define the comment text and the bug resolution * b) a createStockResponse() call at the end of this script that creates the stock * response link on the webpage and calls the EventHandler function you defined in a) * 2) Note that the "addTextToComment" signature here is different from the one used at * bugzilla.gnome.org in /template/en/default/bug/edit.html.tmpl. */ /************************************************************/ /*find out which product/component the bug report is about: */ /************************************************************/ var product = document.getElementById("product").value; var component = document.getElementById("component").value; /* Note to andre: Drop your non-public Nokia stuff here */ /*************************************************************/ /* set prefered height of some fields: */ /*************************************************************/ document.getElementById("comment").rows = 13; /************************************************************************************/ /* if CC field is displayed (=you are not already on the CC list), then make sure */ /* that the CC field is unchecked. this workaround is needed for some actions to */ /* properly add yourself to the CC list - i prefer to CC myself on everything(TM) */ /************************************************************************************/ if (document.getElementById("addselfcc") != null) { document.getElementById("addselfcc").checked = false; } /************************************************************/ /* some requirements for adding stock responses: */ /************************************************************/ /* add a
container for the custom stock responses above the comment input field */ var commentField = document.getElementById("comment"); var individualDiv = document.createElement("div"); individualDiv.setAttribute('id', "custom_div"); var individualDivText = document.createTextNode(""); // "heading" for the div individualDiv.appendChild(individualDivText); individualDiv.setAttribute('style', "max-width:700px; border:0px solid #000000; padding:0px; margin: 2px 0px 2px; text-align: left; background-color:#f4f4f4"); commentField.parentNode.insertBefore(individualDiv, commentField); /* function creates individual stock responses * @param stockID some ID for the to create * @param linkTextDisplayed the link text to be displayed * @param clickHandler the name of the EventHandler function (function must have been defined before in this code) * @return void */ function createStockResponse(stockID, linkTextDisplayed, clickHandler, bgcolor) { var SpanContainer = document.createElement("span"); SpanContainer.setAttribute('id', stockID); var SpanContainerText = document.createTextNode(linkTextDisplayed); SpanContainer.appendChild(SpanContainerText); individualDiv.appendChild(SpanContainer); if (bgcolor == 1) { SpanContainer.setAttribute('style', "padding:0px 5px 0px 5px; background-color:#d7c38e"); } else if (bgcolor == 2) { SpanContainer.setAttribute('style', "padding:0px 5px 0px 5px; background-color:#f97bcf"); } else if (bgcolor == 3) { SpanContainer.setAttribute('style', "padding:0px 5px 0px 5px; background-color:#f4af6e"); } else if (bgcolor == 4) { SpanContainer.setAttribute('style', "padding:0px 5px 0px 5px; background-color:#c7b39e"); } else /* if (bgcolor == 0) */ { SpanContainer.setAttribute('style', "padding:0px 5px 0px 5px;"); } SpanContainer.addEventListener("click", clickHandler, true); } /* function adds reply text to the comment textarea, enables the CC checkbox * and set keyboard focus to the submit button * (shamelessly partially adopted from bugzilla.gnome.org code at * /template/en/default/bug/edit.html.tmpl which is under a Mozilla Public License) * @param text text to add as a new comment * @param knob what to mark the bug report as (e.g. "duplicate" or "needinfo") * @param resolve string that describes the resolution (e.g. "incomplete" or "fixed") * @param crasher if "1", set priority and severity accordingly * @param ccme if "1", add me to the CC list of the bug * @return void */ function addTextToComment(text, knob, resolve, crasher, ccme, moreinfo) { /* pre id="comment_name_N" */ /* make sure we split on all newlines -- IE or Moz use \r and \n * respectively */ text = text.split(/\r|\n/); var replytext = ""; for (var i=0; i < text.length; i++) { replytext += text[i] + "\n"; } if (resolve && resolve != "") { knob = 'resolve'; document.getElementsByName('resolution')[0].value = resolve; } if (knob && knob != "") { var radiobutton = document.getElementById('knob-' + knob); if (radiobutton) {radiobutton.checked = true;} } if (crasher == "1") { document.getElementsByName('priority')[0].value = 'High'; document.getElementsByName('bug_severity')[0].value = 'critical'; } /* enables the CC checkbox as we want to be informed when the reporter adds some info?: */ if (ccme == "1" && document.getElementById("addselfcc") != null) { if (document.getElementById("addselfcc").checked == false) { document.getElementById("addselfcc").checked = true; } } /* add moreinfo keyword: */ if (moreinfo == "1") { if (document.getElementsByName('keywords')[0].value == "") { document.getElementsByName('keywords')[0].value = "moreinfo"; } else { document.getElementsByName('keywords')[0].value += ", moreinfo"; } } var textarea = document.getElementById('comment'); textarea.value += replytext; /* auto-focus the "submit" button to save time */ if (knob && knob == "duplicate") { if (document.getElementsByName('dup_id')[0] != null) {document.getElementsByName('dup_id')[0].focus();} } return false; } /****************************************************/ /* Gentoo mods */ /****************************************************/ function SunriseSuggested (Event) { var Text = "Hello, The Gentoo Team would like to firstly thank you for your ebuild\nsubmission. Unfortunately it is possible that your ebuild might not reach the\nportage tree in a timely manner. There are simply too many new packages.\n\nAllow me to use this opportunity to introduce you to Gentoo Sunrise. The Project\nSunrise overlay [1] is a overlay for Gentoo which we allow trusted users to\ncommit to and all users can have ebuilds reviewed by Gentoo devs for entry into\nthe overlay. Please read the SunriseFaq [2] for additional information.\n\n[1] http://www.gentoo.org/proj/en/sunrise/\n[2] http://overlays.gentoo.org/proj/sunrise/wiki/SunriseFaq"; addTextToComment(Text, 'reassign', '', '', ''); document.getElementById("assigned_to").value="maintainer-wanted@gentoo.org"; document.getElementsByName("status_whiteboard")[0].value="sunrise-suggested"; } /*******************************************************************/ /* now finally add our custom stock response links to the web page */ /*******************************************************************/ //if (product == "Gentoo Linux" && component == "Ebuilds") { if (product == "Gentoo Linux") { createStockResponse('sunrise_suggested','[Sunrise-Suggested] ', SunriseSuggested, 1); };