From 97f8f5ad45a8dfbde27f555eafec5d8318ad67b2 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Fri, 13 May 2011 12:20:05 +0200 Subject: Really Eclipseize formatting. --- data/lib/addAttachmentRow.js | 48 +++++------ data/lib/bugzillaDOMFunctions.js | 12 +-- data/lib/bzpage.js | 48 +++++------ data/lib/color.js | 22 ++--- data/lib/makeBacktraceAttachment.js | 58 ++++++------- data/lib/otherButtons.js | 13 +-- data/lib/queries.js | 10 +-- data/lib/util.js | 66 +++++++------- data/rhlib/fixingAttMIME.js | 22 ++--- data/rhlib/rhbzpage.js | 142 +++++++++++++++--------------- data/rhlib/xorgBugCategories.js | 4 +- data/tweaks/addNewLinks.js | 54 ++++++------ data/tweaks/bug-page-mod.js | 167 ++++++++++-------------------------- data/tweaks/viewSource.js | 19 ++-- lib/cookiemanager.js | 48 +++++------ lib/libbugzilla.js | 158 +++++++++++++++++----------------- lib/main.js | 37 ++++---- lib/prompts.js | 12 +-- lib/util.js | 8 +- lib/xmlrpc.js | 20 ++--- tests/pagemod-test-helpers.js | 34 ++++---- tests/test-color.js | 2 +- tests/test-pageMod.js | 8 +- tests/test-util.js | 4 +- tests/test-xmlrpc.js | 4 +- 25 files changed, 471 insertions(+), 549 deletions(-) diff --git a/data/lib/addAttachmentRow.js b/data/lib/addAttachmentRow.js index 3bee73a..16eb02c 100644 --- a/data/lib/addAttachmentRow.js +++ b/data/lib/addAttachmentRow.js @@ -1,8 +1,8 @@ -// Released under the MIT/X11 license -// http://www.opensource.org/licenses/mit-license.php +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php "use strict"; -// FIXME resp is JSON, not XML anymore +//FIXME resp is JSON, not XML anymore function addAttachmentCallback(resp) { var newAttachID = parseInt( resp.params.param.value.array.data.value.int, 10); @@ -11,28 +11,28 @@ function addAttachmentCallback(resp) { } /** - * + * * This has to stay in RHBugzillaPage because upstream doesn't have * addAttachment XML-RPC call yet. * Params: $params = { - id => '', # ID of the bug report - comment => "", # OPTIONAL Text string containing comment to add. - description => "", # REQUIRED Text Description of the attachment. - isprivate => , # OPTIONAL Whether the Attachment - will be private # Default: false - filename => "", REQUIRED The name of the file to attach to the bug report. - obsoletes => [List of attach_id's to obsolete], OPTIONAL List if attachment ids that are - obsoleted by this new attachment. - ispatch => , OPTIONAL Whether the attachment is a Patch - or not, if not provided the it will be considered NON Patch attachment. - contenttype => "", OPTIONAL If the attachment is patch - REQUIRED If the attachment is not a patch - If the attachment is patch then contenttype will always be text/plain - data => "", REQUIRED It is a base64 - encoded string of the actual attachment data. - nomail => 0, OPTIONAL Flag that is either 1 or 0 if you want email - to be send ot not for this change } + id => '', # ID of the bug report + comment => "", # OPTIONAL Text string containing comment to add. + description => "", # REQUIRED Text Description of the attachment. + isprivate => , # OPTIONAL Whether the Attachment + will be private # Default: false + filename => "", REQUIRED The name of the file to attach to the bug report. + obsoletes => [List of attach_id's to obsolete], OPTIONAL List if attachment ids that are + obsoleted by this new attachment. + ispatch => , OPTIONAL Whether the attachment is a Patch + or not, if not provided the it will be considered NON Patch attachment. + contenttype => "", OPTIONAL If the attachment is patch + REQUIRED If the attachment is not a patch + If the attachment is patch then contenttype will always be text/plain + data => "", REQUIRED It is a base64 + encoded string of the actual attachment data. + nomail => 0, OPTIONAL Flag that is either 1 or 0 if you want email + to be send ot not for this change } */ function addAttachment(data, callback, param) { var params = []; @@ -44,7 +44,7 @@ function addAttachment(data, callback, param) { } var params = { - id: getBugNo(), + id : getBugNo(), description : titleParsedAttachment, filename : "parsed-backtrace.txt", contenttype : "text/plain", @@ -53,8 +53,8 @@ function addAttachment(data, callback, param) { }; self.postMessage(new Message("MakeJSONRPCCall", { - url : constantData.XMLRPCData[window.location.hostname].url. - replace("xmlrpc.cgi","jsonrpc.cgi"), + url : constantData.XMLRPCData[window.location.hostname].url + .replace("xmlrpc.cgi", "jsonrpc.cgi"), method : "bugzilla.addAttachment", params : params, callRPC : "AddAttachmentCallback" diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js index 6823bc1..8f74288 100644 --- a/data/lib/bugzillaDOMFunctions.js +++ b/data/lib/bugzillaDOMFunctions.js @@ -165,8 +165,8 @@ function createNewButton (location, after, cmdObj) { var newId = cmdObj.name.toLowerCase().replace(/[^a-z0-9]+/,"","g") + "_btn"; } catch (e) { console.error("createNewButton : e = " + e + - "\ncreateNewButton : cmdObj.toSource() = " + - cmdObj.toSource()); + "\ncreateNewButton : cmdObj.toSource() = " + + cmdObj.toSource()); } // protection against double-firings @@ -259,7 +259,7 @@ function getProduct() { function commentsWalker (fce) { var comments = document.getElementById("comments"). - getElementsByClassName("bz_comment"); + getElementsByClassName("bz_comment"); Array.forEach(comments, function(item) { fce(item); }); @@ -298,7 +298,7 @@ function parseAttachmentLine(inElem) { // getting MIME type and size var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent. - replace(/[\n ()]+/g, " ").trim().split(", "); + replace(/[\n ()]+/g, " ").trim().split(", "); size = parseInt(stringArray[0], 10); MIMEtype = stringArray[1].split(" ")[0]; @@ -316,7 +316,7 @@ function parseAttachmentLine(inElem) { function getAttachments () { var outAtts = []; var atts = document.getElementById("attachment_table"). - getElementsByTagName("tr"); + getElementsByTagName("tr"); for ( var i = 1, ii = atts.length - 1; i < ii; i++) { outAtts.push(parseAttachmentLine(atts[i])); } @@ -436,7 +436,7 @@ function isEnterprise() { * @return Boolean whether the bug has been triaged or not */ function isTriaged() { - return hasKeyword("Triaged"); + return hasKeyword("Triaged"); } /** diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js index 10c71fb..aa496cf 100644 --- a/data/lib/bzpage.js +++ b/data/lib/bzpage.js @@ -9,14 +9,14 @@ var NumberOfFrames = 7; // constants var SalmonPink = new Color(255, 224, 176); // RGB 255, 224, 176; HSL 36, 2, - // 85 +// 85 var ReporterColor = new Color(255, 255, 166); // RGB 255, 255, 166; HSL 60, 2, - // 83 +// 83 // global variables var config = {}; var constantData = {}; // This should be probably eliminated ASAP or - // or done by other means. TODO +// or done by other means. TODO var equivalentComponents = null; /** * central handler processing messages from the main script. @@ -34,7 +34,7 @@ self.on('message', function onMessage(msg) { constantData = msg.data.constData; config = msg.data.config; equivalentComponents = ("equivalentComponents" in constantData) ? - constantData.equivalentComponents : null; + constantData.equivalentComponents : null; generateButtons(msg.data.instPkgs, msg.data.kNodes); completeInit(); break; @@ -131,7 +131,7 @@ function centralCommandDispatch (cmdLabel, cmdParams) { clickMouse("bz_url_edit_action"); document.getElementById("bug_file_loc").value = cmdParams; break; - // TODO dependson/blocked doesn't work. Find out why. + // TODO dependson/blocked doesn't work. Find out why. case "addDependsOn": clickMouse("dependson_edit_action"); addStuffToTextBox("dependson", cmdParams); @@ -165,7 +165,7 @@ function centralCommandDispatch (cmdLabel, cmdParams) { case "queryStringOurBugzilla": queryForSelection(); break; - // TODO flags, see also + // TODO flags, see also case "commit": if (cmdParams) { // Directly commit the form @@ -179,7 +179,7 @@ function centralCommandDispatch (cmdLabel, cmdParams) { else { console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams); } - break; + break; } } @@ -200,7 +200,7 @@ function changeAssignee (newAssignee) { // Optional value null if (newAssignee === null) { document.getElementById("set_default_assignee").removeAttribute( - "checked"); + "checked"); return ; } @@ -273,8 +273,8 @@ function generateButtons (pkgs, kNodes) { // ========================================================= if (kNodes && window.location.hostname in kNodes) { - var killConf = kNodes[window.location.hostname]; - killNodes(document, killConf[0], killConf[1]); + var killConf = kNodes[window.location.hostname]; + killNodes(document, killConf[0], killConf[1]); } // create anchor for the top toolbar @@ -300,14 +300,14 @@ function generateButtons (pkgs, kNodes) { break; default: // [+-]ID var firstChr = cmdObj.position.charAt(0); - var newId = cmdObj.position.substr(1); - createNewButton(newId, firstChr === "+", cmdObj); - break; + var newId = cmdObj.position.substr(1); + createNewButton(newId, firstChr === "+", cmdObj); + break; } } else { console.error("generateButtons : rejected cmdObj = " + - cmdObj.toSource()); + cmdObj.toSource()); } } } @@ -320,12 +320,12 @@ function setConfigurationButton () { + "Triage configuration"; additionalButtons.appendChild(configurationButtonUI); document.getElementById("configurationButton").addEventListener( - "click", - function(evt) { - self.postMessage(new Message("ChangeJSONURL", null)); - evt.stopPropagation(); - evt.preventDefault(); - }, false); + "click", + function(evt) { + self.postMessage(new Message("ChangeJSONURL", null)); + evt.stopPropagation(); + evt.preventDefault(); + }, false); } /** @@ -346,15 +346,15 @@ function getOptionTableCell(tableId, label) { if (ourLine.length > 0) { return ourLine[0].getElementsByTagName("td")[1]. - getElementsByTagName("a")[0]; + getElementsByTagName("a")[0]; } return null; } /** - * Complete startup, mainly run alternate inits for non-standard BZ - * with proper arguments + * Complete startup, mainly run alternate inits for non-standard BZ with proper + * arguments * */ function completeInit() { @@ -394,7 +394,7 @@ function startup() { if (brElementPlacer) { brElementPlacer.setAttribute("id","brElementPlacer_location"); brElementPlacer.parentNode.insertBefore(document.createElement("br"), - brElementPlacer); + brElementPlacer); } } diff --git a/data/lib/color.js b/data/lib/color.js index 4d0c41f..0031c5c 100644 --- a/data/lib/color.js +++ b/data/lib/color.js @@ -1,11 +1,11 @@ -// Released under the MIT/X11 license -// http://www.opensource.org/licenses/mit-license.php +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php "use strict"; -// ============================================================================ -// Color management methods -// originally from -// http://www.mjijackson.com/2008/02\ -// /rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript +//============================================================================ +//Color management methods +//originally from +//http://www.mjijackson.com/2008/02\ +///rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript function Color(r, g, b) { this.Luminosity = 0.85; this.Desaturated = 0.4; @@ -51,7 +51,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 @@ -96,7 +96,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 @@ -147,7 +147,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 @@ -193,7 +193,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 diff --git a/data/lib/makeBacktraceAttachment.js b/data/lib/makeBacktraceAttachment.js index 6011c06..9fc72bc 100644 --- a/data/lib/makeBacktraceAttachment.js +++ b/data/lib/makeBacktraceAttachment.js @@ -1,9 +1,9 @@ -// Released under the MIT/X11 license -// http://www.opensource.org/licenses/mit-license.php +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php var titleParsedAttachment = "Part of the thread where crash happened"; /** - * + * */ function pasteBacktraceInComments(atts) { /* @@ -20,11 +20,11 @@ function pasteBacktraceInComments(atts) { return null; var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?" - + "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&" - + "sharer_id=74116"; + + "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&" + + "sharer_id=74116"; var mainTitle = document - .getElementsByClassName("bz_alias_short_desc_container")[0]; + .getElementsByClassName("bz_alias_short_desc_container")[0]; createDeadLink("callAbrtQuery_link", "Abrt bugs", mainTitle, abrtQueryURL, [], false, null, "a"); @@ -42,25 +42,25 @@ function pasteBacktraceInComments(atts) { // just the first one will do for now, we would need to do async // btAttachments - .forEach( - function(x) { - var attURL = "https://bugzilla.redhat.com/attachment.cgi?id=" - + x[1]; - if ((!btSnippet) && // ???? FIXME + .forEach( + function(x) { + var attURL = "https://bugzilla.redhat.com/attachment.cgi?id=" + + x[1]; + if ((!btSnippet) && // ???? FIXME (!idContainsWord("status_whiteboard", 'btparsed'))) { - Request({ - url : attURL, - onComplete : function(response) { - if (response.status == 200) { - btSnippet = parseBacktrace(response.text); - if (btSnippet) { - addCheckShowLink(x, btSnippet); - } - } + Request({ + url : attURL, + onComplete : function(response) { + if (response.status == 200) { + btSnippet = parseBacktrace(response.text); + if (btSnippet) { + addCheckShowLink(x, btSnippet); } - }).get(); + } } - }, this); + }).get(); + } + }, this); } // Add "show BT" links if (parsedAttachments.length > 0) { @@ -72,7 +72,7 @@ function pasteBacktraceInComments(atts) { /** * Open new window with the content of the attachment. - * + * * @param id * Number of the attachment id * @return none @@ -84,7 +84,7 @@ function showAttachment(id) { /** * add a link opening a window with the parsed backtrace - * + * * @param att * Attachment object */ @@ -100,7 +100,7 @@ function addShowParsedBTLink(att) { function addNewAttachmentRow(origAtt, newAttId, newAttSize) { var that = this; var oldAddBTLink = document - .getElementById("attachBacktraceActivator"); + .getElementById("attachBacktraceActivator"); oldAddBTLink.parentNode.removeChild(oldAddBTLink); var newTRElem = origAtt[4].cloneNode(true); @@ -116,9 +116,9 @@ function addNewAttachmentRow(origAtt, newAttId, newAttSize) { aElements[0].getElementsByTagName("b")[0].textContent = titleParsedAttachment; var sizeSpan = newTRElem - .getElementsByClassName("bz_attach_extra_info")[0]; + .getElementsByClassName("bz_attach_extra_info")[0]; sizeSpan.textContent = "(" + (newAttSize / 1024).toFixed(2) - + " KB, text/plain)"; + + " KB, text/plain)"; // aElements[1].textContent = new Date().toString(); TODO we should add // eventually, but not pressing @@ -135,7 +135,7 @@ function addNewAttachmentRow(origAtt, newAttId, newAttSize) { vcardAElem.setAttribute("href", "mailto:" + this.login); vcardAElem.className = "email"; vcardAElem.innerHTML = "" + this.login - + ""; + + ""; } var elem = newTRElem.querySelector("td:last-of-type"); @@ -148,7 +148,7 @@ function addNewAttachmentRow(origAtt, newAttId, newAttSize) { /** * Add a link to create a new attachment with a parsed backtrace - * + * * @param oldAtt * Object with an attachment row * @param snippet diff --git a/data/lib/otherButtons.js b/data/lib/otherButtons.js index 507a3b3..060ce16 100644 --- a/data/lib/otherButtons.js +++ b/data/lib/otherButtons.js @@ -4,7 +4,7 @@ /** * Set background color of all comments made by reporter in ReporterColor color - * + * */ function checkComments() { var reporter = getReporter(); @@ -28,7 +28,7 @@ function collectComments() { /** * 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() { @@ -38,7 +38,7 @@ function getDefaultAssignee() { /** * Set default assignee - * + * * @return none sets this.defaultAssignee property according to defaultAssignee * list */ @@ -63,7 +63,8 @@ function markBugTriaged() { if (hasXorgBugsCategory && !hasXorgBugsCategory()) { alert("This won't do! First set the category!"); } - else if (isEnterprise && !isEnterprise() && (getSeverity() == 'unspecified')) { + else if (isEnterprise && !isEnterprise() + && (getSeverity() == 'unspecified')) { alert("This won't do! Specify some severity!"); } else { @@ -73,7 +74,7 @@ function markBugTriaged() { var FillMagicDoneRE = new RegExp("^\\s*\\[[0-9a-zA-Z_]*\\]"); -function addingEmbelishments(list) { +function addingEmbelishments(logList) { var maintCCAddr = ""; if (constantData.CCmaintainer) { @@ -127,7 +128,7 @@ function addingEmbelishments(list) { /** * Set branding colours to easily distinguish between Fedora and RHEL bugs - * + * * @param brand * String with product of the current bug * @param version diff --git a/data/lib/queries.js b/data/lib/queries.js index 52c6ce6..066991e 100644 --- a/data/lib/queries.js +++ b/data/lib/queries.js @@ -13,7 +13,7 @@ function getSelection() { /** * Opens a new tab with a query for the given text in the selected component - * + * * @param text * to be searched for * @param component @@ -22,7 +22,7 @@ function getSelection() { * (optional) string with the product name, if undefined, search in all * products * @return None - * + * */ function queryInNewTab(text, component, product, equivComps) { var urlStr = "https://" + window.location.hostname @@ -55,7 +55,7 @@ function queryInNewTab(text, component, product, equivComps) { + text; urlStr += searchText; self.postMessage(new Message("OpenURLinTab", urlStr)); // utils.js is - // always avaiulable + // always avaiulable } } @@ -80,7 +80,7 @@ function queryForSelection() { } /** - * + * */ function queryUpstreamCallback(text, queryUpBug) { var searchData = filterByRegexp(queryUpBug, getComponent()); @@ -99,7 +99,7 @@ function queryUpstreamCallback(text, queryUpBug) { /** * Search simple query in the upstream bugzilla appropriate for the component - * + * * @return none */ function queryUpstream(qUpBug) { diff --git a/data/lib/util.js b/data/lib/util.js index 1c3e607..92b9436 100644 --- a/data/lib/util.js +++ b/data/lib/util.js @@ -1,5 +1,5 @@ -/*global console: false */ -/*jslint onevar: false */ +/* global console: false */ +/* jslint onevar: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; @@ -7,14 +7,14 @@ /** * parse URL to get its parts. - * + * * @param url * @return object with all parsed parts of URL as properties - * + * * Originally from * http://james.padolsey.com/javascript/parsing-urls-with-the-dom/ Copyright * February 19th, 2009, James Padolsey, - * + * * This function creates a new anchor element and uses location properties * (inherent) to get the desired URL data. Some String operations are used (to * normalize results across browsers). @@ -30,8 +30,8 @@ function parseURL(url) { query: a.search, params: (function(){ var ret = {}, - seg = a.search.replace(/^\?/,'').split('&'), - len = seg.length, i = 0, s; + seg = a.search.replace(/^\?/,'').split('&'), + len = seg.length, i = 0, s; for (;i/, ""); // bug - // 336551 + // 336551 return new XML(respStr); } @@ -74,7 +74,7 @@ function getBugNo() { /** * Get a bug no from URL ... fails with aliases - * + * * @param url * String with URL to be analyzed * @return String with the bug ID @@ -88,7 +88,7 @@ function getBugNoFromURL(url) { /** * Send mouse click to the specified element - * + * * @param String * ID of the element to send mouseclick to * @return None @@ -103,7 +103,7 @@ function clickMouse (targetID) { /** * Create a A element leadink nowhere, but with listener running a callback on * the click - * + * * @param id * String with a id to be added to the element * @param text @@ -173,10 +173,10 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac * From element diggs out just plain email address Note that * bugzilla.gnome.org doesn't have mailto: url but * https://bugzilla.gnome.org/page.cgi?id=describeuser.html&login=mcepl%40redhat.com - * + * * @param aElement Element with href attribute or something else @return String * with the address or null - * + * */ function parseMailto(aElement) { var emailStr = "", hrefStr = ""; @@ -196,7 +196,7 @@ function parseMailto(aElement) { /** * format date to be in ISO format (just day part) - * + * * @param date * @return string with the formatted date */ @@ -206,13 +206,13 @@ function getISODate(dateStr) { } var date = new Date(dateStr); return date.getFullYear() + '-' + pad(date.getMonth() + 1) + '-' + - pad(date.getDate()); + pad(date.getDate()); } /** * 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 @@ -228,23 +228,23 @@ function isInList(mbr, list) { /** * Make sure value returned is Array - * + * * @param Array/String * @return Array - * + * * If something else than Array or String is passed to the function the result * will be untouched actual argument of the call. */ function valToArray(val) { var isArr = val && - val.constructor && - val.constructor.name === "Array"; + val.constructor && + val.constructor.name === "Array"; return isArr ? val : [val]; } /** * Merges two comma separated string as a list and returns new string - * + * * @param str * String with old values * @param value @@ -268,7 +268,7 @@ function addCSVValue(str, value) { /** * Treats comma separated string as a list and removes one item from it - * + * * @param str * String treated as a list * @param value @@ -288,7 +288,7 @@ function removeCSVValue(str, value) { /** * 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 @@ -312,7 +312,7 @@ function filterByRegexp(list, chosingMark) { /** * remove elements from the page based on their IDs - * + * * @param doc * Document object * @param target @@ -339,19 +339,19 @@ function killNodes(doc, target, remove) { /** * Remove duplicate elements from array - * + * * @param arr * Array which needs to be cleaned up * @return cleaned up array */ function removeDuplicates (arr) { for (var i = 0; i < arr.length; i++) { - for (var j = i + 1; j < arr.length; j++) { - if (arr[i] == arr[j]) { - arr.splice (j, 1); + for (var j = i + 1; j < arr.length; j++) { + if (arr[i] == arr[j]) { + arr.splice (j, 1); + } } } - } return arr; } @@ -361,12 +361,12 @@ function removeDuplicates (arr) { * Message("GetPassword", { login: login, hostname: location.hostname })); */ function Message(cmd, data) { - this.cmd = cmd; - this.data = data; + this.cmd = cmd; + this.data = data; } function log(msg) { - self.postMessage(new Message("LogMessage", msg)); + self.postMessage(new Message("LogMessage", msg)); } var NotLoggedinException = function NotLoggedinException (message) { diff --git a/data/rhlib/fixingAttMIME.js b/data/rhlib/fixingAttMIME.js index ada6974..9834cfa 100644 --- a/data/rhlib/fixingAttMIME.js +++ b/data/rhlib/fixingAttMIME.js @@ -1,11 +1,11 @@ -// Released under the MIT/X11 license -// http://www.opensource.org/licenses/mit-license.php +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php var reqCounter = 0; // TODO should be probably a dict indexed by called method /** * Callback function for the XMLRPC request - * + * * @param ret * Object with xmlhttprequest response with attributes: + status -- int * return code + statusText + responseHeaders + responseText @@ -22,7 +22,7 @@ function XMLRPCcallback() { /** * 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 @@ -30,19 +30,19 @@ function XMLRPCcallback() { * @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 to perform * MIME type change on. "mime_type" => "", # 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 }; - * + * */ function fixAttachById(id, XMLRPCURL, type, email) { if (type === undefined) { @@ -62,9 +62,9 @@ function fixAttachById(id, XMLRPCURL, type, email) { }; self.postMessage(new Message("MakeJSONRPCall", { - url : XMLRPCURL.replace("xmlrpc.cgi","jsonrpc.cgi"), + url : XMLRPCURL.replace("xmlrpc.cgi", "jsonrpc.cgi"), method : "bugzilla.updateAttachMimeType", - login: getLogin(), + login : getLogin(), params : params, callRPC : "FixAttachmentMIMECallback" })); @@ -73,7 +73,7 @@ function fixAttachById(id, XMLRPCURL, type, email) { /** * Add a link to the bad attachment for fixing it. - * + * * @param * DOM jQuery element with a bad attachment * @return none diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js index ba85319..2368696 100644 --- a/data/rhlib/rhbzpage.js +++ b/data/rhlib/rhbzpage.js @@ -3,8 +3,8 @@ // For identification of graphics card var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], - [ "ATI Mobility Radeon", "ATI", "1002" ], - [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ]; + [ "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 @@ -12,44 +12,44 @@ var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], var RHColor = new Color(158, 41, 43); // RGB 158, 41, 43; HSL 359, 1, 39 var FedoraColor = new Color(0, 40, 103); // RGB 0, 40, 103; HSL 359, 1, 39 var RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or - // HSL +// HSL // 120, 0, 23 var RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20 // [ 126.386] (--) NOUVEAU(0): Chipset: "NVIDIA NVaf" var logAnalyzeLogic = { - "AnalyzeInterestingLine": { - /* - * [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @ - * 0xd2000000/16777216, \ 0xc0000000/268435456, 0xd0000000/33554432, I/O @ - * 0x00001000/128, BIOS @ 0x????????/131072 - */ - re: [ - "^(\\[[ .0-9]+\\])?\\s*\\(--\\) PCI:\\*\\([0-9:]+\\)\\s*" + - "([0-9a-f:]+).*$", - "^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+ - "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$", - ], - func: chipsetMagic - }, - /* - * [ 126.385] (WW) Falling back to old probe method for vesa [ 126.385] (WW) - * Falling back to old probe method for fbdev [ 126.386] (--) NOUVEAU(0): - * Chipset: "NVIDIA NVaf" Backtrace: [ 33.158] Kernel command line: ro - * root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 - * SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04 - * - */ - "AnalyzeXorgLogBacktrace": { - re: "^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipset:.*)|\\s*(Backtrace|Kernel command line)", - func: analyzeXorg - } + "AnalyzeInterestingLine": { + /* + * [ 126.378] (--) PCI:*(0:4:0:0) 10de:08a0:106b:00c2 rev 162, Mem @ + * 0xd2000000/16777216, \ 0xc0000000/268435456, 0xd0000000/33554432, I/O @ + * 0x00001000/128, BIOS @ 0x????????/131072 + */ + re: [ + "^(\\[[ .0-9]+\\])?\\s*\\(--\\) PCI:\\*\\([0-9:]+\\)\\s*" + + "([0-9a-f:]+).*$", + "^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+ + "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$", + ], + func: chipsetMagic + }, + /* + * [ 126.385] (WW) Falling back to old probe method for vesa [ 126.385] (WW) + * Falling back to old probe method for fbdev [ 126.386] (--) NOUVEAU(0): + * Chipset: "NVIDIA NVaf" Backtrace: [ 33.158] Kernel command line: ro + * root=LABEL=root rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 + * SYSFONT=latarcyrheb-sun16 KEYTABLE=us drm.debug=0x04 + * + */ + "AnalyzeXorgLogBacktrace": { + re: "^\\s*(\\[[0-9 .]*\\])?\\s*(\\((EE|WW)\\)|.* [cC]hipset:.*)|\\s*(Backtrace|Kernel command line)", + func: analyzeXorg + } }; var ProfessionalProducts = [ - "Red Hat Enterprise Linux", - "Red Hat Enterprise MRG" -]; + "Red Hat Enterprise Linux", + "Red Hat Enterprise MRG" + ]; // END OF CONSTANTS @@ -77,7 +77,7 @@ function RHOnMessageHandler(msg) { break; default: console.error("Error: unknown RPC call " + msg.toSource()); - break; + break; } } @@ -133,16 +133,16 @@ function RHcentralCommandDispatch(cmdLabel, cmdParams) { case "chipMagic": fillInWhiteBoard(cmdParams); break; - // If we don't have it here, call superclass method + // If we don't have it here, call superclass method default: console.error("Unknown command:\n" + cmdLabel + "\nparameters:\n" + cmdParams); - break; + break; } } /** * Make it sailent that the some attachments with bad MIME type are present - * + * * @param atts * Array of attachments subarrays * @return none @@ -160,7 +160,7 @@ function markBadAttachments(atts) { if (badAttachments.length > 0) { var titleElement = document. - getElementsByClassName("bz_alias_short_desc_container")[0]; + getElementsByClassName("bz_alias_short_desc_container")[0]; titleElement.style.backgroundColor = "olive"; createDeadLink("fixAllButton", "Fix all", titleElement, function() { @@ -176,7 +176,7 @@ function markBadAttachments(atts) { /** * Open a tab in the upstream bugzilla to create a new bug - * + * * @return none */ function sendBugUpstream() { @@ -188,14 +188,14 @@ function sendBugUpstream() { self.postMessage(new Message("OpenBugUpstream", { url: urlStr, subject: document.getElementById("short_desc_nonedit_display"). - textContent.trim(), + textContent.trim(), comment: collectComments() })); } /** * Add a link opening selected lines of Xorg.0.log - * + * * @return none */ function addCheckXorgLogLink(attList) { @@ -212,14 +212,14 @@ function addCheckXorgLogLink(attList) { /** * Given line to be parsed, find out which chipset it is and fill in the * whiteboard - * + * * @param PCIidArrObj * object with two fields id Array manufacturer-ID and product-ID (PCI * IDs) chipsetLine whole line containing PCI ID. * @param driverStr * String with the driver name * @return None - * + * */ function fillInWhiteBoard(cardName) { console.myDebug("fillInWhiteBoard: cardName = " + cardName); @@ -233,7 +233,7 @@ function fillInWhiteBoard(cardName) { * 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. - * + * * @param log * array of XorgLogAttList * @return None @@ -244,7 +244,7 @@ function fillInChipMagic(XlogID) { /** * Creates a button to change summary by adding a graphic chip label - * + * * @param Array * with matching results of re.exec() */ @@ -261,12 +261,12 @@ function chipsetMagic (interestingLineArr) { // add to the button if (interestingLineArr.length > 1) { var PCIid = (interestingPCIID[0] + "," + interestingPCIID[1]). - toUpperCase(); + toUpperCase(); // Nvidia driver provides good code in the Chipset line if (interestingPCIID[0].toLowerCase() == "10de") { cardStr = interestingLineArr[1][2]. - replace(/\s*nvidia\s*/ig,""). - replace('"','','g'); + replace(/\s*nvidia\s*/ig,""). + replace('"','','g'); } else { try { cardStr = constantData.chipNames[PCIid][0]; @@ -305,17 +305,17 @@ function analyzeXorg(results) { innerString += lRE.input + "
\n"; }); innerString += "----------
\n" + - results.length + " interesting lines found."; + results.length + " interesting lines found."; } else { innerString += "No matching lines found!"; } self.postMessage(new Message("OpenStringInPanel", - '' + - "Xorg.0.log analysis
\n" +
-    innerString.trim() +
-    "\n
")); + '' + + "Xorg.0.log analysis
\n" +
+      innerString.trim() +
+  "\n
")); } function analyzeXorgLog(attachID, backMsg) { @@ -343,29 +343,29 @@ function findInterestingLine(wholeLog, backMsg) { var results = []; wholeLog.split("\n"). - forEach(function(line) { - REarr.forEach(function (re, reIdx) { - if (re.test(line)) { - console.myDebug("Found match on line:\n" + line); - console.myDebug("Result: " + re.exec(line).toSource()); - results.push(re.exec(line)); - } - }); + forEach(function(line) { + REarr.forEach(function (re, reIdx) { + if (re.test(line)) { + console.myDebug("Found match on line:\n" + line); + console.myDebug("Result: " + re.exec(line).toSource()); + results.push(re.exec(line)); + } }); + }); console.myDebug("results = " + results.toSource()); logAnalyzeLogic[backMsg].func(results); } /** * Add information about the upstream bug upstream, and closing it. - * + * * @param evt * Event which called this handler * @return none */ function addClosingUpstream() { var refs = document.getElementById("external_bugs_table") - .getElementsByTagName("tr"); + .getElementsByTagName("tr"); // that's a bad id, if there is a one. :) var inputBox = document.getElementById("inputbox"); @@ -373,8 +373,8 @@ function addClosingUpstream() { var wholeURL = ""; // Fix missing ID on the external_id SELECT - document.getElementsByName("external_id")[0].setAttribute("id", - "external_id"); + document.getElementsByName("external_id")[0].setAttribute("id", + "external_id"); if (inputBox.value.match(/^http.*/)) { externalBugID = getBugNoFromURL(inputBox.value); @@ -410,7 +410,7 @@ function addClosingUpstream() { } /** - * + * */ function parseBacktrace (ret) { var signalHandler = new RegExp("^\\s*#[0-9]*\\s*"); @@ -461,8 +461,8 @@ function RHBZinit(attachments) { markBadAttachments(attachments); var parsedAttachments = attachments.filter(function (att) { - return (new RegExp(titleParsedAttachment).test(att[0])); - }); + return (new RegExp(titleParsedAttachment).test(att[0])); + }); if (constantData.defaultAssignee) { setDefaultAssignee(); @@ -470,7 +470,7 @@ function RHBZinit(attachments) { if (constantData.xorgBugsCategories) { var XBZlist = filterByRegexp(constantData. - xorgBugsCategories, getComponent()); + xorgBugsCategories, getComponent()); if (XBZlist) { makeBugCategoriesList(XBZlist); } @@ -502,7 +502,7 @@ function RHBZinit(attachments) { // Uncheck "set default assignee" when the assignee is changed by other means document.getElementById("assigned_to").addEventListener("change", - function() { - changeAssignee(null); - }, false); + function() { + changeAssignee(null); + }, false); } diff --git a/data/rhlib/xorgBugCategories.js b/data/rhlib/xorgBugCategories.js index 3357ed7..31f2d37 100644 --- a/data/rhlib/xorgBugCategories.js +++ b/data/rhlib/xorgBugCategories.js @@ -4,12 +4,12 @@ /** * Returns true if the bug is in a good shape - * + * * @return Boolean if the bug is either not in the category where we care about * it (i.e., we don't have set up categories for this component) or if * it is in the concerned categories, then it has a category recorded in * the whiteboard input box. - * + * */ function hasXorgBugsCategory() { var catRE = /\s*\[cat:.*?\]\s*/; // RE for testing whether diff --git a/data/tweaks/addNewLinks.js b/data/tweaks/addNewLinks.js index 05d5ffb..5434b57 100644 --- a/data/tweaks/addNewLinks.js +++ b/data/tweaks/addNewLinks.js @@ -1,47 +1,47 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 +/******************************************************************************* + * ***** BEGIN LICENSE BLOCK Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * 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/ + * 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. + * 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 Bugzilla Tweaks. * - * The Initial Developer of the Original Code is Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. + * The Initial Developer of the Original Code is Mozilla Foundation. Portions + * created by the Initial Developer are Copyright (C) 2010 the Initial + * Developer. All Rights Reserved. * - * Contributor(s): - * Johnathan Nightingale - * Ehsan Akhgari + * Contributor(s): Johnathan Nightingale Ehsan Akhgari + * * * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. + * either the GNU General Public License Version 2 or later (the "GPL"), or the + * GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which + * case the provisions of the GPL or the LGPL are applicable instead of those + * above. If you wish to allow use of your version of this file only under the + * terms of either the GPL or the LGPL, and not to allow others to use your + * version of this file under the terms of the MPL, indicate your decision by + * deleting the provisions above and replace them with the notice and other + * provisions required by the GPL or the LGPL. If you do not delete the + * provisions above, a recipient may use your version of this file under the + * terms of any one of the MPL, the GPL or the LGPL. * - * ***** END LICENSE BLOCK ***** */ + * ***** END LICENSE BLOCK ***** + */ function addNewLinks() { var product = document .querySelector("#field_container_product option[selected]"); - var component = document.querySelector("#component option[selected]"); + var component = document + .querySelector("#component option[selected]"); if (product) { - var label = document.getElementById('field_container_product'); + var label = document + .getElementById('field_container_product'); var url = 'enter_bug.cgi?product=' + encodeURIComponent(product.value); if (label) { diff --git a/data/tweaks/bug-page-mod.js b/data/tweaks/bug-page-mod.js index 2b29dc0..f4b75aa 100644 --- a/data/tweaks/bug-page-mod.js +++ b/data/tweaks/bug-page-mod.js @@ -53,7 +53,9 @@ function TweakOnMessageHandler(msg, nextHandler) { /** * generate XML-RPC call to collect complete history of the bug - * @param XMLRPCURL URL of the XML-RPC gateway on the particular bugzilla + * + * @param XMLRPCURL + * URL of the XML-RPC gateway on the particular bugzilla * @returns nothing * * As part of the message is name of the signal "returnedHistory" @@ -172,116 +174,36 @@ function tweakBugzilla(atts, cData) { // =================================================== function processHistory(history) { // FIXME Remove remaining code to special function ... callback -// preprocessDuplicateMarkers(document, iframe.contentDocument); - -/* -This is an example of the history we get: -{ - "version": "1.1", - "result": { - "bugs": [ - { - "history": [ - { - "when": "2011-04-04T00:19:04Z", - "who": "cebbert@redhat.com", - "changes": [ - { - "removed": "", - "added": "xgl-maint@redhat.com", - "field_name": "cc", - "field": "CC" - }, - { - "removed": "kernel", - "added": "xorg-x11-drv-ati", - "field_name": "component", - "field": "Component" - }, - { - "removed": "kernel-maint@redhat.com", - "added": "xgl-maint@redhat.com", - "field_name": "assigned_to", - "field": "AssignedTo" - } - ] - }, - { - "when": "2011-04-12T22:48:22Z", - "who": "mcepl@redhat.com", - "changes": [ - { - "attachment_id": 488889, - "removed": "application/octet-stream", - "added": "text/plain", - "field_name": "attachments.mimetype", - "field": "Attachment mime type" - } - ] - }, - { - "when": "2011-04-13T17:07:04Z", - "who": "mcepl@redhat.com", - "changes": [ - { - "removed": "", - "added": "needinfo?(suckfish@ihug.co.nz)", - "field_name": "flagtypes.name", - "field": "Flags" - } - ] - }, - { - "when": "2011-04-21T12:17:33Z", - "who": "mcepl@redhat.com", - "changes": [ - { - "removed": "xgl-maint@redhat.com", - "added": "jglisse@redhat.com", - "field_name": "assigned_to", - "field": "AssignedTo" - } - ] - }, - { - "when": "2011-04-28T22:53:58Z", - "who": "mcepl@redhat.com", - "changes": [ - { - "attachment_id": 488889, - "removed": "text/plain", - "added": "application/octet-stream", - "field_name": "attachments.mimetype", - "field": "Attachment mime type" - } - ] - }, - { - "when": "2011-04-28T22:59:18Z", - "who": "mcepl@redhat.com", - "changes": [ - { - "attachment_id": 488889, - "removed": "application/octet-stream", - "added": "text/plain", - "field_name": "attachments.mimetype", - "field": "Attachment mime type" - } - ] - } - ], - "id": 692250, - "alias": [ - - ] - } - ], - "faults": [ - - ] - } -} - */ +// preprocessDuplicateMarkers(document, iframe.contentDocument); + + /* + * This is an example of the history we get: { "version": "1.1", "result": { + * "bugs": [ { "history": [ { "when": "2011-04-04T00:19:04Z", "who": + * "cebbert@redhat.com", "changes": [ { "removed": "", "added": + * "xgl-maint@redhat.com", "field_name": "cc", "field": "CC" }, { "removed": + * "kernel", "added": "xorg-x11-drv-ati", "field_name": "component", "field": + * "Component" }, { "removed": "kernel-maint@redhat.com", "added": + * "xgl-maint@redhat.com", "field_name": "assigned_to", "field": "AssignedTo" } ] }, { + * "when": "2011-04-12T22:48:22Z", "who": "mcepl@redhat.com", "changes": [ { + * "attachment_id": 488889, "removed": "application/octet-stream", "added": + * "text/plain", "field_name": "attachments.mimetype", "field": "Attachment + * mime type" } ] }, { "when": "2011-04-13T17:07:04Z", "who": + * "mcepl@redhat.com", "changes": [ { "removed": "", "added": + * "needinfo?(suckfish@ihug.co.nz)", "field_name": "flagtypes.name", "field": + * "Flags" } ] }, { "when": "2011-04-21T12:17:33Z", "who": "mcepl@redhat.com", + * "changes": [ { "removed": "xgl-maint@redhat.com", "added": + * "jglisse@redhat.com", "field_name": "assigned_to", "field": "AssignedTo" } ] }, { + * "when": "2011-04-28T22:53:58Z", "who": "mcepl@redhat.com", "changes": [ { + * "attachment_id": 488889, "removed": "text/plain", "added": + * "application/octet-stream", "field_name": "attachments.mimetype", "field": + * "Attachment mime type" } ] }, { "when": "2011-04-28T22:59:18Z", "who": + * "mcepl@redhat.com", "changes": [ { "attachment_id": 488889, "removed": + * "application/octet-stream", "added": "text/plain", "field_name": + * "attachments.mimetype", "field": "Attachment mime type" } ] } ], "id": + * 692250, "alias": [ + * ] } ], "faults": [ + * ] } } + */ // UserNameCache var userNameCache = {}; @@ -299,12 +221,13 @@ This is an example of the history we get: } if (history) { -// console.log("processHistory: history = " + history.toSource()); +// console.log("processHistory: history = " + history.toSource()); return ; } -// var historyItems = iframe.contentDocument.querySelectorAll('#bugzilla-body tr'); -// var cmtTimes = document.querySelectorAll('.bz_comment_time'); +// var historyItems = iframe.contentDocument.querySelectorAll('#bugzilla-body +// tr'); +// var cmtTimes = document.querySelectorAll('.bz_comment_time'); // Sometimes the history will stack several changes together, // and we'll want to append the data from the Nth item to the @@ -312,19 +235,19 @@ This is an example of the history we get: var i=0, j=0, flagsFound; if (history) { Array.forEach(history, function (item) { - processHistoryItem(cmtTimes, item); + processHistoryItem(cmtTimes, item); }); } - + handleEmptyCollapsedBoxes(document); -// // Set the latest flag links if necessary -// for (var flagName in flagOccurrences) { -// flags[flagName].innerHTML = '
' -// + flags[flagName].innerHTML + ''; -// } +// // Set the latest flag links if necessary +// for (var flagName in flagOccurrences) { +// flags[flagName].innerHTML = '' +// + flags[flagName].innerHTML + ''; +// } -// AttachmentFlagHandler.setupLinks(document); +// AttachmentFlagHandler.setupLinks(document); // END OF load event handler } diff --git a/data/tweaks/viewSource.js b/data/tweaks/viewSource.js index d2a9fd1..81e6735 100644 --- a/data/tweaks/viewSource.js +++ b/data/tweaks/viewSource.js @@ -38,9 +38,9 @@ var reAttachmentType = /,\s+([^ )]*)[;)]/; function viewAttachmentSource(attachments) { - attachments.forEach(function (att) { + attachments.forEach(function(att) { if (att.length < 1) { - return ; + return; } var typeName = att[2]; var elem = att[4]; @@ -56,14 +56,16 @@ function viewAttachmentSource(attachments) { // // https://bugzilla.mozilla.org/show_bug.cgi?id=369814#c5 has more // possible mime types for zips? - createDeadLink("viewSourceJAR_" + id, "JAR Contents", elem, - "jar:" + attachHref + "!/", [], "pipe", null, null); + createDeadLink("viewSourceJAR_" + id, "JAR Contents", + elem, "jar:" + attachHref + "!/", [], "pipe", null, + null); } else if (typeName == "application/zip" || typeName == "application/x-zip-compressed" || typeName == "application/x-xpinstall") { - createDeadLink("viewSourceZIP_" + id, "Static ZIP Contents", elem, - "jar:" + attachHref + "!/", [], "pipe", null, null); + createDeadLink("viewSourceZIP_" + id, + "Static ZIP Contents", elem, "jar:" + attachHref + + "!/", [], "pipe", null, null); } else if (typeName != "text/plain" && typeName != "patch" && // Other types that Gecko displays like text/plain @@ -77,8 +79,7 @@ function viewAttachmentSource(attachments) { typeName != "image/gif" && typeName != "image/png" && typeName != "image/jpeg") { createDeadLink("viewSourcePlain_" + id, "Source", elem, - "view-source:" + attachHref, [], "pipe", null, null); - } + "view-source:" + attachHref, [], "pipe", null, null); } - ) + }) } diff --git a/lib/cookiemanager.js b/lib/cookiemanager.js index b777ab9..6eac7f7 100644 --- a/lib/cookiemanager.js +++ b/lib/cookiemanager.js @@ -1,43 +1,41 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 +/******************************************************************************* + * ***** BEGIN LICENSE BLOCK Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * 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/ + * 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. + * 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 Bugzilla Tweaks. * - * The Initial Developer of the Original Code is Ehsan Akhgari. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. + * The Initial Developer of the Original Code is Ehsan Akhgari. Portions created + * by the Initial Developer are Copyright (C) 2010 the Initial Developer. All + * Rights Reserved. * - * Contributor(s): - * Ehsan Akhgari + * Contributor(s): Ehsan Akhgari * * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. + * either the GNU General Public License Version 2 or later (the "GPL"), or the + * GNU Lesser General Public License Version 2.1 or later (the "LGPL"), in which + * case the provisions of the GPL or the LGPL are applicable instead of those + * above. If you wish to allow use of your version of this file only under the + * terms of either the GPL or the LGPL, and not to allow others to use your + * version of this file under the terms of the MPL, indicate your decision by + * deleting the provisions above and replace them with the notice and other + * provisions required by the GPL or the LGPL. If you do not delete the + * provisions above, a recipient may use your version of this file under the + * terms of any one of the MPL, the GPL or the LGPL. * - * ***** END LICENSE BLOCK ***** */ + * ***** END LICENSE BLOCK ***** + */ exports.getHostCookies = function getHostCookies(host) { var {Cc, Ci} = require("chrome"); var cm = Cc["@mozilla.org/cookiemanager;1"]. - getService(Ci.nsICookieManager2); + getService(Ci.nsICookieManager2); var e = cm.getCookiesFromHost(host); var result = []; while (e.hasMoreElements()) { diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 0eba70b..de93531 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -1,6 +1,6 @@ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php -// + "use strict"; var preferences = require("preferences-service"); var prompts = require("prompts"); @@ -16,12 +16,12 @@ var xrpc = require("xmlrpc"); var panelMod = require("panel"); var JSONURLDefault = "https://fedorahosted.org/released"+ - "/bugzilla-triage-scripts/Config_data.json"; +"/bugzilla-triage-scripts/Config_data.json"; var BTSPrefNS = "bugzilla-triage.setting."; var BTSPassRealm = "BTSXMLRPCPass"; var copiedAttributes = [ "queryButton", "upstreamButton", "parseAbrtBacktraces", - "submitsLogging", "XorgLogAnalysis", "objectStyle", "signature", - "suspiciousComponents" ]; + "submitsLogging", "XorgLogAnalysis", "objectStyle", "signature", + "suspiciousComponents" ]; var passwords = {}; // hash of passwords indexed by a hostname @@ -30,12 +30,12 @@ var debugOption = false; function Message(cmd, data) { console.log("Message: cmd = " + cmd + ", data = " + data); - this.cmd = cmd; - this.data = data; + this.cmd = cmd; + this.data = data; } function log(msg) { - postMessage(new Message("LogMessage", msg)); + postMessage(new Message("LogMessage", msg)); } function debug(str) { @@ -57,7 +57,7 @@ function parseXMLfromString (inStuff) { // this.response // and get just .text property out of it. TODO var respStr = inStuff.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); // bug - // 336551 + // 336551 return new XML(respStr); } @@ -92,8 +92,8 @@ function getPassword(login, domain, callback) { var switchPrompt = "Do you want to switch off features requiring password completely"; var prefName = BTSPrefNS+"withoutPassowrd"; var retObject = { - password: null, // password string or null if no password provided - withoutPass: false // whether user doesn't want to use password at all + password: null, // password string or null if no password provided + withoutPass: false // whether user doesn't want to use password at all }; passUtils.search({ @@ -218,8 +218,8 @@ exports.getInstalledPackages = function getInstalledPackages(locationLoginObj, c // In order to avoid sending whole password to the content script, // we are sending just these two Booleans. config.constantData.passwordState = { - passAvailable: (passwObj.password !== null), - withoutPass: passwObj.withoutPass + passAvailable: (passwObj.password !== null), + withoutPass: passwObj.withoutPass }; callback(new Message("CreateButtons", { @@ -252,7 +252,7 @@ exports.getURL = function getURL(url, callback) { exports.openStringInNewPanel = function openStringInNewPanel(inHTMLStr) { openURLInNewPanel("data:text/html;charset=utf-8," + - inHTMLStr); + inHTMLStr); }; var openURLInNewPanel = exports.openURLInNewPanel = function openURLInNewPanel(url) { @@ -294,33 +294,33 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subject, comment) exports.makeXMLRPCCall = function makeXMLRPCCall(url, login, method, params, callback) { var urlObj = urlMod.URL(url); getPassword(login, - urlObj.scheme + "://" + urlObj.host, - function (passwObj) { - if (!passwObj.password) { - // TODO this should happen, only when user presses Escape in password - // prompt - return null; - } - - var msg = new xrpc.XMLRPCMessage(method); - params.forEach(function (par) { - msg.addParameter(par); - }); - msg.addParameter(login); - msg.addParameter(passwObj.password); - - Request({ - url: url, - onComplete: function(response) { - if (response.status == 200) { - var resp = parseXMLfromString(response.text); - callback(resp.toXMLString()); - } - }, - content: msg.xml(), - contentType: "text/xml" - }).post(); - } + urlObj.scheme + "://" + urlObj.host, + function (passwObj) { + if (!passwObj.password) { + // TODO this should happen, only when user presses Escape in password + // prompt + return null; + } + + var msg = new xrpc.XMLRPCMessage(method); + params.forEach(function (par) { + msg.addParameter(par); + }); + msg.addParameter(login); + msg.addParameter(passwObj.password); + + Request({ + url: url, + onComplete: function(response) { + if (response.status == 200) { + var resp = parseXMLfromString(response.text); + callback(resp.toXMLString()); + } + }, + content: msg.xml(), + contentType: "text/xml" + }).post(); + } ); }; @@ -328,21 +328,21 @@ exports.makeJSONRPCCallWithLogin = function makeJSONRPCCallWithLogin(url, method login, callback) { var urlObj = urlMod.URL(url); getPassword(login, - urlObj.scheme + "://" + urlObj.host, + urlObj.scheme + "://" + urlObj.host, function (passObj) { - if (!passObj.password) { - return; - } - - makeJSONRPCCall(url, "User.login", { - login: login, - password: passObj.password, - remember: false - }, function(logResult) { - console.log("logResult = " + logResult.toSource()); - makeJSONRPCCall(url, method, params, callback); - }); + if (!passObj.password) { + return; } + + makeJSONRPCCall(url, "User.login", { + login: login, + password: passObj.password, + remember: false + }, function(logResult) { + console.log("logResult = " + logResult.toSource()); + makeJSONRPCCall(url, method, params, callback); + }); + } ); }; @@ -351,28 +351,28 @@ exports.makeJSONRPCCallWithLogin = function makeJSONRPCCallWithLogin(url, method // http://json-rpc.org/wd/JSON-RPC-1-1-WD-20060807.html var makeJSONRPCCall = exports.makeJSONRPCCall = function makeJSONRPCCall(url, method, params, callback) { - var msg = { - "version": "1.1", - "method": method, - "params": params - }; + var msg = { + "version": "1.1", + "method": method, + "params": params + }; - debug("makeJSONRPCCall: out = " + JSON.stringify(msg)); + debug("makeJSONRPCCall: out = " + JSON.stringify(msg)); - Request({ - url: url, - onComplete: function(response) { - if (response.status == 200) { - debug("makeJSONRPCCall: in = " + response.text); - if ("error" in response.json) { + Request({ + url: url, + onComplete: function(response) { + if (response.status == 200) { + debug("makeJSONRPCCall: in = " + response.text); + if ("error" in response.json) { throw new Error("Error in JSON-RPC call:\n" + response.json.error); - } - callback(response.json.result); - } - }, - content: JSON.stringify(msg), - contentType: "application/json" - }).post(); + } + callback(response.json.result); + } + }, + content: JSON.stringify(msg), + contentType: "application/json" + }).post(); }; exports.initialize = function initialize(config, callback) { @@ -427,9 +427,9 @@ exports.initialize = function initialize(config, callback) { if ("constantData" in config.gJSONData) { config.constantData = config.gJSONData.constantData; config.constantData.queryUpstreamBug = JSON.parse( - selfMod.data.load("queryUpstreamBug.json")); + selfMod.data.load("queryUpstreamBug.json")); config.constantData.XMLRPCData = JSON.parse( - selfMod.data.load("XMLRPCdata.json")); + selfMod.data.load("XMLRPCdata.json")); config.constantData.bugzillaLabelNames = JSON.parse(selfMod.data.load("bugzillalabelNames.json")); config.constantData.newUpstreamBug = @@ -449,12 +449,12 @@ exports.initialize = function initialize(config, callback) { }); if ("submitsLogging" in config.gJSONData.configData && - config.gJSONData.configData.submitsLogging) { - logger.initialize(JSON.parse(selfMod.data.load( - "bugzillalabelAbbreviations.json"))); + config.gJSONData.configData.submitsLogging) { + logger.initialize(JSON.parse(selfMod.data.load( + "bugzillalabelAbbreviations.json"))); } - } - callback(); + } + callback(); } }).get(); } diff --git a/lib/main.js b/lib/main.js index 431ffe6..c857a08 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,14 +1,14 @@ -// Released under the MIT/X11 license -// http://www.opensource.org/licenses/mit-license.php -// -// Links to read through -// http://ehsanakhgari.org/blog/2010-01-07/bugzilla-tweaks-enhanced -// http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/tip/bugzillatweaks -// http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/ecfa0f028b81/bugzillatweaks/lib/main.js -// http://hg.mozilla.org/users/avarma_mozilla.com/atul-packages/file/42ac1e99a107/packages\ -// /facebook-acquaintances/lib/main.js#l11 -// http://ehsanakhgari.org/blog/2010-05-31/my-experience-jetpack-sdk#comment-1253 -// +//Released under the MIT/X11 license +//http://www.opensource.org/licenses/mit-license.php + +//Links to read through +//http://ehsanakhgari.org/blog/2010-01-07/bugzilla-tweaks-enhanced +//http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/tip/bugzillatweaks +//http://hg.mozilla.org/users/ehsan.akhgari_gmail.com/extensions/file/ecfa0f028b81/bugzillatweaks/lib/main.js +//http://hg.mozilla.org/users/avarma_mozilla.com/atul-packages/file/42ac1e99a107/packages\ +///facebook-acquaintances/lib/main.js#l11 +//http://ehsanakhgari.org/blog/2010-05-31/my-experience-jetpack-sdk#comment-1253 + "use strict"; var browser = require("tab-browser"); var self = require("self"); @@ -103,21 +103,20 @@ var messageHandler = exports.messageHandler = function messageHandler( // url, login, method, params, callback if (msg.data.login) { libbz - .makeJSONRPCCallWithLogin(msg.data.url, msg.data.method, - msg.data.params, msg.data.login, function(ret) { + .makeJSONRPCCallWithLogin(msg.data.url, + msg.data.method, msg.data.params, msg.data.login, + function(ret) { worker.postMessage(new Message(msg.data.callRPC, ret)); - } - ); + }); } else { libbz .makeJSONRPCCall(msg.data.url, msg.data.method, - msg.data.params, function(ret) { + msg.data.params, function(ret) { worker.postMessage(new Message(msg.data.callRPC, ret)); - } - ); + }); } break; case "GetURL": @@ -192,7 +191,7 @@ pageMod.PageMod({ contentScriptFile : self.data.url("lib/skip-bug.js") }); -// Allow toggling of CC event displays using a context menu entry +//Allow toggling of CC event displays using a context menu entry contextMenu.Item({ label : "Toggle CC History", contentScriptFile : [ diff --git a/lib/prompts.js b/lib/prompts.js index 3f34e0d..18edaaf 100644 --- a/lib/prompts.js +++ b/lib/prompts.js @@ -1,5 +1,5 @@ -/*global exports: false, require: false, console: false */ -/*jslint onevar: false */ +/* global exports: false, require: false, console: false */ +/* jslint onevar: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; @@ -11,7 +11,7 @@ var promptTitle = "Bugzilla Triage Script"; /** * shows the text in a simple window - * + * * @return none */ exports.alert = function alert(msg) { @@ -22,7 +22,7 @@ exports.alert = function alert(msg) { /** * general prompts for a string method - * + * * @return String with the password */ exports.prompt = function prompt(prompt, defaultValue) { @@ -44,7 +44,7 @@ exports.prompt = function prompt(prompt, defaultValue) { /** * returns password with a special password - * + * * @return String with the password */ exports.promptPassword = function promptPassword(prompt) { @@ -98,7 +98,7 @@ exports.promptYesNoCancel = function promptOKNoCancel(prompt) { }; /** - * + * * documentation is https://developer.mozilla.org/en/NsIFilePicker */ exports.promptFileOpenPicker = function promptFilePicker(win) { diff --git a/lib/util.js b/lib/util.js index 008d6fb..2a9bea3 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,5 +1,5 @@ -/*global exports: false, require: false, console: false, Cc: false, Ci: false */ -/*jslint onevar: false */ +/* global exports: false, require: false, console: false, Cc: false, Ci: false */ +/* jslint onevar: false */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; @@ -37,7 +37,7 @@ function getParamsFromURL(url, base) { /** * Get a bug no from URL ... fails with aliases It should theoretically belong * to bzpage.js, but we don't have unit tests there yet, so keeping here. - * + * * @param url * String with URL to be analyzed * @return String with the bug ID (hopefully number, but not for aliases) @@ -51,7 +51,7 @@ exports.getBugNo = function getBugNo(url) { /** * format date to be in ISO format (just day part) - * + * * @param date * @return string with the formatted date */ diff --git a/lib/xmlrpc.js b/lib/xmlrpc.js index 3991b04..c369e52 100644 --- a/lib/xmlrpc.js +++ b/lib/xmlrpc.js @@ -1,39 +1,39 @@ -/*global exports: false */ +/* global exports: false */ "use strict"; // Modification of Matěj Cepl released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php /* - * + * * xmlrpc.js beta version 1 Tool for creating XML-RPC formatted requests in * JavaScript - * + * * Copyright 2001 Scott Andrew LePera scott@scottandrew.com - * - * + * + * * 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. - * + * */ /** * checks whether parameter is an array - * + * * @param obj * Object * @return Boolean true if obj is array - * + * * The problem is that in different contexts, Array is not same, and so obj is * not an instance of SAME Array. */ /** * pads a single number with a leading zero. Heh. - * + * * @param n * String or Number * @return String with leading zero added if necessary - * + * * If the real parameter is not numerical, it is just returned as it is. */ var leadingZero = exports.leadingZero = function leadingZero(n) { diff --git a/tests/pagemod-test-helpers.js b/tests/pagemod-test-helpers.js index 9980715..aa01e96 100644 --- a/tests/pagemod-test-helpers.js +++ b/tests/pagemod-test-helpers.js @@ -7,28 +7,28 @@ const Ci = require("chrome").Ci; * checks the effect of the page mod on 'onload' event via testCallback. */ exports.testPageMod = function testPageMod(test, testURL, pageModOptions, - testCallback, timeout) { + testCallback, timeout) { var xulApp = require("xul-app"); if (!xulApp.versionInRange(xulApp.platformVersion, "1.9.3a3", "*") && - !xulApp.versionInRange(xulApp.platformVersion, "1.9.2.7", "1.9.2.*")) { - test.pass("Note: not testing PageMod, as it doesn't work on this platform version"); - return null; + !xulApp.versionInRange(xulApp.platformVersion, "1.9.2.7", "1.9.2.*")) { + test.pass("Note: not testing PageMod, as it doesn't work on this platform version"); + return null; } var wm = Cc['@mozilla.org/appshell/window-mediator;1'] - .getService(Ci.nsIWindowMediator); + .getService(Ci.nsIWindowMediator); var browserWindow = wm.getMostRecentWindow("navigator:browser"); if (!browserWindow) { - test.pass("page-mod tests: could not find the browser window, so " + - "will not run. Use -a firefox to run the pagemod tests."); - return null; + test.pass("page-mod tests: could not find the browser window, so " + + "will not run. Use -a firefox to run the pagemod tests."); + return null; } if (timeout !== undefined) { - test.waitUntilDone(timeout); + test.waitUntilDone(timeout); } else { - test.waitUntilDone(); + test.waitUntilDone(); } let loader = test.makeSandboxedLoader(); @@ -42,13 +42,13 @@ exports.testPageMod = function testPageMod(test, testURL, pageModOptions, var b = tabBrowser.getBrowserForTab(newTab); function onPageLoad() { - b.removeEventListener("load", onPageLoad, true); - testCallback(b.contentWindow.wrappedJSObject, function done() { - pageMods.forEach(function(mod) {mod.destroy()}); - // XXX leaks reported if we don't close the tab? - tabBrowser.removeTab(newTab); - test.done(); - }); + b.removeEventListener("load", onPageLoad, true); + testCallback(b.contentWindow.wrappedJSObject, function done() { + pageMods.forEach(function(mod) {mod.destroy()}); + // XXX leaks reported if we don't close the tab? + tabBrowser.removeTab(newTab); + test.done(); + }); } b.addEventListener("load", onPageLoad, true); diff --git a/tests/test-color.js b/tests/test-color.js index 95d3e16..730bac6 100644 --- a/tests/test-color.js +++ b/tests/test-color.js @@ -1,4 +1,4 @@ -/*global exports: false, require: false */ +/* global exports: false, require: false */ // TODO: add some failing tests as well "use strict"; // var util = require("color"); diff --git a/tests/test-pageMod.js b/tests/test-pageMod.js index 31cb3dd..02b7faf 100644 --- a/tests/test-pageMod.js +++ b/tests/test-pageMod.js @@ -28,21 +28,21 @@ exports.ensureMessagesWork = function(test) { }; /* - * + * * var theURL = main.theURL; var testURL = * self.data.url('tests/change-more-bugs01.html'); - * + * * var contentScriptLibraries = { "bugzilla.redhat.com": [ * self.data.url("util.js"), self.data.url("color.js"), * self.data.url("rhbzpage.js"), self.data.url("bzpage.js") ] }; - * + * * libbz.initialize(libbz.config, function () { pageMod.PageMod({ include: [ * "https://bugzilla.redhat.com/show_bug.cgi?id=*" ], contentScriptWhen: * 'ready', contentScriptFile: contentScriptLibraries["bugzilla.redhat.com"], * onAttach: function onAttach(worker, msg) { console.log("worker: " + worker); * worker.on('message', function (msg) { messageHandler(worker, msg); }); } }); * }); - * + * * pageMod.PageMod({ include: [ "https://bugzilla.redhat.com/process_bug.cgi" ], * contentScriptWhen: 'ready', contentScriptFile: self.data.url("skip-bug.js") * }); diff --git a/tests/test-util.js b/tests/test-util.js index 7ab6280..126436e 100644 --- a/tests/test-util.js +++ b/tests/test-util.js @@ -1,5 +1,5 @@ -/*global exports: false, require: false */ -/*jslint plusplus: false */ +/* global exports: false, require: false */ +/* jslint plusplus: false */ // TODO: add some failing tests as well "use strict"; var util = require("util"); diff --git a/tests/test-xmlrpc.js b/tests/test-xmlrpc.js index 78bf9d5..f9bbfa7 100644 --- a/tests/test-xmlrpc.js +++ b/tests/test-xmlrpc.js @@ -1,5 +1,5 @@ -/*global exports: false, require: false */ -/*jslint plusplus: false */ +/* global exports: false, require: false */ +/* jslint plusplus: false */ "use strict"; var xrpc = require("xmlrpc"); var xmlOut = "\n" -- cgit