aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rhbzpage.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rhbzpage.js')
-rw-r--r--lib/rhbzpage.js227
1 files changed, 43 insertions, 184 deletions
diff --git a/lib/rhbzpage.js b/lib/rhbzpage.js
index f318528..c885699 100644
--- a/lib/rhbzpage.js
+++ b/lib/rhbzpage.js
@@ -3,7 +3,7 @@
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";
-var utilMod = require("util");
+var util = require("util");
var xrpc = require("xmlrpc");
var xhr = require("xhr");
// var TriagedDistro = 13;
@@ -29,6 +29,20 @@ exports.RHBugzillaPage = function RHBugzillaPage(doc) {
// HSL
// 120, 0, 23
this.RHITColor = new Color(102, 0, 102); // RGB 102, 0, 102; HSL 300, 0, 20
+
+ this.RE = {
+ Comment: new RegExp("^\\s*#"), // unsused
+ BlankLine: new RegExp("^\\s*$"), // unused
+ // new line
+ // [ 65.631] (--) intel(0): Chipset: "845G"
+ Chipset: new RegExp("^\\s*\\[?[ 0-9.]*\\]?\\s*\\(--\\) "+
+ "([A-Za-z]+)\\([0-9]?\\): Chipset: (.*)$"),
+ ATIgetID: new RegExp("^.*\\(ChipID = 0x([0-9a-fA-F]+)\\).*$"),
+ Abrt: new RegExp("^\\s*\\[abrt\\]"),
+ signalHandler: new RegExp("^\\s*#[0-9]*\\s*<signal handler called>"),
+ frameNo: new RegExp("^\\s*#([0-9]*)\\s")
+ };
+
// END OF CONSTANTS
// Prepare for query buttons
@@ -104,7 +118,7 @@ exports.RHBugzillaPage = function RHBugzillaPage(doc) {
}
} // END OF RHBugzillaPage CONSTRUCTOR
-RHBugzillaPage.prototype = utilMod.heir(BZPage);
+RHBugzillaPage.prototype = util.heir(BZPage);
RHBugzillaPage.prototype.constructor = RHBugzillaPage;
/**
@@ -114,7 +128,7 @@ RHBugzillaPage.prototype.constructor = RHBugzillaPage;
* we haven't set it up.
*/
RHBugzillaPage.prototype.getDefaultAssignee = function() {
- return this.filterByRegexp(this.constantData.defaultAssignee,
+ return util.filterByRegexp(this.constantData.defaultAssignee,
this.component).toLowerCase();
}
@@ -199,153 +213,6 @@ RHBugzillaPage.prototype.centralCommandDispatch = function(cmdLabel, cmdParams)
};
-/* Offline supporting functions */
-/**
- *
- * @todo FIXME this probably makes a closure and a memory leak name='changeform'
- * investigate
- * https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion
- *
- * <form method="post" action="process_bug.cgi" autocomplete="off">
- *
- * Reading
- * http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13
- * random notes: - 17.13.3 provides all steps necessary - enctype !=
- * application/x-www-form-urlencoded => SHOULD fails (no further questions
- * needed) - http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1. is
- * nice explanation (albeit quite dated) - on multiple values
- * http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.6.1 -
- * příliš jednoduché
- * http://www.innovation.ch/java/HTTPClient/emulating_forms.html -
- */
-RHBugzillaPage.prototype.serializeForm = function(form) {
- let serialForm = {
- dataOut : "",
- name : form.name,
- method : form.method,
- acceptCharset : form.acceptCharset,
- action : form.action, // TODO shouldn't we get a non-relative URL?
- enctype : form.enctype,
- cookie : this.doc.cookie,
- autocomplete : form.getAttribute("autocomplete"),
- bugNo : this.bugNo
- };
-
- function genURIElement(sName, sValue) {
- return encodeURIComponent(sName) + "=" + encodeURIComponent(sValue);
- }
-
- /**
- * @param o
- * control to be serialized
- * @return String with the serialized control
- */
- function serializeControl(element) {
- let val = element.value;
- // console.log("val.toSource() = " + val.toSource());
- /*
- * on HTMLSelectElement we have an attribute 'type' of type DOMString,
- * readonly The type of this form control. This is the string
- * "select-multiple" when the multiple attribute is true and the string
- * "select-one" when false.
- */
- if ((val == null) || (val == undefined) || (val == "")) {
- return;
- } else if (val instanceof Array) {
- return val.map(function(x) {
- return genURIElement(element.name, x.value);
- }).join("&");
- } else if (val instanceof String) {
- return genURIElement(element.name, val);
- } else { // assume HTMLCollection
- return Array.map(val, function(x) {
- return genURIElement(element.name, x.value);
- }).join("&");
- }
- }
-
- serialForm.dataOut = Array.filter(form.elements,function(el) {
- return !el.disabled && el.name &&
- // FIXME shouldn't I just add && el.value here?
- (el.checked || /select|textarea/i.test(el.nodeName) ||
- /text|hidden|password|search/i.test(el.type));
- }).map(serializeControl).join("&");
- return serialForm;
-};
-
-//RHBugzillaPage.prototype.submitCallback = function(evt) {
-// console.log("Submit Callback!");
-// if (jetpack.__parent__.navigator.onLine) {
-// let serForm = this
-// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms
-// .namedItem("changeform"));
-//// console.log("serForm:\n" + serForm.toSource());
-// } else {
-// let serForm = this
-// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms
-// .namedItem("changeform"));
-// myStorage.forms[this.bugNo] = serForm;
-// evt.stopPropagation();
-// evt.preventDefault();
-// }
-//};
-
-/**
- *
- *
- * Yes, this is correct, this is NOT method of RHBugzillaPage!
- */
-/*function onlineCallback() {
- function deserializeAndSend(formData) {
- // FIXME notImplemented
- // is it enough to just
- // run XMLHttpRequest? Probably yes, this is just a form
- // and this is just a HTTP request
- // it is probably better to get already processed
- // application/x-www-form-urlencoded
- // see http://htmlhelp.com/reference/html40/forms/form.html for details
- // and also https://developer.mozilla.org/en/AJAX/Getting_Started
- // what's?
- // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
- // /Global_Functions/encodeURI & co.
- // this seems to be also interesting
- // https://developer.mozilla.org/en/Code_snippets/Post_data_to_window
- console.error("Sending bugs not implemented yet!");
- return ""; // FIXME check other HTTP headers to be set
-
- let bugID = formData.bugNo;
- let req = new XMLHttpRequest();
- req.open("POST", formData.action, true);
- // FIXME co očekávám za odpověď? req.overrideMimeType("text/xml");
- // * Accept-Encoding
- // * Accept-Language
- // * Accept (MIME types)
- req.setRequestHeader("Connection", "keep-alive");
- req.setRequestHeader("Keep-Alive", 300);
- req.setRequestHeader("Content-Type", formData.enctype);
- req.setRequestHeader("Referer", bugURL + bugID);
- req.setRequestHeader("Accept-Charset", formData.acceptCharset);
- req.setRequestHeader("Cookie", formData.cookie);
- req.onreadystatechange = function(aEvt) {
- if (req.readyState == 4) {
- if (req.status == 200) {
- console.log("Sent form for bug " + bugID);
- delete myStorage.forms[bugID];
- } else {
- console.error("Sending form for bug " + bugID + "failed!");
- }
- }
- };
- req.send(formData.data);
- }
-
- if (myStorage.forms.length > 0) {
- myStorage.forms.forEach(function(x) {
- deserializeAndSend(x);
- });
- }
-}
-*/
/* Bugzilla functions. */
RHBugzillaPage.prototype.ProfessionalProducts = [
@@ -394,7 +261,7 @@ RHBugzillaPage.prototype.pasteBacktraceInComments = function() {
attURL = "https://bugzilla.redhat.com/attachment.cgi?id="
+ x[1];
if (!this.btSnippet) {
- let btRaw = utilMod.loadText(attURL, function(ret) {
+ let btRaw = util.loadText(attURL, function(ret) {
this.btSnippet = this.parseBacktrace(ret);
if (this.btSnippet) {
this.addStuffToTextBox("comment", this.btSnippet);
@@ -414,7 +281,7 @@ RHBugzillaPage.prototype.markBadAttachments = function() {
let badMIMEArray = [ "application/octet-stream", "text/x-log", "undefined" ];
let badAttachments = this.attachments.filter(function(att, idx, arr) {
- return (utilMod.isInList(att[2], badMIMEArray));
+ return (util.isInList(att[2], badMIMEArray));
});
if (badAttachments.length > 0) {
@@ -514,7 +381,7 @@ RHBugzillaPage.prototype.setBranding = function() {
}
// we should make visible whether maintCCAddr is in CCList
- if (utilMod.isInList(this.maintCCAddr, this.CCList)) {
+ if (util.isInList(this.maintCCAddr, this.CCList)) {
let ccEditBoxElem = this.doc.getElementById("cc_edit_area_showhide");
// ccEditBoxElem.textContent = "*"+ccEditBoxElem.textContent;
ccEditBoxElem.style.color = "navy";
@@ -526,7 +393,7 @@ RHBugzillaPage.prototype.setBranding = function() {
let compElems;
let suspiciousComponents = config.gJSONData.configData.suspiciousComponents;
if (suspiciousComponents
- && utilMod.isInList(this.component, suspiciousComponents)
+ && util.isInList(this.component, suspiciousComponents)
&& (compElems = this.doc
.getElementById("bz_component_edit_container"))) {
compElems.style.background = "red none";
@@ -545,7 +412,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) {
let that = this;
function groupIDs(manStr, cardStrID) {
- let outStr = that.filterByRegexp(chipIDsGroupings, manStr + "," + cardStrID);
+ let outStr = util.filterByRegexp(chipIDsGroupings, manStr + "," + cardStrID);
if (outStr.length === 0) {
outStr = "UNGROUPED_" + manStr + "/" + cardStrID;
}
@@ -623,6 +490,7 @@ RHBugzillaPage.prototype.fillInWhiteBoard = function(iLine, driverStr) {
* @return None
*/
RHBugzillaPage.prototype.fillInChipMagic = function () {
+ let that = this;
let XorgLogURL = "";
let XorgLogAttID = "";
let XorgLogFound = false;
@@ -643,34 +511,25 @@ RHBugzillaPage.prototype.fillInChipMagic = function () {
attURL = "https://bugzilla.redhat.com/attachment.cgi?id="+XorgLogAttID;
that = this;
- let req = new xhrMod.XMLHttpRequest();
- req.open("GET",attURL,true);
- req.onreadystatechange = function (aEvt) {
- if (req.readyState == 4) {
- if (req.status == 200) {
- let ret = req.responseText;
- let interestingLineArr = ret.split("\n").
- filter(function (v,i,a) {
- return this.RE.Chipset.test(v);
- });
- if (interestingLineArr.length >0) {
- interestingArray = this.RE.Chipset.exec(interestingLineArr[0]);
- interestingLine = interestingArray[2].
- replace(/[\s"]+/g," ").trim();
- // Persuade createNewButton to have mercy and to actually add
- // non-default button
- this.constantData.chipMagicTrigger = true;
- this.chipMagicInterestingLine = interestingLine+"\t"+interestingArray[1]
- .toUpperCase();
- this.createNewButton("status_whiteboard", true, "rh-xorg", "chipMagic");
- }
- } else {
- throw "Getting attachment " + attURL + "failed!";
- }
+ // parse Xorg.0.log
+ util.loadText(attURL, function(ret){
+ let interestingLineArr = ret.split("\n").
+ filter(function (v,i,a) {
+ return that.RE.Chipset.test(v);
+ });
+ if (interestingLineArr.length >0) {
+ // TODO we are parsing only the first found line; is it alright?
+ interestingArray = that.RE.Chipset.exec(interestingLineArr[0]);
+ interestingLine = interestingArray[2].
+ replace(/[\s"]+/g," ").trim();
+ // Persuade createNewButton to have mercy and to actually add
+ // non-default button
+ that.constantData.chipMagicTrigger = true;
+ that.chipMagicInterestingLine = interestingLine+"\t"+interestingArray[1]
+ .toUpperCase();
+ that.createNewButton("status_whiteboard", true, "rh-xorg", "chipMagic");
}
- };
- req.send("");
-
+ });
this.XorgLogAttListIndex++;
};
@@ -750,7 +609,7 @@ RHBugzillaPage.prototype.queryUpstream = function() {
if (text) {
let text = encodeURIComponent(text.trim());
let queryUpstreamBugsURLArray = this.constantData.queryUpstreamBug;
- let url = this.filterByRegexp(queryUpstreamBugsURLArray, this.component);
+ let url = util.filterByRegexp(queryUpstreamBugsURLArray, this.component);
jetpack.tabs.open(url + text);
}
}
@@ -759,7 +618,7 @@ RHBugzillaPage.prototype.queryUpstream = function() {
*
*/
RHBugzillaPage.prototype.sendBugUpstream = function() {
- let url = this.filterByRegexp(this.constantData.newUpstreamBug, this
+ let url = util.filterByRegexp(this.constantData.newUpstreamBug, this
.getOptionValue("component"));
let ret = jetpack.tabs.open(url);