/*jslint onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */ /*global jetpack */ // Released under the MIT/X11 license // http://www.opensource.org/licenses/mit-license.php "use strict"; var utilMod = require("util"); var xrpc = require("xmlrpc"); var xhr = require("xhr"); // var TriagedDistro = 13; // var NumberOfFrames = 7; // var XMLRPCurl = "https://bugzilla.redhat.com/xmlrpc.cgi"; // var bugURL = "https://bugzilla.redhat.com/show_bug.cgi?id="; // ==================================================================================== // RHBugzillaPage object exports.RHBugzillaPage = function RHBugzillaPage(doc) { // For identification of graphics card const manuChipStrs = [ [ "ATI Radeon", "ATI", "1002" ], [ "ATI Mobility Radeon", "ATI", "1002" ], [ "Intel Corporation", "INTEL", "8086" ], [ "NVIDIA", "NV", "10de" ] ]; // http://en.wikipedia.org/wiki/HSL_color_space // when only the value of S is changed // stupido!!! the string is value in hex for each color this.RHColor = new Color(158, 41, 43); // RGB 158, 41, 43; HSL 359, 1, 39 this.FedoraColor = new Color(0, 40, 103); // RGB 0, 40, 103; HSL 359, 1, 39 this.RawhideColor = new Color(0, 119, 0); // or "green", or RGB 0, 119, 0, or // HSL // 120, 0, 23 this.RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20 // END OF CONSTANTS // Prepare for query buttons // FIXME getting null for commentArea sometimes let 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); } // inheritance ... call superobject's constructor BZPage.call(this,doc); let that = this; this.reqCounter = 0; this.signaturesCounter = 0; this.chipMagicInterestingLine = ""; this.login = this.getLogin(); this.password = this.getPassword(); let ITbutton = this.doc.getElementById("cf_issuetracker"); this.its = ITbutton ? ITbutton.value.trim() : ""; // set default assignee on change of the component this.doc.getElementById("component").addEventListener("change", function() { that.component = that.getOptionValue("component"); that.changeAssignee("default"); }, false); // getBadAttachments this.XorgLogAttList = []; this.XorgLogAttListIndex = 0; this.attachments = this.getAttachments(); this.markBadAttachments(); this.setDefaultAssignee(); // Dig out backtrace this.btSnippet = ""; let 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; this.doc.forms.namedItem("changeform").addEventListener("submit", function() { if (this.signaturesCounter < 1) { that.addStuffToTextBox("comment", signatureFedoraString); this.signaturesCounter += 1; } }, false); } this.setBranding(); this.checkComments(); // TODO Get compiz bugs as well if ((config.gJSONData.configData.PCIIDsURL && (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; if (!/card_/.test(whiteboard_string)) { this.fillInChipMagic(); } } } // END OF RHBugzillaPage CONSTRUCTOR RHBugzillaPage.prototype = utilMod.heir(BZPage); RHBugzillaPage.prototype.constructor = RHBugzillaPage; /** * Find default assignee based on the current component * * @return String what would be a default assignee if * we haven't set it up. */ RHBugzillaPage.prototype.getDefaultAssignee = function() { return this.filterByRegexp(this.constantData.defaultAssignee, this.component).toLowerCase(); } /** * Set default assignee * * @return none * sets this.defaultAssignee property according to defaultAssignee list */ RHBugzillaPage.prototype.setDefaultAssignee = function() { this.defaultAssignee = this.getDefaultAssignee(); let defAss = this.defaultAssignee; // Add setting default assignee if ((defAss.length > 0) && (defAss !== this.getOwner())) { this.constantData.defaultAssigneeTrigger = true; this.createNewButton("bz_assignee_edit_container",true,"rh-common","setDefaultAssignee"); } }; /** * Auxiliary function to computer more complicated resolution */ RHBugzillaPage.prototype.closeSomeRelease = function() { // for RAWHIDE close as RAWHIDE, // if active selection -> CURRENTRELEASE // and put the release version to // "Fixed in Version" textbox // otherwise -> NEXTRELEASE let verNo = this.getVersion(); this.selectOption("bug_status", "CLOSED"); let text = ""; let resolution = ""; if (jetpack.selection.text) { text = jetpack.select.text.trim(); } if (text.length > 0) { resolution = "CURRENTRELEASE"; this.doc.getElementById("cf_fixed_in").value = text; } else if (verNo === 999) { resolution = "RAWHIDE"; } else { resolution = "NEXTRELEASE"; } this.centralCommandDispatch("resolution", resolution); }; /** * Additional commands specific for this subclass, overriding superclass one. */ RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams) { switch (cmdLabel) { // Set up our own commands case "closeUpstream": this.addClosingUpstream(); break; case "computeResolution": this.closeSomeRelease(); break; case "queryStringOurBugzilla": this.queryForSelection(); break; case "queryUpstreamBugzilla": this.queryUpstream(); break; case "sendBugUpstream": this.sendBugUpstream(); break; case "markTriaged": this.markBugTriaged(); break; case "chipMagic": let splitArr = cmdParams.split("\t"); this.fillInWhiteBoard(splitArr[0], splitArr[1]); break; // If we don't have it here, call superclass method default: BZPage.prototype.centralCommandDispatch.call(this, cmdLabel, cmdParams); break; } }; /* Offline supporting functions */ /** * * @todo FIXME this probably makes a closure and a memory leak name='changeform' * investigate * https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion * *