aboutsummaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-03-25 01:17:49 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-03-25 14:21:22 +0100
commitbcf1996cbdd2118a88226b24a4c78a08fe21749b (patch)
treeb2274c77ae97dc116675145885b335e2a8377d5f /data
parent23fb75565611af1e85455844be1d8931efe0a0a4 (diff)
downloadbugzilla-triage-bcf1996cbdd2118a88226b24a4c78a08fe21749b.tar.gz
Working on cutting down lines from bug-page-mod.js
Diffstat (limited to 'data')
-rw-r--r--data/lib/addNewLinks.js60
-rw-r--r--data/lib/bug-page-mod.js (renamed from data/js/bug-page-mod.js)204
-rw-r--r--data/lib/cc-context.js (renamed from data/js/cc-context.js)0
-rw-r--r--data/lib/checkin-context.js (renamed from data/js/checkin-context.js)0
-rw-r--r--data/lib/preprocessDuplicates.js120
-rw-r--r--data/lib/rhbzpage.js2
-rw-r--r--data/lib/urltest.js (renamed from data/js/urltest.js)0
-rw-r--r--data/lib/util.js8
-rw-r--r--data/lib/viewSource.js100
9 files changed, 287 insertions, 207 deletions
diff --git a/data/lib/addNewLinks.js b/data/lib/addNewLinks.js
new file mode 100644
index 0000000..7993e07
--- /dev/null
+++ b/data/lib/addNewLinks.js
@@ -0,0 +1,60 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Bugzilla Tweaks.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Johnathan Nightingale <johnath@mozilla.com>
+ * Ehsan Akhgari <ehsan@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+function addNewLinks(d) {
+ var product = d.querySelector("#field_container_product option[selected]");
+ var component = d.querySelector("#component option[selected]");
+
+ if (product) {
+ var label = d.getElementById('field_container_product');
+ var url = 'enter_bug.cgi?product=' + encodeURIComponent(product.value);
+ if (label) {
+ createDeadLink("file_new_bug_product", "new", label,
+ url, [], "parens");
+ }
+ }
+
+ if (product && component) {
+ var select = d.querySelector("select#component");
+ var label = select.parentNode;
+ var url = 'enter_bug.cgi?product=' + encodeURIComponent(product.value) +
+ '&component=' + encodeURIComponent(component.value);
+ if (label) {
+ createDeadLink("file_new_bug_component", "new", label, url, [], "parens");
+ }
+ }
+}
diff --git a/data/js/bug-page-mod.js b/data/lib/bug-page-mod.js
index a75e776..a5a908d 100644
--- a/data/js/bug-page-mod.js
+++ b/data/lib/bug-page-mod.js
@@ -46,24 +46,6 @@ function tweakBugzilla(d) {
if (!d.getElementById("comments")) // don't process the mid-air collision pages
return;
- // Strip "Bug " from titles for better tab readability
- if (/^Bug /.test(d.title))
- d.title = d.title.slice(4);
-
- // After POSTing, redirect with a GET back to the same bug
- if (/\/(process_bug|attachment|post_bug).cgi$/.test(d.location.href)) {
- var bug = getBugNumber(d);
- if (bug) {
- var url = d.location.href;
- url = url.replace("process_bug.cgi", "show_bug.cgi");
- url = url.replace("attachment.cgi", "show_bug.cgi");
- url = url.replace("post_bug.cgi", "show_bug.cgi");
- url += "?id=" + bug;
- d.defaultView.history.replaceState(null, "", url);
- d.title = bug + " - " + d.getElementById("short_desc_nonedit_display").textContent;
- }
- }
-
// Make the comment box bigger
var commentBox = d.querySelector("#comment");
if (commentBox)
@@ -526,70 +508,6 @@ function attachmentDiffLinkify(doc) {
}
}
-var reAttachmentType = /,\s+([^ )]*)[;)]/;
-
-function viewAttachmentSource(doc) {
- function addLink(elem, title, href) {
- if (elem.textContent.match(/[\S]/)) {
- elem.appendChild(doc.createTextNode(" | "));
- }
- var link = doc.createElement("a");
- link.href = href;
- link.textContent = title;
- elem.appendChild(link);
- }
- var table = doc.getElementById("attachment_table");
- if (!table)
- return;
- var rows = table.querySelectorAll("tr");
- for (var i = 0; i < rows.length; ++i) {
- var items = rows[i].querySelectorAll("td");
- if (items.length != 3)
- continue;
- var links = items[0].querySelectorAll("a");
- if (links.length == 0)
- continue;
- var attachHref = links[0].href;
- // get the type of the attachment
- var span = items[0].querySelector(".bz_attach_extra_info");
- if (!span)
- continue;
- var typeName = null;
- try {
- // Match mime type followed by ";" (charset) or ")" (no charset)
- typeName = span.textContent.match(reAttachmentType)[1];
- typeName = typeName.split(";")[0]; // ignore charset following type
- } catch (e) {}
- if (typeName == "application/java-archive" ||
- typeName == "application/x-jar") {
- // Due to the fix for bug 369814, only zip files with this special
- // mime type can be used with the jar: protocol.
- // http://hg.mozilla.org/mozilla-central/rev/be54f6bb9e1e
- addLink(items[2], "JAR Contents", "jar:" + attachHref + "!/");
- // https://bugzilla.mozilla.org/show_bug.cgi?id=369814#c5 has more possible mime types for zips?
- } else if (typeName == "application/zip" ||
- typeName == "application/x-zip-compressed" ||
- typeName == "application/x-xpinstall") {
- addLink(items[2], "Static ZIP Contents", "jar:" + attachHref + "!/");
- } else if (typeName != "text/plain" &&
- typeName != "patch" &&
- // Other types that Gecko displays like text/plain
- // http://mxr.mozilla.org/mozilla-central/source/parser/htmlparser/public/nsIParser.h
- typeName != "text/css" &&
- typeName != "text/javascript" &&
- typeName != "text/ecmascript" &&
- typeName != "application/javascript" &&
- typeName != "application/ecmascript" &&
- typeName != "application/x-javascript" &&
- // Binary image types for which the "source" is not useful
- typeName != "image/gif" &&
- typeName != "image/png" &&
- typeName != "image/jpeg") {
- addLink(items[2], "Source", "view-source:" + attachHref);
- }
- }
-}
-
function quicksearchHandler(doc) {
var win = doc.defaultView;
var match = /quicksearch=([^&]+)/i.exec(win.location.search);
@@ -1005,90 +923,6 @@ function getUserName(doc) {
return null;
}
-function preprocessDuplicateMarkers(mainDoc, histDoc) {
- var comments = mainDoc.querySelectorAll(".bz_comment");
- var reDuplicate = /^\s*\*\*\*\s+Bug\s+(\d+)\s+has\s+been\s+marked\s+as\s+a\s+duplicate\s+of\s+this\s+bug.\s+\*\*\*\s*$/i;
- var row = 0;
- var rows = histDoc.querySelectorAll("#bugzilla-body tr");
- for (var i = 1 /* comment 0 can never be a duplicate marker */;
- i < comments.length; ++i) {
- var textHolder = comments[i].querySelector(".bz_comment_text");
- var match = reDuplicate.exec(trimContent(textHolder));
- if (match) {
- // construct the table row to be injected in histDoc
- var bugID = match[1];
- var email = comments[i].querySelector(".bz_comment_user .email")
- .href
- .substr(7);
- var link = textHolder.querySelector("a");
- var title = link.title;
- var time = trimContent(comments[i].querySelector(".bz_comment_time"));
- var what = 'Duplicate';
- var removed = '';
- var number = trimContent(comments[i].querySelector(".bz_comment_number")).
- replace(/[^\d]+/g, '');
- var class_ = '';
- if (/bz_closed/i.test(link.className + " " + link.parentNode.className)) {
- class_ += 'bz_closed ';
- }
- if (link.parentNode.tagName.toLowerCase() == 'i') {
- class_ += 'bztw_unconfirmed ';
- }
- var added = '<a href="show_bug.cgi?id=' + bugID + '" title="' +
- htmlEncode(title) + '" name="c' + number + '" class="' + class_ +
- '">' + bugID + '</a>';
-
- // inject the table row
- var reachedEnd = false;
- for (; row < rows.length; ++row) {
- var cells = rows[row].querySelectorAll("td");
- if (cells.length != 5)
- continue;
- if (time > trimContent(cells[1])) {
- if (row < rows.length - 1) {
- continue;
- } else {
- reachedEnd = true;
- }
- }
- if (time == trimContent(cells[1])) {
- cells[0].rowSpan++;
- cells[1].rowSpan++;
- var rowContents = [what, removed, added];
- var tr = histDoc.createElement("tr");
- rowContents.forEach(function (cellContents) {
- var td = histDoc.createElement("td");
- td.innerHTML = cellContents;
- tr.appendChild(td);
- });
- if (row != rows.length - 1) {
- rows[row].parentNode.insertBefore(tr, rows[row+1]);
- } else {
- rows[row].parentNode.appendChild(tr);
- }
- } else {
- var rowContents = [email, time, what, removed, added];
- var tr = histDoc.createElement("tr");
- rowContents.forEach(function (cellContents) {
- var td = histDoc.createElement("td");
- td.innerHTML = cellContents;
- tr.appendChild(td);
- });
- if (reachedEnd) {
- rows[row].parentNode.appendChild(tr);
- } else {
- rows[row].parentNode.insertBefore(tr, rows[row]);
- }
- }
- break;
- }
-
- // remove the comment from the main doc
- comments[i].parentNode.removeChild(comments[i]);
- }
- }
-}
-
function handleEmptyCollapsedBoxes(doc) {
// first, try to get the display style of a CC field (any would do)
var historyBoxes = doc.querySelectorAll(".bztw_history");
@@ -1123,44 +957,6 @@ function htmlEncode(str) {
.replace('"', '&quot;', 'g');
}
-function addNewLinks(d) {
- var product = d.querySelector("#field_container_product option[selected]");
- var component = d.querySelector("#component option[selected]");
-
- if (product) {
- var label = d.getElementById('field_container_product');
- var url = 'enter_bug.cgi?product=' + encodeURIComponent(product.value);
- if (label) {
- label.appendChild(d.createTextNode("("));
- var link = d.createElement('a');
- link.href = url;
- link.textContent = "new";
- link.title = "File a new bug in the same Product";
- var span = d.createElement('span');
- span.appendChild(link);
- label.appendChild(span);
- label.appendChild(d.createTextNode(")"));
- }
- }
-
- if (product && component) {
- var select = d.querySelector("select#component");
- var label = select.parentNode;
- var url = 'enter_bug.cgi?product=' + encodeURIComponent(product.value) + '&component=' + encodeURIComponent(component.value);
- if (label) {
- label.appendChild(d.createTextNode("("));
- var link = d.createElement('a');
- link.href = url;
- link.textContent = "new";
- link.title = "File a new bug in the same Product and Component";
- var span = d.createElement('span');
- span.appendChild(link);
- label.appendChild(span);
- label.appendChild(d.createTextNode(")"));
- }
- }
-}
-
function tbplbotSpamCollapser(d) {
var collapseExpandBox = d.querySelector(".bz_collapse_expand_comments");
if (!collapseExpandBox) {
diff --git a/data/js/cc-context.js b/data/lib/cc-context.js
index 38397a9..38397a9 100644
--- a/data/js/cc-context.js
+++ b/data/lib/cc-context.js
diff --git a/data/js/checkin-context.js b/data/lib/checkin-context.js
index 4d073be..4d073be 100644
--- a/data/js/checkin-context.js
+++ b/data/lib/checkin-context.js
diff --git a/data/lib/preprocessDuplicates.js b/data/lib/preprocessDuplicates.js
new file mode 100644
index 0000000..44ea5ca
--- /dev/null
+++ b/data/lib/preprocessDuplicates.js
@@ -0,0 +1,120 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Bugzilla Tweaks.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Johnathan Nightingale <johnath@mozilla.com>
+ * Ehsan Akhgari <ehsan@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+function preprocessDuplicateMarkers(mainDoc, histDoc) {
+ var comments = mainDoc.querySelectorAll(".bz_comment");
+ var reDuplicate = /^\s*\*\*\*\s+Bug\s+(\d+)\s+has\s+been\s+marked\s+as\s+a\s+duplicate\s+of\s+this\s+bug.\s+\*\*\*\s*$/i;
+ var row = 0;
+ var rows = histDoc.querySelectorAll("#bugzilla-body tr");
+ for (var i = 1 /* comment 0 can never be a duplicate marker */;
+ i < comments.length; ++i) {
+ var textHolder = comments[i].querySelector(".bz_comment_text");
+ var match = reDuplicate.exec(trimContent(textHolder));
+ if (match) {
+ // construct the table row to be injected in histDoc
+ var bugID = match[1];
+ var email = comments[i].querySelector(".bz_comment_user .email")
+ .href
+ .substr(7);
+ var link = textHolder.querySelector("a");
+ var title = link.title;
+ var time = trimContent(comments[i].querySelector(".bz_comment_time"));
+ var what = 'Duplicate';
+ var removed = '';
+ var number = trimContent(comments[i].querySelector(".bz_comment_number")).
+ replace(/[^\d]+/g, '');
+ var class_ = '';
+ if (/bz_closed/i.test(link.className + " " + link.parentNode.className)) {
+ class_ += 'bz_closed ';
+ }
+ if (link.parentNode.tagName.toLowerCase() == 'i') {
+ class_ += 'bztw_unconfirmed ';
+ }
+ var added = '<a href="show_bug.cgi?id=' + bugID + '" title="' +
+ htmlEncode(title) + '" name="c' + number + '" class="' + class_ +
+ '">' + bugID + '</a>';
+
+ // inject the table row
+ var reachedEnd = false;
+ for (; row < rows.length; ++row) {
+ var cells = rows[row].querySelectorAll("td");
+ if (cells.length != 5)
+ continue;
+ if (time > trimContent(cells[1])) {
+ if (row < rows.length - 1) {
+ continue;
+ } else {
+ reachedEnd = true;
+ }
+ }
+ if (time == trimContent(cells[1])) {
+ cells[0].rowSpan++;
+ cells[1].rowSpan++;
+ var rowContents = [what, removed, added];
+ var tr = histDoc.createElement("tr");
+ rowContents.forEach(function (cellContents) {
+ var td = histDoc.createElement("td");
+ td.innerHTML = cellContents;
+ tr.appendChild(td);
+ });
+ if (row != rows.length - 1) {
+ rows[row].parentNode.insertBefore(tr, rows[row+1]);
+ } else {
+ rows[row].parentNode.appendChild(tr);
+ }
+ } else {
+ var rowContents = [email, time, what, removed, added];
+ var tr = histDoc.createElement("tr");
+ rowContents.forEach(function (cellContents) {
+ var td = histDoc.createElement("td");
+ td.innerHTML = cellContents;
+ tr.appendChild(td);
+ });
+ if (reachedEnd) {
+ rows[row].parentNode.appendChild(tr);
+ } else {
+ rows[row].parentNode.insertBefore(tr, rows[row]);
+ }
+ }
+ break;
+ }
+
+ // remove the comment from the main doc
+ comments[i].parentNode.removeChild(comments[i]);
+ }
+ }
+}
diff --git a/data/lib/rhbzpage.js b/data/lib/rhbzpage.js
index 9af0127..f57af79 100644
--- a/data/lib/rhbzpage.js
+++ b/data/lib/rhbzpage.js
@@ -240,7 +240,7 @@ function pasteBacktraceInComments(atts) {
createDeadLink ("callAbrtQuery_link",
"Abrt bugs", mainTitle, abrtQueryURL, [], false, null, "a");
-
+
if (idContainsWord("cf_devel_whiteboard", 'btparsed')) {
addStuffToTextBox('status_whiteboard', 'btparsed');
}
diff --git a/data/js/urltest.js b/data/lib/urltest.js
index a0dbabf..a0dbabf 100644
--- a/data/js/urltest.js
+++ b/data/lib/urltest.js
diff --git a/data/lib/util.js b/data/lib/util.js
index f336a7f..6cbb493 100644
--- a/data/lib/util.js
+++ b/data/lib/util.js
@@ -124,14 +124,18 @@ function createDeadLink (id, text, parent, callback, params, before, covered, ac
}, false);
}
+ locParent.appendChild(newAElem);
+
if ((before === "br") || (before === true)) {
locParent.appendChild(document.createElement("br"));
}
else if (before === "dash") {
locParent.appendChild(document.createTextNode("\u00A0-\u00A0"));
}
-
- locParent.appendChild(newAElem);
+ else if (before === "parens") {
+ locParent.appendChild(document.createTextNode(")"));
+ locParent.insertBefore(document.createTextNode("("), newAElem);
+ }
}
/*
diff --git a/data/lib/viewSource.js b/data/lib/viewSource.js
new file mode 100644
index 0000000..25cba58
--- /dev/null
+++ b/data/lib/viewSource.js
@@ -0,0 +1,100 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Bugzilla Tweaks.
+ *
+ * The Initial Developer of the Original Code is Mozilla Foundation.
+ * Portions created by the Initial Developer are Copyright (C) 2010
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Johnathan Nightingale <johnath@mozilla.com>
+ * Ehsan Akhgari <ehsan@mozilla.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+var reAttachmentType = /,\s+([^ )]*)[;)]/;
+
+function viewAttachmentSource(doc) {
+ function addLink(elem, title, href) {
+ if (elem.textContent.match(/[\S]/)) {
+ elem.appendChild(doc.createTextNode(" | "));
+ }
+ var link = doc.createElement("a");
+ link.href = href;
+ link.textContent = title;
+ elem.appendChild(link);
+ }
+ var table = doc.getElementById("attachment_table");
+ if (!table)
+ return;
+ var rows = table.querySelectorAll("tr");
+ for (var i = 0; i < rows.length; ++i) {
+ var items = rows[i].querySelectorAll("td");
+ if (items.length != 3)
+ continue;
+ var links = items[0].querySelectorAll("a");
+ if (links.length == 0)
+ continue;
+ var attachHref = links[0].href;
+ // get the type of the attachment
+ var span = items[0].querySelector(".bz_attach_extra_info");
+ if (!span)
+ continue;
+ var typeName = null;
+ try {
+ // Match mime type followed by ";" (charset) or ")" (no charset)
+ typeName = span.textContent.match(reAttachmentType)[1];
+ typeName = typeName.split(";")[0]; // ignore charset following type
+ } catch (e) {}
+ if (typeName == "application/java-archive" ||
+ typeName == "application/x-jar") {
+ // Due to the fix for bug 369814, only zip files with this special
+ // mime type can be used with the jar: protocol.
+ // http://hg.mozilla.org/mozilla-central/rev/be54f6bb9e1e
+ addLink(items[2], "JAR Contents", "jar:" + attachHref + "!/");
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=369814#c5 has more possible mime types for zips?
+ } else if (typeName == "application/zip" ||
+ typeName == "application/x-zip-compressed" ||
+ typeName == "application/x-xpinstall") {
+ addLink(items[2], "Static ZIP Contents", "jar:" + attachHref + "!/");
+ } else if (typeName != "text/plain" &&
+ typeName != "patch" &&
+ // Other types that Gecko displays like text/plain
+ // http://mxr.mozilla.org/mozilla-central/source/parser/htmlparser/public/nsIParser.h
+ typeName != "text/css" &&
+ typeName != "text/javascript" &&
+ typeName != "text/ecmascript" &&
+ typeName != "application/javascript" &&
+ typeName != "application/ecmascript" &&
+ typeName != "application/x-javascript" &&
+ // Binary image types for which the "source" is not useful
+ typeName != "image/gif" &&
+ typeName != "image/png" &&
+ typeName != "image/jpeg") {
+ addLink(items[2], "Source", "view-source:" + attachHref);
+ }
+ }
+}