aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-09-01 00:00:58 +0200
committerMatěj Cepl <mcepl@redhat.com>2011-09-01 09:17:18 +0200
commitb6b75faa9ef841396731398a2882e869df5b8ae7 (patch)
treef7ece86109980c8104aa2f8ccffb8503bcb6384f
parent2ed5e245736860323819a93336b28d3b39176f17 (diff)
downloadbugzilla-triage-b6b75faa9ef841396731398a2882e869df5b8ae7.tar.gz
Removing GetURL and some overcomplicated parts.
-rw-r--r--data/lib/otherButtons.js2
-rw-r--r--data/mozlib/mozpage.js18
-rw-r--r--data/rhlib/rhbzpage.js61
-rw-r--r--lib/libbugzilla.js11
-rw-r--r--lib/main.js18
5 files changed, 48 insertions, 62 deletions
diff --git a/data/lib/otherButtons.js b/data/lib/otherButtons.js
index ef04d19..80d9274 100644
--- a/data/lib/otherButtons.js
+++ b/data/lib/otherButtons.js
@@ -95,7 +95,7 @@ function addingEmbelishments(logList) {
&& (!FillMagicDoneRE.test(getSummary()))
&& (maintCCAddr == "xgl-maint@redhat.com")) {
// Add find chip magic button
- fillInChipMagic(logList[0].id);
+ analyzeXorgLog(logList[0].id, "AnalyzeInterestingLine");
}
// Add links for creating new bug in the same product
diff --git a/data/mozlib/mozpage.js b/data/mozlib/mozpage.js
index 5185cd7..81eb4fb 100644
--- a/data/mozlib/mozpage.js
+++ b/data/mozlib/mozpage.js
@@ -16,14 +16,16 @@ var mozFlags = (function() {
function _init() {
var tdColumn2 = document.getElementById("bz_show_bug_column_2");
- var flag_selects = tdColumn2.querySelectorAll("td.field_value select");
- Array.forEach(flag_selects, function(sel) {
- var label = tdColumn2.querySelector("label[for='" + sel.id + "']");
- if (label) {
- var key = label.textContent.trim().replace(/\s*:?$/,"");
- flags[key] = sel.id;
- }
- });
+ if (tdColumn2) { // TODO we should really make some configuration for non-Mozilla
+ var flag_selects = tdColumn2.querySelectorAll("td.field_value select");
+ Array.forEach(flag_selects, function(sel) {
+ var label = tdColumn2.querySelector("label[for='" + sel.id + "']");
+ if (label) {
+ var key = label.textContent.trim().replace(/\s*:?$/,"");
+ flags[key] = sel.id;
+ }
+ });
+ }
}
function _setFlag(label) {
diff --git a/data/rhlib/rhbzpage.js b/data/rhlib/rhbzpage.js
index 34bf906..944b9a6 100644
--- a/data/rhlib/rhbzpage.js
+++ b/data/rhlib/rhbzpage.js
@@ -77,11 +77,6 @@ function RHOnMessageHandler(msg, nextHandlerList) {
case "FixAttachmentMIMECallback":
XMLRPCcallback();
break;
- case "AnalyzeInterestingLine":
- case "AnalyzeXorgLogBacktrace":
- case "AnalyzeDmesgErrors":
- findInterestingLine(msg.data, msg.cmd);
- break;
case "queryUpstream":
queryUpstreamCallback(msg.data, constantData.queryUpstreamBug);
break;
@@ -208,7 +203,6 @@ function sendBugUpstream(thgs) {
*
*/
function fillInWhiteBoard(cardName) {
- console.myDebug("fillInWhiteBoard: cardName = " + cardName);
clickMouse("editme_action");
var titleElem = document.getElementById('short_desc');
titleElem.value = '[' + cardName + ']\u00A0' + titleElem.value;
@@ -216,19 +210,6 @@ 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
- */
-function fillInChipMagic(XlogID) {
- analyzeXorgLog(XlogID, "AnalyzeInterestingLine");
-}
-
-/**
* Creates a button to change summary by adding a graphic chip label
*
* @param Array
@@ -247,7 +228,6 @@ function chipsetMagic (interestingLineArr) {
if (interestingPCIID.length > 1) {
var PCIid = (interestingPCIID[0] + ":" + interestingPCIID[1]).
toUpperCase();
- console.myDebug("PCIid = " + PCIid);
// Nvidia driver provides good code in the Chipset line
if (interestingPCIID[0].toLowerCase() == "10de") {
cardStr = interestingLineArr[1][2].
@@ -304,13 +284,6 @@ function displayResultsInPanel(results) {
"\n</pre></body></html>"));
}
-function analyzeXorgLog(attachID, backMsg) {
- self.postMessage(new Message("GetURL", {
- url: "https://" + window.location.hostname + "/attachment.cgi?id=" + attachID,
- backMessage: backMsg
- }));
-}
-
function findInterestingLine(wholeLog, backMsg) {
var REstr = logAnalyzeLogic[backMsg].re;
var REarr = [];
@@ -322,26 +295,44 @@ function findInterestingLine(wholeLog, backMsg) {
return new RegExp(reone);
});
}
- console.myDebug("Current REs:");
- REarr.forEach(function (re) {
- console.myDebug("re: " + re.source);
- });
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));
}
});
});
- console.myDebug("results = " + results.toSource());
logAnalyzeLogic[backMsg].func(results);
}
+
+/**
+ * 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
+ */
+function analyzeXorgLog(attachID, backMsg) {
+ var req = new XMLHttpRequest();
+ req.open("GET", "/attachment.cgi?id=" + attachID, true);
+ req.onreadystatechange = function (aEvt) {
+ if (req.readyState == 4) {
+ if(req.status == 200) {
+ findInterestingLine(req.responseText, backMsg);
+ }
+ else
+ console.error('Error', req.statusText);
+ }
+ };
+ req.send(null);
+}
+
/**
* Add an external bug reference from the input box
*
@@ -397,7 +388,7 @@ function addClosingUpstream() {
var newBugURL = addExternalBug();
if (!newBugURL) {
- console.myDebug("No external bug specified among the External References!");
+ console.warning("No external bug specified among the External References!");
return null;
}
diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js
index c6f1adb..46356cc 100644
--- a/lib/libbugzilla.js
+++ b/lib/libbugzilla.js
@@ -238,17 +238,6 @@ exports.setClipboard = function setClipboard(stuff) {
clipboard.set(stuff, "text");
};
-exports.getURL = function getURL(url, callback) {
- Request({
- url: url,
- onComplete: function(response) {
- if (response.status == 200) {
- callback(response.text);
- }
- }
- }).get();
-};
-
exports.openStringInNewPanel = function openStringInNewPanel(inHTMLStr) {
openURLInNewPanel("data:text/html;charset=utf-8," +
inHTMLStr);
diff --git a/lib/main.js b/lib/main.js
index 9c42166..b7ac152 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -74,12 +74,15 @@ var messageHandler = exports.messageHandler = function messageHandler(
case "ChangeJSONURL":
libbz.changeJSONURL();
break;
+ // Needed because Panel is add-on module
case "OpenURLinPanel":
libbz.openURLInNewPanel(msg.data);
break;
+ // Needed because of tabs.open()
case "OpenURLinTab":
libbz.openURLInNewTab(msg.data);
break;
+ // Needed because Panel is add-on module
case "OpenStringInPanel":
libbz.openStringInNewPanel(msg.data);
break;
@@ -113,13 +116,7 @@ var messageHandler = exports.messageHandler = function messageHandler(
});
}
break;
- case "GetURL":
- libbz.getURL(msg.data.url,
- function(stuff) {
- worker.postMessage(new Message(msg.data.backMessage,
- stuff));
- });
- break;
+ // Needed because creating additional page-mods on remote bugzilla
case "OpenBugUpstream":
libbz.createUpstreamBug(msg.data.url, msg.data.subject,
msg.data.comment);
@@ -170,6 +167,13 @@ libbz.initialize(libbz.config, function() {
worker.on('message', function(msg) {
messageHandler(worker, msg);
});
+ worker.port.on('GetURL', function (command) {
+ libbz.getURL(command.url,
+ function(stuff) {
+ worker.port.emit(command.backMessage,
+ stuff);
+ });
+ });
}
});
});