1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
//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) {
/*
* Let's comment it out, and we'll see if anything breaks. TODO This paragraph
* looks suspicous ... what is it? Does it belong to this function? var
* notedLabel = document.querySelector("label[for='newcc']"); while
* (notedLabel.firstChild) { var node =
* notedLabel.removeChild(notedLabel.firstChild);
* notedLabel.parentNode.insertBefore(node, notedLabel); }
* notedLabel.parentNode.removeChild(notedLabel);
*/
// FIXME BROKEN and its depending functions are even more broken
return null;
var abrtQueryURL = "https://bugzilla.redhat.com/buglist.cgi?"
+ "cmdtype=dorem&remaction=run&namedcmd=all%20NEW%20abrt%20crashes&"
+ "sharer_id=74116";
var mainTitle = document
.getElementsByClassName("bz_alias_short_desc_container")[0];
createDeadLink("callAbrtQuery_link", "Abrt bugs", mainTitle,
abrtQueryURL, [], false, null, "a");
if (idContainsWord("cf_devel_whiteboard", 'btparsed')) {
addStuffToTextBox('status_whiteboard', 'btparsed');
}
if (!(isTriaged()
|| idContainsWord("status_whiteboard", 'btparsed') || (atts.length > 0))) {
var btAttachments = atts.filter(function(att) {
return (/File: backtrace/.test(att[0]));
});
// TODO we need to go through all backtrace attachments, but
// 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
(!idContainsWord("status_whiteboard", 'btparsed'))) {
Request({
url : attURL,
onComplete : function(response) {
if (response.status == 200) {
btSnippet = parseBacktrace(response.text);
if (btSnippet) {
addCheckShowLink(x, btSnippet);
}
}
}
}).get();
}
}, this);
}
// Add "show BT" links
if (parsedAttachments.length > 0) {
this.parsedAttachments.forEach(function(att) {
addShowParsedBTLink(att);
});
}
}
/**
* Open new window with the content of the attachment.
*
* @param id
* Number of the attachment id
* @return none
*/
function showAttachment(id) {
self.postMessage(new Message("OpenURLinPanel", "https://"
+ window.location.hostname + "/attachment.cgi?id=" + id));
}
/**
* add a link opening a window with the parsed backtrace
*
* @param att
* Attachment object
*/
function addShowParsedBTLink(att) {
var elem = att[4].querySelector("td:last-of-type");
createDeadLink("showParsedBacktraceWindow-" + att[1],
"showBT", elem, showAttachment, att[1], true);
}
/**
* Unfinished ... see above FIXME BROKEN AND DOESN'T WORK
*/
function addNewAttachmentRow(origAtt, newAttId, newAttSize) {
var that = this;
var oldAddBTLink = document
.getElementById("attachBacktraceActivator");
oldAddBTLink.parentNode.removeChild(oldAddBTLink);
var newTRElem = origAtt[4].cloneNode(true);
// fix number of the attachment
Array.forEach(newTRElem.getElementsByTagName("a"), function(
aEl) {
aEl.setAttribute("href", aEl.getAttribute("href").replace(
origAtt[1], newAttId));
});
var aElements = newTRElem.getElementsByTagName("a");
aElements[0].setAttribute("name", "parsed-backtrace.txt");
aElements[0].getElementsByTagName("b")[0].textContent = titleParsedAttachment;
var sizeSpan = newTRElem
.getElementsByClassName("bz_attach_extra_info")[0];
sizeSpan.textContent = "(" + (newAttSize / 1024).toFixed(2)
+ " KB, text/plain)";
// aElements[1].textContent = new Date().toString(); TODO we should add
// eventually, but not pressing
var vcardSpan = newTRElem.getElementsByClassName("vcard")[0];
if (vcardSpan !== undefined) {
var vcardSpanClassList = vcardSpan.classList;
if (/@redhat\.com/.test(this.login)
&& !vcardSpanClassList.contains("redhat_user")) {
vcardSpanClassList.add("redhat_user");
}
var vcardAElem = vcardSpan.getElementsByTagName("a")[0];
vcardAElem.setAttribute("title", this.login);
vcardAElem.setAttribute("href", "mailto:" + this.login);
vcardAElem.className = "email";
vcardAElem.innerHTML = "<span class='fn'>" + this.login
+ "</span>";
}
var elem = newTRElem.querySelector("td:last-of-type");
this.createDeadLink("showBacktrace", "show BT", elem,
this.showAttachment, newAttId, false);
origAtt[4].parentNode.insertBefore(newTRElem,
origAtt[4].nextSibling);
}
/**
* Add a link to create a new attachment with a parsed backtrace
*
* @param oldAtt
* Object with an attachment row
* @param snippet
* String with parsed backtrace
* @return none
*/
function addCheckShowLink(oldAtt, snippet) {
var elem = oldAtt[4].querySelector("td:last-of-type");
/*
* createDeadLink("attachBacktraceActivator", "add parsed BT", elem,
* function(x) { // pass function and parameters as two separate parameters,
* the function to be called from // addAttachment addAttachment(snippet,
* addNewAttachmentRow, oldAtt); }, [], true);
*/
}
|