diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-05-06 19:46:42 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-05-06 19:46:42 +0200 |
commit | 26d9750031c4c45cb63feb0c0bce2f8ac7de238e (patch) | |
tree | 3a3e413985c05591993aa170d34cd857b5375d3b /data | |
parent | 63c0e1c9ebeacb7bf103fcd35f7ee03d5f432756 (diff) | |
download | bugzilla-triage-26d9750031c4c45cb63feb0c0bce2f8ac7de238e.tar.gz |
Removing unimportant parts of the page as a prevention against #65
There is now complete analysis of the issue, but I don’t know how to fix
it, because we just write into various input boxes and they got focus (and
subsequently Firefox makes them visible).
Diffstat (limited to 'data')
-rw-r--r-- | data/lib/bugzillaDOMFunctions.js | 86 | ||||
-rw-r--r-- | data/lib/bzpage.js | 2 |
2 files changed, 55 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 diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js index 296fe29..7b8a764 100644 --- a/data/lib/bzpage.js +++ b/data/lib/bzpage.js @@ -215,6 +215,7 @@ function changeAssignee (newAssignee) { } } + var saveFocus = document.activeElement; if (newAssignee) { clickMouse("bz_assignee_edit_action"); document.getElementById("assigned_to").value = newAssignee; @@ -224,6 +225,7 @@ function changeAssignee (newAssignee) { defAssigneeButton.style.display = "none"; } } + saveFocus.focus(); } /** |