aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bzpage.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-09-18 23:32:09 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-09-18 23:32:09 +0200
commit88112016166ac10e7ed2848c9562bed211918748 (patch)
tree0738e884d8c156e42f42fa685f0b3726a0fd1d37 /lib/bzpage.js
parent91e43addcad1bb62ee54204143698c154e90a638 (diff)
downloadbugzilla-triage-88112016166ac10e7ed2848c9562bed211918748.tar.gz
First working version.
Missing AJAX-style adding an attachment row to the attachment table. Add createDeadLink function, we don't need to use href='#'
Diffstat (limited to 'lib/bzpage.js')
-rw-r--r--lib/bzpage.js55
1 files changed, 47 insertions, 8 deletions
diff --git a/lib/bzpage.js b/lib/bzpage.js
index cbaae12..96ad655 100644
--- a/lib/bzpage.js
+++ b/lib/bzpage.js
@@ -99,7 +99,7 @@ var BZPage = function BZPage(win, config) {
if ("killNodes" in config.gJSONData.configData &&
this.hostname in config.gJSONData.configData.killNodes) {
var killConf = config.gJSONData.configData.killNodes[this.hostname];
- util.killNodes(this.doc, killConf[0], killConf[1])
+ util.killNodes(this.doc, killConf[0], killConf[1]);
}
this.setConfigurationButton();
@@ -152,7 +152,7 @@ BZPage.prototype.getRealBugNo = function () {
Request({
url: this.win.location.href+"&ctype=xml",
onComplete: function() {
- if (this.response.status == 200) {
+ if (this.response.status === 200) {
var xmlRepr = this.response.xml;
var bugID = parseInt(xmlRepr.getElementsByTagName("bug_id")[0].textContent, 10);
if (isNaN(bugID)) {
@@ -161,7 +161,7 @@ BZPage.prototype.getRealBugNo = function () {
that.bugNo = bugID;
console.log("The real bug no. is " + bugID);
}
- },
+ }
}).get();
};
@@ -406,6 +406,41 @@ BZPage.prototype.addToCommentsDropdown = function addToCommentsDropdown (pkg, cm
};
/**
+ * Create a A element leadink nowhere, but with listener running a callback on the click
+ *
+ * @param id String with a id to be added to the element
+ * @param text String with a string to be added as a textContent of the element
+ * @param parent Node which is a parent of the object
+ * @param callback Function to be called after clicking on the link
+ * @param params Array with parameters of the callback
+ * @param Boolean breakBefore if there should be a <br> element before.
+ * @return none
+ */
+BZPage.prototype.createDeadLink = function createDeadLink (id, text, parent, callback, params, breakBefore, accesskey) {
+ var that = this;
+ var newAElem = this.doc.createElement("a");
+ params = util.valToArray(params);
+ newAElem.setAttribute("id", id);
+ if (accesskey) {
+ newAElem.setAttribute("accesskey", accesskey);
+ }
+ newAElem.setAttribute("href", "");
+ newAElem.textContent = text;
+
+ newAElem.addEventListener("click", function(evt) {
+ callback.apply(that, params);
+ evt.stopPropagation();
+ evt.preventDefault();
+ }, false);
+
+ if (breakBefore) {
+ parent.appendChild(this.doc.createElement("br"));
+ }
+ parent.appendChild(newAElem);
+};
+
+
+/**
* Generic function to add new button to the page. Actually copies new button
* from the old one (in order to have the same look-and-feel, etc.
*
@@ -456,7 +491,7 @@ BZPage.prototype.createNewButton = function createNewButton (location, after, pk
.createTextNode("\u00A0"), originalLocation);
}
} catch (e if e instanceof TypeError) {
- console.log("cannot find originalLocation element with id " + location);
+ console.error("cannot find originalLocation element with id " + location);
}
};
@@ -500,7 +535,7 @@ BZPage.prototype.generateButtons = function generateButtons () {
BZPage.prototype.setConfigurationButton = function setConfigurationButton () {
var additionalButtons = this.doc.querySelector("#bugzilla-body *.related_actions");
var configurationButtonUI = this.doc.createElement("li");
- configurationButtonUI.innerHTML = "\u00A0-\u00A0<a href='#' id='configurationButton'>"
+ configurationButtonUI.innerHTML = "\u00A0-\u00A0<a href='' id='configurationButton'>"
+ "Triage configuration</a>";
additionalButtons.appendChild(configurationButtonUI);
this.doc.getElementById("configurationButton").addEventListener(
@@ -898,7 +933,7 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
}
var generateTimeSheetUI = this.doc.createElement("li");
- generateTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='#' id='generateTSButton'>"
+ generateTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='' id='generateTSButton'>"
+ "Generate TS</a>";
additionalButtons.appendChild(generateTimeSheetUI);
this.doc.getElementById("generateTSButton").addEventListener(
@@ -911,7 +946,7 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
}, false);
var ImportTimeSheetUI = this.doc.createElement("li");
- ImportTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='#' id='importTSButton'>"
+ ImportTimeSheetUI.innerHTML = "\u00A0-\u00A0<a href='' id='importTSButton'>"
+ "Import TS</a>";
additionalButtons.appendChild(ImportTimeSheetUI);
this.doc.getElementById("importTSButton").addEventListener(
@@ -932,10 +967,12 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
} else {
console.error("File " + jsonPaths + " doesn't exist!");
}
+ evt.stopPropagation();
+ evt.preventDefault();
}, false);
var clearLogsUI = this.doc.createElement("li");
- clearLogsUI.innerHTML = "\u00A0-\u00A0<a href='#' id='clearLogs'>"
+ clearLogsUI.innerHTML = "\u00A0-\u00A0<a href='' id='clearLogs'>"
+ "Clear TS</a>";
additionalButtons.appendChild(clearLogsUI);
var clearLogAElem = this.doc.getElementById("clearLogs");
@@ -944,6 +981,8 @@ BZPage.prototype.setUpLogging = function setUpLogging () {
this.style.color = that.log.EmptyLogsColor;
this.style.fontWeight = "normal";
console.log("this.store wiped out!");
+ evt.stopPropagation();
+ evt.preventDefault();
}, false);
if (this.log.store.length > 0) {