diff options
Diffstat (limited to 'bugzillaBugTriage.js')
-rw-r--r-- | bugzillaBugTriage.js | 220 |
1 files changed, 117 insertions, 103 deletions
diff --git a/bugzillaBugTriage.js b/bugzillaBugTriage.js index 410ca08..0c21118 100644 --- a/bugzillaBugTriage.js +++ b/bugzillaBugTriage.js @@ -98,17 +98,17 @@ var bottomRow = {}; // console.log("Now we are calling XMLHTTPRequest to load xmlrpc.js"); // req.send(""); /* - * + * * xmlrpc.js beta version 1 Tool for creating XML-RPC formatted requests in * JavaScript - * + * * Copyright 2001 Scott Andrew LePera scott@scottandrew.com * http://www.scottandrew.com/xml-rpc - * + * * License: You are granted the right to use and/or redistribute this code only * if this license and the copyright notice are included and you accept that no * warranty of any kind is made or implied by the author. - * + * */ function XMLRPCMessage(methodname) { @@ -207,11 +207,11 @@ XMLRPCMessage.prototype.doDateXML = function(data) { var time = this.leadingZero(new String(date.getHours())) + ":" + this.leadingZero(new String(date.getMinutes())) + ":" + this.leadingZero(new String(date.getSeconds())); - + var converted = year + month + day + "T" + time; return converted; }; - + var xml = "<dateTime.iso8601>"; xml += dateToISO8601(data); xml += "</dateTime.iso8601>"; @@ -267,7 +267,7 @@ XMLRPCMessage.prototype.getParamXML = function(type, data) { ///* // * Create and return an object that has p as its prototype -// * +// * // * @param p parent Object // * @return child Object // */ @@ -315,7 +315,7 @@ hlpr.addCSVValue = function addCSVValue(str, value) { /** * Check whether an item is member of the list. Idea is just to make long if * commands slightly more readable. - * + * * @param mbr * string to be searched in the list * @param list @@ -363,7 +363,7 @@ hlpr.loadText = function(URL, cb_function, what) { /** * Converts attributes value of the given list of elements to the Javascript * list. - * + * * @param list * array of elements * @return array of values @@ -427,7 +427,7 @@ hlpr.loadJSON(PCIIDsURL, function(response) { function Color(r, g, b) { this.Luminosity = 0.85; this.Desaturated = 0.4; - + if (r instanceof Array) { this.r = r[0]; this.g = r[1]; @@ -466,7 +466,7 @@ Color.prototype.toString = function() { * Converts an RGB color value to HSL. Conversion formula adapted from * http://en.wikipedia.org/wiki/HSL_color_space. Assumes r, g, and b are * contained in the set [0, 255] and returns h, s, and l in the set [0, 1].4343 - * + * * @param Number * r The red color value * @param Number @@ -508,7 +508,7 @@ Color.prototype.hsl = function() { * Converts an HSL color value to RGB. Conversion formula adapted from * http://en.wikipedia.org/wiki/HSL_color_space. Assumes h, s, and l are * contained in the set [0, 1] and returns r, g, and b in the set [0, 255]. - * + * * @param Number * h The hue * @param Number @@ -556,7 +556,7 @@ Color.prototype.hslToRgb = function(h, s, l) { * Converts an RGB color value to HSV. Conversion formula adapted from * http://en.wikipedia.org/wiki/HSV_color_space. Assumes r, g, and b are * contained in the set [0, 255] and returns h, s, and v in the set [0, 1]. - * + * * @param Number * r The red color value * @param Number @@ -599,7 +599,7 @@ Color.prototype.hsv = function() { * Converts an HSV color value to RGB. Conversion formula adapted from * http://en.wikipedia.org/wiki/HSV_color_space. Assumes h, s, and v are * contained in the set [0, 1] and returns r, g, and b in the set [0, 255]. - * + * * @param Number * h The hue * @param Number @@ -669,18 +669,18 @@ Color.prototype.lightColor = function() { // BZPage's methods function BZPage(doc) { - + } /** * Select option with given label on the <SELECT> element with given id. - * + * * Also execute change HTMLEvent, so that the form behaves accordingly. - * + * * @param id * @param label * @return none - * + * * FIXME bugzilla-comments version has this signature: * selectOption = function selectOption(select, value) { let doc = select[0].ownerDocument; @@ -702,11 +702,11 @@ BZPage.prototype.selectOption = function(id, label) { /** * Send mouse click to the specified element - * + * * @param element * where to send mouseclick to * @return None - * + * * FIXME depreceated version from bugzilla-comments hlpr.clickElement = function clickElement(element) { let doc = element[0].ownerDocument; @@ -722,7 +722,7 @@ BZPage.prototype.clickMouse = function(target) { /** * format date to be in ISO format (just day part) - * + * * @param date * @return string with the formatted date */ @@ -738,7 +738,7 @@ BZPage.prototype.getISODate = function (dateStr) { /** * select element of the array where regexp in the first element matches second * parameter of this function - * + * * @param list * array with regexps and return values * @param chosingMark @@ -761,12 +761,12 @@ BZPage.prototype.filterByRegexp = function(list, chosingMark) { /** * Add text to the text box (comment box or status whiteboard) - * + * * @param id * string with the id of the element * @param string2BAdded * string to be added to the comment box - * + * * @return none */ BZPage.prototype.addTextToTextBox = function(id, string2BAdded) { @@ -791,11 +791,11 @@ BZPage.prototype.addTextToTextBox = function(id, string2BAdded) { /** * Add new keyword among the keywords. - * + * * @param str * string with the new keyword * @return none - * + * * Checks for the existing keywords. */ BZPage.prototype.addKeyword = function(str) { @@ -804,7 +804,7 @@ BZPage.prototype.addKeyword = function(str) { /** * generalized hasKeyword ... search in the value of the box with given id - * + * * @param id * String with ID of the element we want to check * @param str @@ -824,7 +824,7 @@ BZPage.prototype.idContainsWord = function(id, str) { /** * Check for the presence of a keyword - * + * * @param str * string with the keyword * @return Boolean @@ -835,7 +835,7 @@ BZPage.prototype.hasKeyword = function(str) { /** * Set additional keyword if it isn't there - * + * * @param str * string with the keyword * @return none @@ -857,7 +857,7 @@ BZPage.prototype.getOptionValue = function(id) { /** * Generic function to add new button to the page. Actually copies new button * from the old one (in order to have the same look-and-feel, etc. - * + * * @param originalLocation * object after which the new button will be added * @param newId @@ -875,7 +875,7 @@ BZPage.prototype.getOptionValue = function(id) { * @param doSubmit * bool optional whether the button should submit whole page (default * true) - * + * * @return none */ BZPage.prototype.addNewButton = function(originalLocation, newId, newLabel, @@ -931,11 +931,47 @@ BZPage.prototype.getLogin = function () { return loginStr; } +/** + * returns password from the current storage, or if there isn't + * one, then it will ask user for it. + * + * @return String with the password + * @todo TODO myStorage is a global object ... should be probably a parameter + * of BZPage instance. + * - more importantly, we should use jetpack.storage.settings + */ +BZPage.prototype.getPassword = function() { + if (myStorage.BZpassword) { + return myStorage.BZpassword; + } else { + var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + .getService(Components.interfaces.nsIPromptService); + var password = { + value : "" + }; // default the password to pass + var check = { + value : true + }; // default the checkbox to true + var result = prompts.promptPassword(null, "Title", "Enter password:", + password, null, check); + // result is true if OK was pressed, false if cancel was pressed. + // password.value is + // set if OK was pressed. The checkbox is not displayed. + if (result) { + this.password = password.value; + myStorage.BZpassword = this.password; + jetpack.storage.simple.sync(); + return password.value; + } + } + return null; +} + // ==================================================================================== // MozillaBugzilla object MozillaBugzilla = function () { - + }; MozillaBugzilla.prototype = new BZPage(); MozillaBugzilla.prototype.constructor = MozillaBugzilla; @@ -948,7 +984,7 @@ RHBugzillaPage = function(doc) { const manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], [ "ATI Mobility Radeon", "ATI", "1002" ], [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ]; - + // http://en.wikipedia.org/wiki/HSL_color_space // when only the value of S is changed // stupido!!! the string is value in hex for each color @@ -965,35 +1001,13 @@ RHBugzillaPage = function(doc) { this.EmptyLogsColor = new Color(0, 255, 0); this.FullLogsColor = this.FedoraColor; // END OF CONSTANTS - + this.doc = doc; var that = this; this.originalButton = this.doc.getElementById("commit"); - - this.login = this.getLogin(); - if (myStorage.BZpassword) { - this.password = myStorage.BZpassword; - } else { - var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - var password = { - value : "" - }; // default the password to pass - var check = { - value : true - }; // default the checkbox to true - var result = prompts.promptPassword(null, "Title", "Enter password:", - password, null, check); - // result is true if OK was pressed, false if cancel was pressed. - // password.value is - // set if OK was pressed. The checkbox is not displayed. - if (result) { - this.password = password.value; - myStorage.BZpassword = this.password; - jetpack.storage.simple.sync(); - } - } + this.login = this.getLogin(); + this.password = this.getPassword(); var bugNoTitle = this.doc.querySelector("#title > p").textContent.trim(); this.bugNo = new RegExp("[0-9]+").exec(bugNoTitle)[0]; @@ -1198,13 +1212,13 @@ RHBugzillaPage.prototype.constructor = RHBugzillaPage; /* Offline supporting functions */ /** - * + * * @todo FIXME this probably makes a closure and a memory leak name='changeform' * investigate * https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion - * + * * <form method="post" action="process_bug.cgi" autocomplete="off"> - * + * * Reading * http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13 * random notes: - 17.13.3 provides all steps necessary - enctype != @@ -1294,8 +1308,8 @@ RHBugzillaPage.prototype.submitCallback = function(evt) { }; /** - * - * + * + * * Yes, this is correct, this is NOT method of RHBugzillaPage! */ function onlineCallback() { @@ -1353,7 +1367,7 @@ function onlineCallback() { /** * Get the current email of the reporter of the bug. - * + * * @return string */ RHBugzillaPage.prototype.getReporter = function() { @@ -1364,7 +1378,7 @@ RHBugzillaPage.prototype.getReporter = function() { /** * Get the current version of the Fedora release ... even if changed meanwhile * by bug triager. - * + * * @return string (integer for released Fedora, float for RHEL, rawhide) */ RHBugzillaPage.prototype.getVersion = function() { @@ -1388,7 +1402,7 @@ RHBugzillaPage.prototype.commentsWalker = function(fce) { /** * Set background color of all comments made by reporter in ReporterColor color - * + * */ RHBugzillaPage.prototype.checkComments = function() { var that = this; @@ -1416,7 +1430,7 @@ RHBugzillaPage.prototype.ProfessionalProducts = [ /** * Is this bug a RHEL bug? - * + * * @return Boolean true if it is a RHEL bug */ RHBugzillaPage.prototype.isEnterprise = function() { @@ -1432,12 +1446,12 @@ RHBugzillaPage.prototype.isEnterprise = function() { /** * Find out whether the bug is needed an attention of bugZappers - * + * * @return Boolean whether the bug has been triaged or not */ RHBugzillaPage.prototype.isTriaged = function() { // First excceptions - if (this.version > 7 && this.version < 13) { + if (this.version > 7 && this.version < 12) { return this.doc.getElementById("bug_status").value.toUpperCase() !== "NEW"; } else { // and then the rule return this.hasKeyword("Triaged"); @@ -1446,7 +1460,7 @@ RHBugzillaPage.prototype.isTriaged = function() { /** * Set branding colours to easily distinguish between Fedora and RHEL bugs - * + * * @param brand * string with product of the current bug * @param version @@ -1454,7 +1468,7 @@ RHBugzillaPage.prototype.isTriaged = function() { * @param its * string with the IsueTracker numbers * @return none - * + * */ RHBugzillaPage.prototype.setBranding = function() { var brandColor = {}; @@ -1486,7 +1500,7 @@ RHBugzillaPage.prototype.setBranding = function() { // Remove "Bug" from the title of the bug page, so we have more space with // plenty of tabs var titleElem = this.doc.getElementsByTagName("title")[0]; - titleElem.textContent = titleElem.textContent.slice(4); + titleElem.textContent = titleElem.textContent.slice(4); var bodyTitleParent = this.doc.getElementById("summary_alias_container").parentNode; var bodyTitleElem = bodyTitleParent.getElementsByTagName("b")[0]; bodyTitleElem.textContent = bodyTitleElem.textContent.slice(4); @@ -1527,7 +1541,7 @@ RHBugzillaPage.prototype.setBranding = function() { /** * Given line to be parsed, find out which chipset it is and fill in the * whiteboard - * + * * @param iLine * string with the whole unparsed "interesting line" * @param driverStr @@ -1536,7 +1550,7 @@ RHBugzillaPage.prototype.setBranding = function() { */ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { var that = this; - + function groupIDs(manStr, cardStrID) { var outStr = that.filterByRegexp(chipIDsGroupings, manStr + "," + cardStrID); if (outStr.length === 0) { @@ -1548,12 +1562,12 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { /** * Given PCI IDs for manufacturer and card ID return chipset string - * + * * @param manufacturerNo * string with manufacturer PCI ID * @param cardNo * string with card PCI ID - * + * * @return array with chip string and optinoal variants */ function checkChipStringFromID(manufacturerNo, cardNo) { @@ -1615,7 +1629,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { * Get attached Xorg.0.log, parse it and find the value of chip. Does not fill * the whiteboard itself, just adds button to do so,paramList so that slow * XMLHttpRequest is done in advance. - * + * * @return None */ RHBugzillaPage.prototype.fillInChipMagic = function () { @@ -1673,7 +1687,7 @@ RHBugzillaPage.prototype.fillInChipMagic = function () { /** * Opens a new tab with a query for the given text in the selected component - * + * * @param text * to be searched for * @param component @@ -1681,7 +1695,7 @@ RHBugzillaPage.prototype.fillInChipMagic = function () { * @param product * (optional) string with the product name * @return None - * + * */ RHBugzillaPage.prototype.queryInNewTab = function(text, component, product) { // Optional parameter @@ -1752,7 +1766,7 @@ RHBugzillaPage.prototype.queryUpstream = function() { } /** - * + * */ RHBugzillaPage.prototype.sendBugUpstream = function() { var url = this.filterByRegexp(newUpstreamBugsURLArray, this @@ -1773,7 +1787,7 @@ RHBugzillaPage.prototype.sendBugUpstream = function() { /** * Parse the row with the attachment - * + * * @param * <tr> DOM element to be parsed * @return array with string name of the attachment, integer its id number, @@ -1810,11 +1824,11 @@ RHBugzillaPage.prototype.parseAttachmentLine = function(inElem) { /** * Check for the presence of a keyword - * + * * @param str * string with the keyword * @return Boolean - * + * */ RHBugzillaPage.prototype.hasKeyword = function(str) { var kwd = this.doc.getElementById('keywords').value.trim(); @@ -1823,7 +1837,7 @@ RHBugzillaPage.prototype.hasKeyword = function(str) { /** * Add accesskey to the particular element - * + * * @param rootElement * element to which the new text object will be attached * @param beforeText @@ -1843,7 +1857,7 @@ RHBugzillaPage.prototype.fixElement = function(elem, beforeText, accKey, afterTe /** * Add XGL to the CC list - * + * * @param evt * event which made this function active * @return none @@ -1870,9 +1884,9 @@ RHBugzillaPage.prototype.changeOwner = function(newAssignee) { /** * Set the bug to NEEDINFO state - * + * * Working function. - * + * * @return none */ RHBugzillaPage.prototype.setNeedinfoReporter = function() { @@ -1882,7 +1896,7 @@ RHBugzillaPage.prototype.setNeedinfoReporter = function() { /** * Return string with the ID for the external_id SELECT for external bugzilla - * + * * @param URLhostname * string hostname of the external bugzilla * @return string with the string for the external_id SELECT @@ -1899,7 +1913,7 @@ RHBugzillaPage.prototype.getBugzillaName = function(URLhostname) { /** * Generate URL of the bug on remote bugzilla - * + * * @param selectValue * Number which is index of the bugzilla in hashBugzillaWholeURL * @param bugID @@ -1918,7 +1932,7 @@ RHBugzillaPage.prototype.getWholeURL = function(selectValue, bugID) { /** * Callback function for the XMLRPC request - * + * * @param ret * object with xmlhttprequest response with attributes: + status -- * int return code + statusText + responseHeaders + responseText @@ -1932,7 +1946,7 @@ RHBugzillaPage.prototype.callBack = function(data, textStatus) { /** * The worker function -- call XMLRPC to fix MIME type of the particular * attachment - * + * * @param id * integer with the attachment id to be fixed * @param type @@ -1940,19 +1954,19 @@ RHBugzillaPage.prototype.callBack = function(data, textStatus) { * @param email * Boolean whether email should be sent to appropriate person; * option, defaults to false - * + * * updateAttachMimeType($data_ref, $username, $password) - * + * * Update the attachment mime type of an attachment. The first argument is a * data hash containing information on the new MIME type and the attachment id * that you want to act on. - * + * * $data_ref = { "attach_id" => "<Attachment ID>", # Attachment ID to perform * MIME type change on. "mime_type" => "<New MIME Type Value>", # Legal MIME * type value that you want to change the attachment to. "nomail" => 0, # * OPTIONAL Flag that is either 1 or 0 if you want email to be sent or not for * this change }; - * + * */ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) { if (type === undefined) { @@ -2004,7 +2018,7 @@ RHBugzillaPage.prototype.fixAllAttachments = function(list) { /** * Create a button for fixing all bad attachments. - * + * * @param list * Array of all bad attachmentss * @return button fixing all bad Attachments @@ -2026,7 +2040,7 @@ RHBugzillaPage.prototype.createFixAllButton = function(list) { /** * Add a link to the bad attachment for fixing it. - * + * * @param * <TR> DOM jQuery element with a bad attachment * @return none @@ -2043,10 +2057,10 @@ RHBugzillaPage.prototype.addTextLink = function(row) { /** * Add information about the upstream bug upstream, and closing it. - * + * * @param evt * event which called this handler - * + * * @return none */ RHBugzillaPage.prototype.addClosingUpstream = function() { @@ -2102,7 +2116,7 @@ RHBugzillaPage.prototype.addClosingUpstream = function() { /** * Insert a row of buttons before the marked element - * + * * @param anchor * element before which the row of buttons will be inserted * @param array @@ -2119,7 +2133,7 @@ RHBugzillaPage.prototype.generateToolBar = function(anchor, array) { /** * Generalized function for all actions - * + * * @param addString * string to be added as new comment * @param nextState @@ -2222,7 +2236,7 @@ RHBugzillaPage.prototype.generalPurposeCureForAllDisease = function(addString, }; /** - * + * */ RHBugzillaPage.prototype.parseBacktrace = function(ret) { var splitArray = ret.split("\n"); @@ -2259,7 +2273,7 @@ RHBugzillaPage.prototype.parseBacktrace = function(ret) { * Main executable functioning actually building all buttons on the page -- * separated into function, so that it could be called from onload method of the * XMLHttpRequest. - * + * * @param jsonList * Array created from JSON * @return none |