aboutsummaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2011-02-01 16:28:51 +0100
committerMatěj Cepl <mcepl@redhat.com>2011-02-01 16:28:51 +0100
commitc1ec772b104316530f6737340355205398df33af (patch)
tree98385a10209cef7ee528fb2d536ef5c15bdf0d7e /data
parentab4f262d119fefe06bea938400ee8ff64bed7ab1 (diff)
downloadbugzilla-triage-c1ec772b104316530f6737340355205398df33af.tar.gz
This actually almost looks like working, so much I can file bugs.
Diffstat (limited to 'data')
-rw-r--r--data/bzpage.js104
1 files changed, 80 insertions, 24 deletions
diff --git a/data/bzpage.js b/data/bzpage.js
index 11b38c7..ced0181 100644
--- a/data/bzpage.js
+++ b/data/bzpage.js
@@ -30,7 +30,6 @@ function Message(cmd, data) {
console.log("Message: cmd = " + cmd + ", data = " + data);
this.cmd = cmd;
this.data = data;
- console.log("Message JSONified: " + JSON.stringify(this));
}
function log(msg) {
@@ -50,7 +49,6 @@ NotLoggedinException.prototype.toString = function () {
* central handler processing messages from the main script.
*/
onMessage = function onMessage(msg) {
- console.log("onMessage: msg = " + msg.toSource());
switch (msg.cmd) {
case "ReloadThePage":
document.location.reload(true);
@@ -64,7 +62,7 @@ onMessage = function onMessage(msg) {
break;
case "CreateButtons":
constantData = msg.data.constData;
- generateButtons(msg.data.instPkgs);
+ generateButtons(msg.data.instPkgs, msg.data.kNodes);
break;
case "Error":
alert("Error " + msg.data);
@@ -191,6 +189,29 @@ function centralCommandDispatch (cmdLabel, cmdParams) {
}
/**
+ * remove elements from the page based on their IDs
+ *
+ * @param doc Document object
+ * @param target String/Array with ID(s)
+ * @param remove Boolean indicating whether the node should be
+ * actually removed or just hidden.
+ * @return none
+ * TODO remove parameter could be replaced by function which would
+ * do actual activity.
+ */
+function killNodes(doc, target, remove) {
+ var targetArr = target instanceof Array ? target : target.trim().split(/[,\s]+/);
+ targetArr.forEach(function(x) {
+ if (remove) {
+ var targetNode = doc.getElementById(x);
+ targetNode.parentNode.removeChild(targetNode);
+ } else {
+ x.style.display = "none";
+ }
+ });
+}
+
+/**
* Change assignee of the bug
*
* @param newAssignee String with the email address of new assigneeAElement
@@ -370,10 +391,18 @@ function createNewButton (location, after, cmdObj) {
/**
* Generate button based on
*/
-function generateButtons (pkgs) {
+function generateButtons (pkgs, kNodes) {
var topRowPosition = "topRowPositionID";
var bottomRowPosition = "commit";
+ setUpLogging();
+
+ // =========================================================
+ if (kNodes && window.location.hostname in kNodes) {
+ var killConf = killNodes[window.location.hostname];
+ killNodes(document, killConf[0], killConf[1]);
+ }
+
// create anchor for the top toolbar
var commentBox = document.getElementById("comment");
var brElement = document.createElement("br");
@@ -386,10 +415,10 @@ function generateButtons (pkgs) {
var cmdObj = pkgs[pkg][cmdIdx];
switch (cmdObj.position) {
case "topRow":
- createNewButton(topRowPosition, cmdObj, false);
+ createNewButton(topRowPosition, false, cmdObj);
break;
case "bottomRow":
- createNewButton(bottomRowPosition, cmdObj, false);
+ createNewButton(bottomRowPosition, false, cmdObj);
break;
case "dropDown":
addToCommentsDropdown(cmdObj);
@@ -744,8 +773,27 @@ function getLogin () {
return loginStr;
}
+function addLogRecord() {
+ var rec = {};
+ rec.date = new Date();
+ rec.url = document.location.toString();
+ rec.title = document.title;
+ var comment = window.prompt(
+ "Enter comments for this comment");
+ if (comment && comment.length > 0) {
+ comment = comment.trim();
+ rec.comment = comment;
+ var dateStr = getISODate(rec.date);
+ var urlStr = window.location.hostname;
+ rec.key = dateStr + "+" +
+ urlStr + "+" + getBugNo();
+ postMessage(new Message("AddLogRecord", rec));
+ return rec;
+ }
+ return null;
+}
+
/**
- * TODO THIS IS COMPLETELY BROKEN AND NEED TO BE REWRITTEN
*/
function setUpLogging () {
// Protection against double-call
@@ -753,9 +801,6 @@ function setUpLogging () {
return ;
}
- // TODO fix later
- return ; // switched off for now
-
// For adding additional buttons to the top toolbar
var additionalButtons = document.querySelector("#bugzilla-body *.related_actions");
var that = this;
@@ -763,9 +808,7 @@ function setUpLogging () {
// logging all submits for timesheet
if (!submitHandlerInstalled) {
document.forms.namedItem("changeform").addEventListener("submit",function (evt) {
- // TODO this is probably another RPC call
- var resp = that.log.addLogRecord(that);
- if (resp === null) {
+ if (addLogRecord() === null) {
evt.stopPropagation();
evt.preventDefault();
}
@@ -773,27 +816,23 @@ function setUpLogging () {
submitHandlerInstalled = true;
}
- // TODO another RPC call
// (id, text, parent, callback, params, before, covered, accesskey)
- this.createDeadLink("generateTSButton", "Generate TS", additionalButtons,
+ createDeadLink("generateTSButton", "Generate TS", additionalButtons,
function(evt) {
- that.log.createBlankPage.call(that.log, "TimeSheet",
- that.log.generateTimeSheet);
+ postMessage(new Message("GenerateTS"));
}, [], "dash", "li");
- // TODO another RPC call
- this.createDeadLink("clearLogs", "Clear TS", additionalButtons,
+ createDeadLink("clearLogs", "Clear TS", additionalButtons,
function(evt) {
- that.log.clearStore(this);
+ postMessage(new Message("ClearTS"));
}, [], "dash", "li");
- // TODO another RPC call
- this.createDeadLink("importTSButton", "Import TS", additionalButtons,
+ createDeadLink("importTSButton", "Import TS", additionalButtons,
function(evt) {
- jsonPaths = prompts.promptFileOpenPicker(that.win);
- that.log.importOtherStore(jsonPaths, clearLogAElem);
+ postMessage(new Message("ImportTS"));
}, [], "dash", "li");
+ /* TODO
var clearLogAElem = document.getElementById("clearLogs");
if (this.log.isEmpty()) {
clearLogAElem.style.color = this.log.EmptyLogsColor;
@@ -802,6 +841,7 @@ function setUpLogging () {
clearLogAElem.style.color = this.log.FullLogsColor;
clearLogAElem.style.fontWeight = "bolder";
}
+ */
}
function getSelection () {
@@ -921,6 +961,22 @@ function startup() {
// doing any harm to anybody.
}
+ // Prepare for query buttons
+ // element ID brElementPlace_location is later used in JSON files
+ // Stay with this add_comment element even if RH BZ upgrades, this seems
+ // to be generally much more stable (even with other bugzillas, e.g. b.gnome.org)
+ // then some getElementById.
+ var commentArea = document.getElementsByName("add_comment")[0].parentNode;
+ if (commentArea) {
+ var brElementPlacer = commentArea.getElementsByTagName("br");
+ brElementPlacer = brElementPlacer[0];
+ if (brElementPlacer) {
+ brElementPlacer.setAttribute("id","brElementPlacer_location");
+ brElementPlacer.parentNode.insertBefore(document.createElement("br"),
+ brElementPlacer);
+ }
+ }
+
// TODO Probably could be ignored ... used only once on line 973 of rhbzpage.js
// if (parseAbrtBacktraces && this.RE.Abrt.test(this.title)) {
// title = document.getElementById("short_desc_nonedit_display").textContent;