aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/bugzillaDOMFunctions.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/lib/bugzillaDOMFunctions.js')
-rw-r--r--data/lib/bugzillaDOMFunctions.js86
1 files changed, 53 insertions, 33 deletions
diff --git a/data/lib/bugzillaDOMFunctions.js b/data/lib/bugzillaDOMFunctions.js
index f58f0d9..4437e7c 100644
--- a/data/lib/bugzillaDOMFunctions.js
+++ b/data/lib/bugzillaDOMFunctions.js
@@ -4,13 +4,13 @@
/**
* Select option with given value on the <SELECT> element with given id.
- *
+ *
* Also execute change HTMLEvent, so that the form behaves accordingly.
- *
+ *
* @param id
* @param label
* @return none
- *
+ *
*/
function selectOption (id, label, fireEvent) {
if (!fireEvent) {
@@ -48,15 +48,16 @@ function selectOptionByLabel(id, label, fireEvent) {
/**
* Add object to the text box (comment box or status whiteboard)
- *
+ *
* @param id
* String with the id of the element
* @param stuff
* String/Array to be added to the comment box
- *
+ *
* @return none
*/
function addStuffToTextBox (id, stuff) {
+ var saveFocus = document.activeElement;
var textBox = document.getElementById(id);
if (textBox.tagName.toLowerCase() === "textarea") {
stuff = textBox.value ? "\n\n" + stuff : stuff;
@@ -65,11 +66,12 @@ function addStuffToTextBox (id, stuff) {
else {
textBox.value = addCSVValue(textBox.value,stuff);
}
+ saveFocus.focus();
}
/**
* Remove a keyword from the element if it is there
- *
+ *
* @param id
* String with the id of the element
* @param stuff
@@ -82,7 +84,7 @@ function removeStuffFromTextBox (id, stuff) {
/**
* generalized hasKeyword ... search in the value of the box with given id
- *
+ *
* @param id
* String with ID of the element we want to check
* @param str
@@ -102,7 +104,7 @@ function idContainsWord (id, str) {
/**
* Check for the presence of a keyword
- *
+ *
* @param str
* String with the keyword
* @return Boolean
@@ -113,9 +115,9 @@ function hasKeyword (str) {
/**
* Set the bug to NEEDINFO state
- *
+ *
* Working function.
- *
+ *
* @return none
* @todo TODO we may extend this to general setNeedinfo function with parameter
* [reporter|assignee|general-email-address]
@@ -126,7 +128,7 @@ function setNeedinfoReporter () {
}
/**
- *
+ *
*/
function getOwner () {
// TODO(maemo) doesn't work on maemo
@@ -137,7 +139,7 @@ function getOwner () {
/**
* Return maintainer which is per default by bugzilla (which is not necessarily
* the one who is default maintainer per component)
- *
+ *
* @return String with the maintainer's email address
*/
function getDefaultBugzillaMaintainer (component) {
@@ -147,7 +149,7 @@ function getDefaultBugzillaMaintainer (component) {
/**
* 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.
- *
+ *
* @param location
* Object around which the new button will be added
* @param after
@@ -207,7 +209,7 @@ function createNewButton (location, after, cmdObj) {
/**
* Get the current title of the bug
- *
+ *
* @return string
*/
function getSummary() {
@@ -216,7 +218,7 @@ function getSummary() {
/**
* Get the current title of the bug
- *
+ *
* @return string
*/
function getSeverity() {
@@ -225,7 +227,7 @@ function getSeverity() {
/**
* Get the current email of the reporter of the bug.
- *
+ *
* @return string
*/
function getReporter () {
@@ -265,7 +267,7 @@ function commentsWalker (fce) {
/**
* collect the list of attachments in a structured format
- *
+ *
* @return Array of arrays, one for each attachments; each record has string
* name of the attachment, integer its id number, string of MIME type,
* integer of size in kilobytes, and the whole element itself
@@ -282,7 +284,7 @@ function getAttachments () {
/**
* Get login of the currently logged-in user.
- *
+ *
* @return String with the login name of the currently logged-in user
*/
function getLogin () {
@@ -294,7 +296,7 @@ function getLogin () {
/**
* adds a person to the CC list, if it isn't already there
- *
+ *
* @param who
* String with email address or "self" if the current user of the
* bugzilla should be added
@@ -316,7 +318,7 @@ function addToCCList (who) {
/**
* a collect a list of emails on CC list
- *
+ *
* @return Array with email addresses as Strings.
*/
function getCCList () {
@@ -332,11 +334,11 @@ function getCCList () {
/**
* remove elements from the page based on their IDs
- *
+ *
* @param doc
* Document object
* @param target
- * String/Array with ID(s)
+ * Array with querySelector parameters
* @param remove
* Boolean indicating whether the node should be actually removed or
* just hidden.
@@ -344,21 +346,39 @@ function getCCList () {
* 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";
+ var victimElements = [];
+
+ target.forEach(function(x) {
+ var targetNode = doc.querySelector(x);
+ if (targetNode) {
+ if (remove) {
+ console.log("killing element " + targetNode);
+ victimElements.push([x,targetNode]);
+ }
+ else {
+ targetNode.style.display = "none";
+ }
}
});
+
+ var elem = {};
+ // Don't run victimElements.forEach here as we are effectively
+ // removing its members.
+ for(var i = 0, ii = victimElements.length; i < ii; i++) {
+ elem = victimElements[i];
+ try {
+ elem[1].parentNode.removeChild(elem[1]);
+// elem[1].style.backgroundColor = "red";
+ }
+ catch (e if e instanceof TypeError) {
+ console.error("Cannot remove: " + elem[0]);
+ }
+ }
}
/**
* Is this bug a RHEL bug?
- *
+ *
* @return Boolean true if it is a RHEL bug
*/
function isEnterprise() {
@@ -370,7 +390,7 @@ function isEnterprise() {
/**
* Find out whether the bug is needed an attention of bugZappers
- *
+ *
* @return Boolean whether the bug has been triaged or not
*/
function isTriaged() {
@@ -379,7 +399,7 @@ function isTriaged() {
/**
* Return string with the ID for the external_id SELECT for external bugzilla
- *
+ *
* @param URLhostname
* String hostname of the external bugzilla
* @return String with the string for the external_id SELECT