diff options
author | Matěj Cepl <mcepl@redhat.com> | 2010-06-09 21:53:42 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2010-06-09 21:53:42 +0200 |
commit | 9b41b8867d5eb3f78b6260e8ee719c81579102c9 (patch) | |
tree | f3b2ee664b4de1c563e5a03f1becc748bbad12a0 | |
parent | e6c92c1ff7c2b465afd6076beabb692d9c3e4825 (diff) | |
download | bugzilla-triage-9b41b8867d5eb3f78b6260e8ee719c81579102c9.tar.gz |
* clean up to make jslint happy (abandoned let and replaced with var)
* cleaned up couple of crashes and missing stuff
-rw-r--r-- | jsons/RH_Data-packages.json | 4 | ||||
-rw-r--r-- | lib/bzpage.js | 162 | ||||
-rw-r--r-- | lib/logger.js | 1 | ||||
-rw-r--r-- | lib/main.js | 49 | ||||
-rw-r--r-- | lib/rhbzpage.js | 218 | ||||
-rw-r--r-- | package.json | 3 |
6 files changed, 225 insertions, 212 deletions
diff --git a/jsons/RH_Data-packages.json b/jsons/RH_Data-packages.json index b16a613..ad7d2b9 100644 --- a/jsons/RH_Data-packages.json +++ b/jsons/RH_Data-packages.json @@ -212,6 +212,10 @@ ], "PCIIDsURL": "http://mcepl.fedorapeople.org/scripts/drm_pciids.json", "objectStyle": "RH", + "matches": [ + "https://bugzilla.redhat.com/show_bug.cgi.*", + "https://bugzilla.mozilla.org/show_bug.cgi.*" + ], "signature": "" }, "constantData": { diff --git a/lib/bzpage.js b/lib/bzpage.js index 59790fb..79f6d64 100644 --- a/lib/bzpage.js +++ b/lib/bzpage.js @@ -5,6 +5,7 @@ "use strict"; var util = require("util"); var simpleStorage = require("simple-storage"); +var Color = require("color").Color; var TriagedDistro = 13; var NumberOfFrames = 7; @@ -14,7 +15,7 @@ var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id="; // ==================================================================================== // BZPage's methods -exports.BZPage = function BZPage(doc, config) { +var BZPage = exports.BZPage = function BZPage(doc, config) { // constants this.SalmonPink = new Color(255, 224, 176); // RGB 255, 224, 176; HSL 36, 2, // 85 @@ -22,6 +23,7 @@ exports.BZPage = function BZPage(doc, config) { // 83 // initialize dynamic properties this.doc = doc; + console.log("this.doc = " + this.doc); this.packages = this.getInstalledPackages(); if ("commentStrings" in config.gJSONData) { this.commentStrings = config.gJSONData.commentStrings; @@ -55,20 +57,20 @@ exports.BZPage = function BZPage(doc, config) { this.CCList = this.getCCList(); this.generateButtons(); -} +}; /** * */ BZPage.prototype.getInstalledPackages = function() { - let installedPackages = {}; + var installedPackages = {}; if (config.gJSONData && ("commentPackages" in config.gJSONData)) { - let enabledPackages = jetpack.storage.settings.enabledPacks.split(/[, ]/); - for each (let pkg in enabledPackages) { + var enabledPackages = jetpack.storage.settings.enabledPacks.split(/[, ]/); + enabledPackages.forEach(function (pkg, idx, arr) { if (pkg in config.gJSONData.commentPackages) { installedPackages[pkg] = config.gJSONData.commentPackages[pkg]; } - } + }); } return installedPackages; }; @@ -141,13 +143,13 @@ BZPage.prototype.centralCommandDispatch = function (cmdLabel, cmdParams) { break; case "removeBlocks": this.clickMouse("blocked_edit_action"); - this.removeStuffFromTextBox("blocked", cmdParams) + this.removeStuffFromTextBox("blocked", cmdParams); break; case "comment": this.addStuffToTextBox("comment", cmdParams); break; case "commentIdx": - let commentText = this.commentStrings[cmdParams]; + var commentText = this.commentStrings[cmdParams]; this.addStuffToTextBox("comment", commentText); break; case "setNeedinfo": @@ -178,10 +180,10 @@ BZPage.prototype.centralCommandDispatch = function (cmdLabel, cmdParams) { * this.centralCommandDispatch to execute them. */ BZPage.prototype.executeCommand = function(cmd) { - let [pkg, id] = cmd.split("//"); - let commentObj = this.packages[pkg][id]; + var cmdArr = cmd.split("//"); + var commentObj = this.packages[cmdArr[0]][cmdArr[1]]; - for (let key in commentObj) { + for (var key in commentObj) { this.centralCommandDispatch(key,commentObj[key]); } }; @@ -193,7 +195,7 @@ BZPage.prototype.executeCommand = function(cmd) { * @return none */ BZPage.prototype.changeAssignee = function(newAssignee) { - let defAssigneeButton = null; + var defAssigneeButton = null; this.addToCCList(this.owner); if (newAssignee === null) { this.doc.getElementById("set_default_assignee").removeAttribute( @@ -202,8 +204,8 @@ BZPage.prototype.changeAssignee = function(newAssignee) { } if (this.getDefaultAssignee) { - if (newAssignee == "default") { - let defAss = this.getDefaultAssignee(); + if (newAssignee === "default") { + var defAss = this.getDefaultAssignee(); if (defAss) { newAssignee = defAss; } else { @@ -216,8 +218,8 @@ BZPage.prototype.changeAssignee = function(newAssignee) { this.clickMouse("bz_assignee_edit_action"); this.doc.getElementById("assigned_to").value = newAssignee; this.doc.getElementById("set_default_assignee").checked = false; - if (defAssigneeButton = this.doc - .getElementById("setDefaultAssignee_btn")) { + defAssigneeButton = this.doc.getElementById("setDefaultAssignee_btn"); + if (defAssigneeButton) { defAssigneeButton.style.display = "none"; } } @@ -232,9 +234,9 @@ BZPage.prototype.changeAssignee = function(newAssignee) { * function will set up new one. */ BZPage.prototype.addToCommentsDropdown = function(pkg, cmd) { - let select = this.doc.getElementById("comment_action"); + var select = this.doc.getElementById("comment_action"); if (!select) { - let that = this; + var that = this; this.doc.getElementById("comments").innerHTML += "<div id='make_bugzilla_comment_action'>" + " <label for='comment_action'>Add Comment: </label>" + @@ -243,9 +245,10 @@ BZPage.prototype.addToCommentsDropdown = function(pkg, cmd) { "</div>"; select = this.doc.getElementById("comment_action"); select.addEventListener("change", function () { - let valueElement = that.doc.getElementById("comment_action"); + var value = ""; + var valueElement = that.doc.getElementById("comment_action"); if (valueElement) { - let value = valueElement.getAttribute("value"); + value = valueElement.getAttribute("value"); } else { return; } @@ -253,7 +256,7 @@ BZPage.prototype.addToCommentsDropdown = function(pkg, cmd) { }, false); } - let opt = that.doc.createElement("option"); + var opt = this.doc.createElement("option"); opt.value = pkg + "//" + cmd; opt.textContent = this.packages[pkg][cmd].name; select.appendChild(opt); @@ -270,10 +273,10 @@ BZPage.prototype.addToCommentsDropdown = function(pkg, cmd) { * @return none */ BZPage.prototype.createNewButton = function(location, after, pkg, id) { - let that = this; - let cmdObj = this.packages[pkg][id]; - let newId = id + "_btn"; - let label = cmdObj["name"]; + var that = this; + var cmdObj = this.packages[pkg][id]; + var newId = id + "_btn"; + var label = cmdObj.name; // protection against double-firings if (this.doc.getElementById(newId)) { @@ -283,12 +286,12 @@ BZPage.prototype.createNewButton = function(location, after, pkg, id) { // creation of button might be conditional on existence of data in constantData if ("ifExist" in cmdObj) { - if (!(cmdObj["ifExist"] in this.constantData)) { + if (!(cmdObj.ifExist in this.constantData)) { return ; } } - let newButton = this.doc.createElement("input"); + var newButton = this.doc.createElement("input"); newButton.setAttribute("id", newId); newButton.setAttribute("type", "button"); newButton.value = label; @@ -296,7 +299,7 @@ BZPage.prototype.createNewButton = function(location, after, pkg, id) { that.executeCommand(pkg + "//" + id); }, false); - let originalLocation = this.doc.getElementById(location); + var originalLocation = this.doc.getElementById(location); if (after) { originalLocation.parentNode.insertBefore(newButton, @@ -314,19 +317,19 @@ BZPage.prototype.createNewButton = function(location, after, pkg, id) { * */ BZPage.prototype.generateButtons = function() { - let topRowPosition = "topRowPositionID"; - let bottomRowPosition = "commit"; + var topRowPosition = "topRowPositionID"; + var bottomRowPosition = "commit"; // create anchor for the top toolbar - let commentBox = this.doc.getElementById("comment"); - let brElement = this.doc.createElement("br"); + var commentBox = this.doc.getElementById("comment"); + var brElement = this.doc.createElement("br"); brElement.setAttribute("id",topRowPosition); commentBox.parentNode.normalize(); commentBox.parentNode.insertBefore(brElement, commentBox); - for (let pkg in this.packages) { - for (let cmdIdx in this.packages[pkg]) { - let cmdObj = this.packages[pkg][cmdIdx]; + for (var pkg in this.packages) { + for (var cmdIdx in this.packages[pkg]) { + var cmdObj = this.packages[pkg][cmdIdx]; switch (cmdObj.position) { case "topRow": this.createNewButton(topRowPosition, false, pkg, cmdIdx); @@ -338,9 +341,9 @@ BZPage.prototype.generateButtons = function() { this.addToCommentsDropdown(pkg,cmdIdx); break; default: // [+-]ID - let firstChr = cmdObj.position.charAt(0); - let newId = cmdObj.position.substr(1); - this.createNewButton(newId, firstChr == "+", pkg, cmdIdx); + var firstChr = cmdObj.position.charAt(0); + var newId = cmdObj.position.substr(1); + this.createNewButton(newId, firstChr === "+", pkg, cmdIdx); break; } } @@ -364,8 +367,8 @@ BZPage.prototype.getReporter = function() { * @return string (integer for released Fedora, float for RHEL, rawhide) */ BZPage.prototype.getVersion = function() { - let verStr = this.getOptionValue("version").toLowerCase(); - let verNo = 0; + var verStr = this.getOptionValue("version").toLowerCase(); + var verNo = 0; if (/rawhide/.test(verStr)) { verNo = 999; } else { @@ -375,7 +378,7 @@ BZPage.prototype.getVersion = function() { }; BZPage.prototype.commentsWalker = function(fce) { - let comments = this.doc.getElementById("comments").getElementsByClassName( + var comments = this.doc.getElementById("comments").getElementsByClassName( "bz_comment"); Array.forEach(comments, function(item) { fce(item); @@ -387,9 +390,9 @@ BZPage.prototype.commentsWalker = function(fce) { * */ BZPage.prototype.checkComments = function() { - let that = this; + var that = this; this.commentsWalker(function(x) { - let email = x.getElementsByClassName("vcard")[0] + var email = x.getElementsByClassName("vcard")[0] .getElementsByTagName("a")[0].textContent; if (new RegExp(that.reporter).test(email)) { x.style.backgroundColor = that.ReporterColor.toString(); @@ -398,7 +401,7 @@ BZPage.prototype.checkComments = function() { }; BZPage.prototype.collectComments = function() { - let outStr = ""; + var outStr = ""; this.commentsWalker(function(x) { outStr += x.getElementsByTagName("pre")[0].textContent + "\n"; }); @@ -417,13 +420,13 @@ BZPage.prototype.collectComments = function() { * * FIXME bugzilla-comments version has this signature: * selectOption = function selectOption(select, value) { - let doc = select[0].ownerDocument; + var doc = select[0].ownerDocument; select.val(value); */ BZPage.prototype.selectOption = function(id, label) { - let sel = this.doc.getElementById(id); + var sel = this.doc.getElementById(id); sel.value = label; - let intEvent = this.doc.createEvent("HTMLEvents"); + var intEvent = this.doc.createEvent("HTMLEvents"); intEvent.initEvent("change", true, true); sel.dispatchEvent(intEvent); }; @@ -435,7 +438,7 @@ BZPage.prototype.selectOption = function(id, label) { * @return None */ BZPage.prototype.clickMouse = function(targetID) { - let localEvent = this.doc.createEvent("MouseEvents"); + var localEvent = this.doc.createEvent("MouseEvents"); localEvent.initMouseEvent("click", true, true, this.doc.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null); this.doc.getElementById(targetID).dispatchEvent(localEvent); @@ -450,7 +453,7 @@ BZPage.prototype.clickMouse = function(targetID) { * @return none */ BZPage.prototype.addStuffToTextBox = function(id, stuff) { - let textBox = this.doc.getElementById(id); + var textBox = this.doc.getElementById(id); if (textBox.tagName.toLowerCase() === "textarea") { stuff = textBox.value ? "\n\n" + stuff : stuff; textBox.value += stuff; @@ -466,9 +469,9 @@ BZPage.prototype.addStuffToTextBox = function(id, stuff) { * @param stuff String/Array with keyword(s) to be removed */ BZPage.prototype.removeStuffFromTextBox = function(id, stuff) { - let changedElement = this.getElementById(id); + var changedElement = this.getElementById(id); changedElement.value = util.removeCSVValue(changedElement.value,stuff); -} +}; /** * generalized hasKeyword ... search in the value of the box with given id @@ -478,13 +481,14 @@ BZPage.prototype.removeStuffFromTextBox = function(id, stuff) { * @return Boolean found? */ BZPage.prototype.idContainsWord = function(id, str) { + var kwd = ""; try { - var kwd = this.doc.getElementById(id).value; + kwd = this.doc.getElementById(id).value; } catch (e) { // For those who don't have particular element at all or if it is empty return false; } - return (kwd.trim().indexOf(str) != -1); + return (kwd.trim().indexOf(str) !== -1); }; /** @@ -502,7 +506,7 @@ BZPage.prototype.hasKeyword = function(str) { */ BZPage.prototype.getOptionValue = function(id) { // Some special bugs don't have version for example - let element = this.doc.getElementById(id); + var element = this.doc.getElementById(id); if (element) { return element.value; } else { @@ -528,11 +532,11 @@ BZPage.prototype.setNeedinfoReporter = function() { * */ BZPage.prototype.getOwner = function() { - let priorityParent = this.doc.querySelector("label[for~='target_milestone']") + var priorityParent = this.doc.querySelector("label[for~='target_milestone']") .parentNode.parentNode.parentNode; - let assigneeAElement = priorityParent.querySelector("tr:nth-of-type(1) a.email"); - let assgineeHref = decodeURI(assigneeAElement.getAttribute("href")); - let email = assgineeHref.split(":")[1]; + var assigneeAElement = priorityParent.querySelector("tr:nth-of-type(1) a.email"); + var assgineeHref = decodeURI(assigneeAElement.getAttribute("href")); + var email = assgineeHref.split(":")[1]; return email; }; @@ -542,9 +546,9 @@ BZPage.prototype.getOwner = function() { * @return String with the login name of the currently logged-in user */ BZPage.prototype.getLogin = function () { - let lastLIElement = this.doc.querySelector("#header ul.links li:last-of-type"); - let loginArr = lastLIElement.textContent.split("\n"); - let loginStr = loginArr[loginArr.length - 1].trim(); + var lastLIElement = this.doc.querySelector("#header ul.links li:last-of-type"); + var loginArr = lastLIElement.textContent.split("\n"); + var loginStr = loginArr[loginArr.length - 1].trim(); return loginStr; }; @@ -555,9 +559,9 @@ BZPage.prototype.getLogin = function () { * @return String with the maintainer's email address */ BZPage.prototype.getDefaultBugzillaMaintainer = function(component) { - let address = util.filterByRegexp(this.defBugzillaMaintainerArr, component); + var address = util.filterByRegexp(this.defBugzillaMaintainerArr, component); return address; -} +}; /** * collect the list of attachments in a structured format @@ -568,10 +572,10 @@ BZPage.prototype.getDefaultBugzillaMaintainer = function(component) { * element itself */ BZPage.prototype.getAttachments = function() { - let outAtts = []; - let atts = this.doc.getElementById("attachment_table") + var outAtts = []; + var atts = this.doc.getElementById("attachment_table") .getElementsByTagName("tr"); - for ( let i = 1, ii = atts.length - 1; i < ii; i++) { + for ( var i = 1, ii = atts.length - 1; i < ii; i++) { outAtts.push(this.parseAttachmentLine(atts[i])); } return outAtts; @@ -587,21 +591,21 @@ BZPage.prototype.getPassword = function() { if (jetpack.storage.settings.BZpassword) { return jetpack.storage.settings.BZpassword; } else { - let prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] + var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); - let password = { + var password = { value : "" }; // default the password to pass - let check = { + var check = { value : true }; // default the checkbox to true - let result = prompts.promptPassword(null, "Title", "Enter password:", + 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) { - let passwordText = password.value; + var passwordText = password.value; jetpack.storage.settings.BZpassword = passwordText; jetpack.storage.simple.sync(); return passwordText; @@ -615,8 +619,8 @@ BZPage.prototype.getPassword = function() { */ BZPage.prototype.setUpLogging = function() { // For adding additional buttons to the top toolbar - let additionalButtons = this.doc.querySelector("#bugzilla-body *.related_actions"); - let that = this; + var additionalButtons = this.doc.querySelector("#bugzilla-body *.related_actions"); + var that = this; // logging all submits for timesheet // FIXME we should merge in functionality of RHBugzillaPage.submitCallback @@ -626,7 +630,7 @@ BZPage.prototype.setUpLogging = function() { console.log("Installing submit callback!"); this.doc.forms.namedItem("changeform").addEventListener("submit",function (evt) { console.log("Submit callback!"); - let resp = that.log.addLogRecord(that); + var resp = that.log.addLogRecord(that); console.log("resp = " + resp); if (resp === null) { console.log("Avoiding submitting!"); @@ -638,7 +642,7 @@ BZPage.prototype.setUpLogging = function() { this.submitHandlerInstalled = true; } - let generateTimeSheetUI = this.doc.createElement("li"); + var generateTimeSheetUI = this.doc.createElement("li"); generateTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='#' id='generateTSButton'>" + "Generate timesheet</a>"; additionalButtons.appendChild(generateTimeSheetUI); @@ -651,11 +655,11 @@ BZPage.prototype.setUpLogging = function() { evt.preventDefault(); }, false); - let clearLogsUI = this.doc.createElement("li"); + var clearLogsUI = this.doc.createElement("li"); clearLogsUI.innerHTML = "\u00A0-\u00A0<a href='#' id='clearLogs'>" + "Clear logs</a>"; additionalButtons.appendChild(clearLogsUI); - let clearLogAElem = this.doc.getElementById("clearLogs"); + var clearLogAElem = this.doc.getElementById("clearLogs"); clearLogAElem.addEventListener("click", function() { that.log.store = {}; jetpack.storage.simple.sync(); @@ -688,7 +692,7 @@ BZPage.prototype.addToCCList = function(who) { if (!who) { return ; } - if (who == "self") { + if (who === "self") { this.doc.getElementById("addselfcc").checked = true; } else { this.clickMouse("cc_edit_area_showhide"); @@ -704,7 +708,7 @@ BZPage.prototype.addToCCList = function(who) { * @return Array with email addresses as Strings. */ BZPage.prototype.getCCList = function() { - let CCListSelect = this.doc.getElementById("cc"); + var CCListSelect = this.doc.getElementById("cc"); outCCList = []; if (CCListSelect) { outCCList = Array.map(CCListSelect.options, function(item) { diff --git a/lib/logger.js b/lib/logger.js index 6bd8142..702465a 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -3,6 +3,7 @@ "use strict"; var urlMod = require("url"); var urilMod = require("util"); +var Color = require("color").Color; var Logger = exports.Logger = function Logger(store, abbsMap) { this.EmptyLogsColor = new Color(0, 255, 0); diff --git a/lib/main.js b/lib/main.js index 1027d72..3364971 100644 --- a/lib/main.js +++ b/lib/main.js @@ -21,21 +21,18 @@ const JSONURL = "http://matej.ceplovi.cz/progs/data/RH_Data-packages.json"; var myStorage = require("simple-storage"); var config = {}; -config.matches = [ - "https://bugzilla.redhat.com/show_bug.cgi", - "https://bugzilla.mozilla.org/show_bug.cgi" -]; function initialize(callback) { util.loadJSON(JSONURL, function(parsedData) { config.gJSONData = parsedData; - // Get card translation table + var keys = "", key = ""; for (key in config.gJSONData) { keys += key + " "; } console.log("loaded JSON object keys: " + keys); + // Get card translation table if ("PCIIDsURL" in config.gJSONData.configData) { util.loadJSON(config.gJSONData.configData.PCIIDsURL, function(response) { config.PCI_ID_Array = response; @@ -50,37 +47,39 @@ function initialize(callback) { } -function isOurPage(window, bugzillaPageModLocation) { +// TODO: sometime in the future we should include +// also skip-process.js functionality and these URLs +// "https://bugzilla.redhat.com/process_bug.cgi", +// "https://bugzilla.redhat.com/post_bug.cgi", +// "https://bugzilla.mozilla.org/post_bug.cgi", +// "https://bugzilla.mozilla.org/process_bug.cgi" +function isOurPage(window, matchingURLs) { if ("window" in window) { window = window.window; } + var url = window.location.href; - if (window.location.protocol == "https:") { - // like ["name1": "url1", "name2":"url2"] - // FIXME the real name of bugzillaPageModLocation array - for (var loc in bugzillaPageModLocation) { - if (bugzillaPageModLocation[loc].test(window.location.href)) { - return true; - } - } - } - // we haven't found a conforming bugzilla - return false; + // like ["regexp-url1", "regexp-url2"] + return matchingURLs.some(function (element,i,a) { + return new RegExp(element).test(url); + }); } exports.main = function main(options, callbacks) { initialize(function (config) { browser.whenContentLoaded( function(window) { - if (isOurPage(window)) { + var doc = window.document; + if (isOurPage(window, config.gJSONData.configData.matches)) { + console.log("dump config:\n" + config); var curPage = {}; - var mycallback = function(doc) { - if (config.gJSONData.configData.objectStyle = "RH") { - curPage = new require("rhbzpage").RHBugzillaPage(doc, config); - } else if (config.gJSONData.configData.objectStyle = "MoFo") { - curPage = new require("mozillabzpage").MozillaBugzilla(doc, config); - } - }; + if (config.gJSONData.configData.objectStyle = "RH") { + curPage = new require("rhbzpage").RHBugzillaPage(doc, config); + } else if (config.gJSONData.configData.objectStyle = "MoFo") { + curPage = new require("mozillabzpage").MozillaBugzilla(doc, config); + } + } else { + console.log("Not our page: " + window.location.href); } }); }); diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js index 2370e72..f2e7c22 100644 --- a/lib/rhbzpage.js +++ b/lib/rhbzpage.js @@ -7,6 +7,8 @@ var util = require("util"); var xrpc = require("xmlrpc"); var xhr = require("xhr"); var clip = require("clipboard"); +var Color = require("color").Color; +var BZPage = require("bzpage").BZPage; // var TriagedDistro = 13; // var NumberOfFrames = 7; // var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; @@ -15,9 +17,9 @@ var clip = require("clipboard"); // ==================================================================================== // RHBugzillaPage object -exports.RHBugzillaPage = function RHBugzillaPage(doc, config) { +var RHBugzillaPage = exports.RHBugzillaPage = function RHBugzillaPage(doc, config) { // For identification of graphics card - const manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], + var manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], [ "ATI Mobility Radeon", "ATI", "1002" ], [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ]; @@ -48,18 +50,22 @@ exports.RHBugzillaPage = function RHBugzillaPage(doc, config) { // Prepare for query buttons // FIXME getting null for commentArea sometimes - let commentArea = doc.getElementById("comment_status_commit"); + var commentArea = doc.getElementById("comment_status_commit"); if (commentArea) { - let brElementPlacer = commentArea.getElementsByTagName("br")[0]; - brElementPlacer.setAttribute("id","brElementPlacer_location"); - brElementPlacer.parentNode.insertBefore(doc.createElement("br"), - brElementPlacer); + var brElementPlacer = commentArea.getElementsByTagName("br"); + console.log("brElementPlacer.length = " + brElementPlacer.length); + brElementPlacer = brElementPlacer[0]; + if (brElementPlacer) { + brElementPlacer.setAttribute("id","brElementPlacer_location"); + brElementPlacer.parentNode.insertBefore(doc.createElement("br"), + brElementPlacer); + } } // inheritance ... call superobject's constructor BZPage.call(this,doc, config); - let that = this; + var that = this; this.reqCounter = 0; this.signaturesCounter = 0; this.chipMagicInterestingLine = ""; @@ -67,7 +73,7 @@ exports.RHBugzillaPage = function RHBugzillaPage(doc, config) { this.login = this.getLogin(); this.password = this.getPassword(); - let ITbutton = this.doc.getElementById("cf_issuetracker"); + var ITbutton = this.doc.getElementById("cf_issuetracker"); this.its = ITbutton ? ITbutton.value.trim() : ""; // set default assignee on change of the component @@ -87,14 +93,14 @@ exports.RHBugzillaPage = function RHBugzillaPage(doc, config) { // Dig out backtrace this.btSnippet = ""; - let parseAbrtBacktraces = config.gJSONData.configData.parseAbrtBacktraces; + var parseAbrtBacktraces = config.gJSONData.configData.parseAbrtBacktraces; if (parseAbrtBacktraces && this.RE.Abrt.test(this.title)) { this.pasteBacktraceInComments(); } // Take care of signature for Fedora bugzappers if (config.gJSONData.configData.signature.length > 0) { - let signatureFedoraString = config.gJSONData.configData.signature; + var signatureFedoraString = config.gJSONData.configData.signature; this.doc.forms.namedItem("changeform").addEventListener("submit", function() { if (this.signaturesCounter < 1) { @@ -112,12 +118,12 @@ exports.RHBugzillaPage = function RHBugzillaPage(doc, config) { && (config.PCI_ID_Array.length > 0)) && this.maintCCAddr === "xgl-maint@redhat.com") { // Add find chip magic button - let whiteboard_string = this.doc.getElementById("status_whiteboard").value; + var whiteboard_string = this.doc.getElementById("status_whiteboard").value; if (!/card_/.test(whiteboard_string)) { this.fillInChipMagic(); } } -} // END OF RHBugzillaPage CONSTRUCTOR +}; // END OF RHBugzillaPage CONSTRUCTOR RHBugzillaPage.prototype = util.heir(BZPage); RHBugzillaPage.prototype.constructor = RHBugzillaPage; @@ -131,7 +137,7 @@ RHBugzillaPage.prototype.constructor = RHBugzillaPage; RHBugzillaPage.prototype.getDefaultAssignee = function() { return util.filterByRegexp(this.constantData.defaultAssignee, this.component).toLowerCase(); -} +}; /** * Set default assignee @@ -141,7 +147,7 @@ RHBugzillaPage.prototype.getDefaultAssignee = function() { */ RHBugzillaPage.prototype.setDefaultAssignee = function() { this.defaultAssignee = this.getDefaultAssignee(); - let defAss = this.defaultAssignee; + var defAss = this.defaultAssignee; // Add setting default assignee if ((defAss.length > 0) && (defAss !== this.getOwner())) { @@ -159,10 +165,10 @@ RHBugzillaPage.prototype.closeSomeRelease = function() { // and put the release version to // "Fixed in Version" textbox // otherwise -> NEXTRELEASE - let verNo = this.getVersion(); + var verNo = this.getVersion(); this.selectOption("bug_status", "CLOSED"); - let text = ""; - let resolution = ""; + var text = ""; + var resolution = ""; if (jetpack.selection.text) { text = jetpack.select.text.trim(); @@ -204,7 +210,7 @@ RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams) this.markBugTriaged(); break; case "chipMagic": - let splitArr = cmdParams.split("\t"); + var splitArr = cmdParams.split("\t"); this.fillInWhiteBoard(splitArr[0], splitArr[1]); break; // If we don't have it here, call superclass method @@ -228,19 +234,19 @@ RHBugzillaPage.prototype.ProfessionalProducts = [ RHBugzillaPage.prototype.pasteBacktraceInComments = function() { // FIXME This paragraph looks suspicous ... what is it? // Does it belong to this function? - let notedLabel = this.doc.querySelector("label[for='newcc']"); + var notedLabel = this.doc.querySelector("label[for='newcc']"); while (notedLabel.firstChild) { - let node = notedLabel.removeChild(notedLabel.firstChild); + var node = notedLabel.removeChild(notedLabel.firstChild); notedLabel.parentNode.insertBefore(node, notedLabel); } notedLabel.parentNode.removeChild(notedLabel); - let abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?" + var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?" + "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&sharer_id=74116"; - let mainTitle = this.doc + var mainTitle = this.doc .getElementsByClassName("bz_alias_short_desc_container")[0]; - let abrtButton = this.doc.createElement("a"); + var abrtButton = this.doc.createElement("a"); abrtButton.setAttribute("accesskey", "a"); abrtButton.setAttribute("href", abrtQueryURL); abrtButton.textContent = "Abrt bugs"; @@ -252,7 +258,7 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() { if (!(this.isTriaged() || this.idContainsWord("status_whiteboard", 'btparsed'))) { - let btAttachments = this.attachments + var btAttachments = this.attachments .filter(function(att, idx, arr) { return (/backtrace/.test(att[0])); }); @@ -263,7 +269,7 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() { attURL = "https://bugzilla.redhat.com/attachment.cgi?id=" + x[1]; if (!this.btSnippet) { - let btRaw = util.loadText(attURL, function(ret) { + var btRaw = util.loadText(attURL, function(ret) { this.btSnippet = this.parseBacktrace(ret); if (this.btSnippet) { this.addStuffToTextBox("comment", this.btSnippet); @@ -280,14 +286,14 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() { * */ RHBugzillaPage.prototype.markBadAttachments = function() { - let badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ]; + var badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ]; - let badAttachments = this.attachments.filter(function(att, idx, arr) { + var badAttachments = this.attachments.filter(function(att, idx, arr) { return (util.isInList(att[2], badMIMEArray)); }); if (badAttachments.length > 0) { - let titleElement = this.doc + var titleElement = this.doc .getElementsByClassName("bz_alias_short_desc_container")[0]; titleElement.style.backgroundColor = "olive"; titleElement.appendChild(this.createFixAllButton(badAttachments)); @@ -303,8 +309,8 @@ RHBugzillaPage.prototype.markBadAttachments = function() { * @return Boolean true if it is a RHEL bug */ RHBugzillaPage.prototype.isEnterprise = function() { - let prod = this.product; - let result = this.ProfessionalProducts.some(function(elem,idx,arr) { + var prod = this.product; + var result = this.ProfessionalProducts.some(function(elem,idx,arr) { return new RegExp(elem).test(prod); }); return result; @@ -333,8 +339,8 @@ RHBugzillaPage.prototype.isTriaged = function() { * @return none */ RHBugzillaPage.prototype.setBranding = function() { - let brandColor = {}; - let TriagedColor = {}; + var brandColor = {}; + var TriagedColor = {}; if (this.isEnterprise()) { console.log("This is an enterprise bug."); @@ -345,7 +351,7 @@ RHBugzillaPage.prototype.setBranding = function() { } } else if (new RegExp("Fedora").test(this.product)) { console.log("This is NOT an enterprise bug."); - if (this.version == 999) { + if (this.version === 999) { brandColor = this.RawhideColor; } else { brandColor = this.FedoraColor; @@ -361,11 +367,11 @@ RHBugzillaPage.prototype.setBranding = function() { // Remove "Bug" from the title of the bug page, so we have more space with // plenty of tabs - let titleElem = this.doc.getElementsByTagName("title")[0]; + var titleElem = this.doc.getElementsByTagName("title")[0]; titleElem.textContent = titleElem.textContent.slice(4); - let bodyTitleParent = this.doc.getElementById("summary_alias_container").parentNode; - let bodyTitleElem = bodyTitleParent.getElementsByTagName("b")[0]; + var bodyTitleParent = this.doc.getElementById("summary_alias_container").parentNode; + var bodyTitleElem = bodyTitleParent.getElementsByTagName("b")[0]; bodyTitleElem.textContent = bodyTitleElem.textContent.slice(4); // Make background-color of the body of bug salmon pink @@ -384,7 +390,7 @@ RHBugzillaPage.prototype.setBranding = function() { // we should make visible whether maintCCAddr is in CCList if (util.isInList(this.maintCCAddr, this.CCList)) { - let ccEditBoxElem = this.doc.getElementById("cc_edit_area_showhide"); + var ccEditBoxElem = this.doc.getElementById("cc_edit_area_showhide"); // ccEditBoxElem.textContent = "*"+ccEditBoxElem.textContent; ccEditBoxElem.style.color = "navy"; ccEditBoxElem.style.fontWeight = "bolder"; @@ -392,8 +398,8 @@ RHBugzillaPage.prototype.setBranding = function() { } // mark suspicious components - let compElems; - let suspiciousComponents = config.gJSONData.configData.suspiciousComponents; + var compElems; + var suspiciousComponents = config.gJSONData.configData.suspiciousComponents; if (suspiciousComponents && util.isInList(this.component, suspiciousComponents) && (compElems = this.doc @@ -411,16 +417,15 @@ RHBugzillaPage.prototype.setBranding = function() { * @return None */ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { - let that = this; + var that = this; function groupIDs(manStr, cardStrID) { - let outStr = util.filterByRegexp(chipIDsGroupings, manStr + "," + cardStrID); + var outStr = util.filterByRegexp(chipIDsGroupings, manStr + "," + cardStrID); if (outStr.length === 0) { outStr = "UNGROUPED_" + manStr + "/" + cardStrID; } return outStr; } - ; /** * Given PCI IDs for manufacturer and card ID return chipset string @@ -430,22 +435,21 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { * @return Array with chip string and optinoal variants */ function checkChipStringFromID(manufacturerNo, cardNo) { - let soughtID = (manufacturerNo + "," + cardNo).toUpperCase(); - let outList = config.PCI_ID_Array[soughtID]; + var soughtID = (manufacturerNo + "," + cardNo).toUpperCase(); + var outList = config.PCI_ID_Array[soughtID]; if (outList) { return outList; } else { return ""; } } - ; - let outStr = ""; - let cardIDStr = ""; - let cardIDArr = []; + var outStr = ""; + var cardIDStr = ""; + var cardIDArr = []; chipSwitchboard: if (driverStr === "RADEON") { - let cardID = iLine.replace(this.RE.ATIgetID, "$1"); + var cardID = iLine.replace(this.RE.ATIgetID, "$1"); cardIDArr = checkChipStringFromID("1002", cardID); if (cardIDArr.length > 0) { cardIDStr = cardIDArr[0]; @@ -492,12 +496,12 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) { * @return None */ RHBugzillaPage.prototype.fillInChipMagic = function () { - let that = this; - let XorgLogURL = ""; - let XorgLogAttID = ""; - let XorgLogFound = false; - let attURL = "", interestingLine = ""; - let interestingArray = []; + var that = this; + var XorgLogURL = ""; + var XorgLogAttID = ""; + var XorgLogFound = false; + var attURL = "", interestingLine = ""; + var interestingArray = []; // Find out Xorg.0.log attachment URL @@ -515,7 +519,7 @@ RHBugzillaPage.prototype.fillInChipMagic = function () { // parse Xorg.0.log util.loadText(attURL, function(ret){ - let interestingLineArr = ret.split("\n"). + var interestingLineArr = ret.split("\n"). filter(function (v,i,a) { return that.RE.Chipset.test(v); }); @@ -549,7 +553,7 @@ RHBugzillaPage.prototype.queryInNewTab = function(text, component, product) { console.log("queryInNewTab / text = " + text); console.log("queryInNewTab / component = " + component); console.log("queryInNewTab / product = " + product); - let url = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced"; + var url = "https://bugzilla.redhat.com/buglist.cgi?query_format=advanced"; if (product) { url += "&product=" + product.trim(); } @@ -562,7 +566,7 @@ RHBugzillaPage.prototype.queryInNewTab = function(text, component, product) { // for further investigative searches if (text) { text = encodeURIComponent(text.trim()); - let searchText = "&field1-0-0=longdesc&type1-0-0=substring&value1-0-0=" + var searchText = "&field1-0-0=longdesc&type1-0-0=substring&value1-0-0=" + text + "&field1-0-1=attach_data.thedata&type1-0-1=substring&value1-0-1=" + text @@ -588,7 +592,7 @@ RHBugzillaPage.prototype.queryInNewTab = function(text, component, product) { * function this.queryInNewTab, and run it. */ RHBugzillaPage.prototype.queryForSelection = function() { - let text = jetpack.selection.text; + var text = jetpack.selection.text; console.log("selection = " + text); if (!text) { text = clip.get(); @@ -605,31 +609,31 @@ RHBugzillaPage.prototype.queryForSelection = function() { */ RHBugzillaPage.prototype.queryUpstream = function() { console.log("Querying upstream!"); - let text = jetpack.selection.text; + var text = jetpack.selection.text; console.log("Selection = |" + text + "|"); if (!text) { text = clip.get(); } if (text) { - let text = encodeURIComponent(text.trim()); - let queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug; - let url = util.filterByRegexp(queryUpstreamBugsURLArray, this.component); + text = encodeURIComponent(text.trim()); + var queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug; + var url = util.filterByRegexp(queryUpstreamBugsURLArray, this.component); jetpack.tabs.open(url + text); } -} +}; /** * */ RHBugzillaPage.prototype.sendBugUpstream = function() { - let url = util.filterByRegexp(this.constantData.newUpstreamBug, this + var url = util.filterByRegexp(this.constantData.newUpstreamBug, this .getOptionValue("component")); - let ret = jetpack.tabs.open(url); - let that = this; + var ret = jetpack.tabs.open(url); + var that = this; jetpack.tabs.onReady(function() { - let otherDoc = ret.contentDocument; - let otherElems = otherDoc.forms.namedItem("Create").elements; + var otherDoc = ret.contentDocument; + var otherElems = otherDoc.forms.namedItem("Create").elements; otherElems.namedItem("short_desc").value = that.doc .getElementById("short_desc_nonedit_display").textContent .trim(); @@ -647,8 +651,8 @@ RHBugzillaPage.prototype.sendBugUpstream = function() { * element itself */ RHBugzillaPage.prototype.parseAttachmentLine = function(inElem) { - let MIMEtype = ""; - let size = 0; + var MIMEtype = ""; + var size = 0; // Skip over obsolete attachments if (inElem.getElementsByClassName("bz_obsolete").length > 0) { @@ -656,17 +660,17 @@ RHBugzillaPage.prototype.parseAttachmentLine = function(inElem) { } // getting name of the attachment - let attName = inElem.getElementsByTagName("b")[0].textContent.trim(); + var attName = inElem.getElementsByTagName("b")[0].textContent.trim(); - let aHrefsArr = inElem.getElementsByTagName("a"); - let aHref = Array.filter(aHrefsArr, function(x) { - return x.textContent.trim() == "Details"; + var aHrefsArr = inElem.getElementsByTagName("a"); + var aHref = Array.filter(aHrefsArr, function(x) { + return x.textContent.trim() === "Details"; })[0]; - let id = parseInt(aHref.getAttribute("href").replace( + var id = parseInt(aHref.getAttribute("href").replace( /^.*attachment.cgi\?id=/, ""), 10); // getting MIME type and size - let stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent + var stringArray = inElem.getElementsByClassName("bz_attach_extra_info")[0].textContent .replace(/[\n ()]+/g, " ").trim().split(", "); size = parseInt(stringArray[0], 10); MIMEtype = stringArray[1].split(" ")[0]; @@ -696,7 +700,7 @@ RHBugzillaPage.prototype.fixElement = function(elem, beforeText, accKey, afterTe * @return String with the string for the external_id SELECT */ RHBugzillaPage.prototype.getBugzillaName = function(URLhostname) { - let bugzillaID = ""; + var bugzillaID = ""; if (this.constantData.bugzillalabelNames[URLhostname]) { bugzillaID = this.constantData.bugzillalabelNames[URLhostname]; } else { @@ -715,7 +719,7 @@ RHBugzillaPage.prototype.getBugzillaName = function(URLhostname) { * + responseText */ RHBugzillaPage.prototype.fixingMIMECallBack = function(data, textStatus) { - let that = this; + var that = this; if (--this.reqCounter <= 0) { setTimeout(function () { that.doc.location.reload(true); @@ -753,7 +757,7 @@ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) { email = false; } - let msg = new xrpc.XMLRPCMessage("bugzilla.updateAttachMimeType"); + var msg = new xrpc.XMLRPCMessage("bugzilla.updateAttachMimeType"); msg.addParameter( { 'attach_id' : id, 'mime_type' : type, @@ -762,14 +766,14 @@ RHBugzillaPage.prototype.fixAttachById = function(id, type, email) { msg.addParameter(this.login); msg.addParameter(this.password); - let req = new XMLHttpRequest(); - let that = this; + var req = new XMLHttpRequest(); + var that = this; req.open("POST", XMLRPCurl, true); req.overrideMimeType("text/xml"); req.setRequestHeader("Content-type", "text/xml"); req.onreadystatechange = function(aEvt) { - if (req.readyState == 4) { - if (req.status == 200) { + if (req.readyState === 4) { + if (req.status === 200) { console.log("Fixing attachment MIME type success!"); that.fixingMIMECallBack(); } else { @@ -791,8 +795,8 @@ RHBugzillaPage.prototype.createFixAllButton = function(list) { if (!XMLRPCMessage) { return; } - let that = this; - let elem = this.doc.createElement("a"); + var that = this; + var elem = this.doc.createElement("a"); elem.setAttribute("href", ""); elem.setAttribute("accesskey", "f"); elem.innerHTML = "<b>F</b>ix all"; @@ -812,9 +816,9 @@ RHBugzillaPage.prototype.createFixAllButton = function(list) { * @return none */ RHBugzillaPage.prototype.addTextLink = function(row) { - let that = this; - let elemS = row[4].getElementsByTagName("td"); - let elem = elemS[elemS.length - 1]; + var that = this; + var elemS = row[4].getElementsByTagName("td"); + var elem = elemS[elemS.length - 1]; elem.innerHTML += "<br/><a href=''>Text</a>"; elem.addEventListener("click", function(x) { that.fixAttachById(row[1], "text/plain"); @@ -828,24 +832,24 @@ RHBugzillaPage.prototype.addTextLink = function(row) { * @return none */ RHBugzillaPage.prototype.addClosingUpstream = function() { - let refs = this.doc.getElementById("external_bugs_table") + var refs = this.doc.getElementById("external_bugs_table") .getElementsByTagName("tr"); // that's a bad id, if there is a one. :) - let inputBox = this.doc.getElementById("inputbox"); - let externalBugID = 0; - let wholeURL = ""; + var inputBox = this.doc.getElementById("inputbox"); + var externalBugID = 0; + var wholeURL = ""; // Fix missing ID on the external_id SELECT this.doc.getElementsByName("external_id")[0].setAttribute("id", "external_id"); if (inputBox.value.match(/^http.*/)) { - let helpAElem = this.doc.createElement("a"); + var helpAElem = this.doc.createElement("a"); wholeURL = inputBox.value; helpAElem.setAttribute("href", wholeURL); - let paramsArr = helpAElem.search.replace(/^\?/, '').split('&'); + var paramsArr = helpAElem.search.replace(/^\?/, '').split('&'); // get convert URL parameters to an Object - let params = {}, s = []; + var params = {}, s = []; paramsArr.forEach(function(par, idx, arr) { s = par.split('='); params[s[0]] = s[1]; @@ -855,11 +859,11 @@ RHBugzillaPage.prototype.addClosingUpstream = function() { inputBox.value = externalBugID; } // get host and bugzillaName - let bugzillaName = this.getBugzillaName(helpAElem.hostname); + var bugzillaName = this.getBugzillaName(helpAElem.hostname); this.selectOption("external_id", bugzillaName); } else if (!isNaN(inputBox.value)) { externalBugID = parseInt(inputBox.value, 10); - let bugzillaHostname = this.doc.getElementById("external_id").value; + var bugzillaHostname = this.doc.getElementById("external_id").value; wholeURL = bugzillaHostname+"show_bug.cgi?id="+externalBugID; } else { // no inputBox.value -- maybe there is an external bug from @@ -872,7 +876,7 @@ RHBugzillaPage.prototype.addClosingUpstream = function() { // It is not good to close bug as UPSTREAM, if there is no reference // to the upstream bug. if ((externalBugID > 0) || (refs.length > 2)) { - let msgStr = this.commentStrings["sentUpstreamString"]; + var msgStr = this.commentStrings.sentUpstreamString; msgStr = msgStr.replace("§§§", wholeURL); this.centralCommandDispatch("comment",msgStr); this.centralCommandDispatch("status", "CLOSED"); @@ -895,22 +899,22 @@ RHBugzillaPage.prototype.markBugTriaged = function() { // /fedora-meeting.2009-11-24-15.11.log.html // for F13 and later, ASSIGNED is "add Triaged keyword" (as well) // for <F13 it is "add both" (ASSIGNED status and Triaged keyword) - let ver = this.getVersion(); - let assignee = this.getOwner(); + var ver = this.getVersion(); + var assignee = this.getOwner(); if ((!this.isEnterprise()) && (ver < TriagedDistro)) { this.selectOption("bug_status", "ASSIGNED"); } this.addStuffToTextBox("keywords","Triaged"); -} +}; /** * */ RHBugzillaPage.prototype.parseBacktrace = function(ret) { - let splitArray = ret.split("\n"); - let i = 0, ii = splitArray.length; - let outStr = "", curLine = "", numStr = ""; - let lineCounter = 0, endLineNo = 0; + var splitArray = ret.split("\n"); + var i = 0, ii = splitArray.length; + var outStr = "", curLine = "", numStr = ""; + var lineCounter = 0, endLineNo = 0; while (i < ii) { if (this.RE.signalHandler.test(splitArray[i])) { diff --git a/package.json b/package.json index 5c8fe4d..96db7e7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,8 @@ { + "id": "jid0-uXmbeWgOltUUuqrHKhrR7hW3IQY", "dependencies": [ "jetpack-core" ], "description": "Help for triage on bugzilla", - "author": "Matěj Cepl (http://matej.ceplovi.cz)" + "author": "Mat\u011bj Cepl (http://matej.ceplovi.cz)" } |