By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,070 Members | 1,237 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,070 IT Pros & Developers. It's quick & easy.

Improving bugzilla and hitting the wall

P: n/a
I am trying to write new GM script after couple of months of not
working with Firefox at all, and I am hitting the wall even with the
simplest preliminary steps to it. What I would like to achieve is to
add key shortcut for setting status of the bug to NEEDINFO and
information required from the reporter (which is like 75 % of bugs I
manage). For that I would like to add new <Aelement to the end of the
bottom button bar (see e.g.
https://bugzilla.redhat.com/bugzilla....cgi?id=212188 which is
the bug where I am testing my script) just behind the words "Format for
printing" with acceskey and event listener calling function in the
script.

However, just the preliminary attempts to add simple text node and an
empty element are miserably failing and I cannot find why (JavaScript
console is silent):

// Some embellishments to RH Bugzilla
// version 0.1 ALPHA!
// 2006-01-02
// Copyright (c) 2006, Matěj Cepl
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
//
// ==UserScript==
// @name Bugzilla Improved
// @namespace http://www.ceplovi.cz/matej/progs/scripts
// @description some embellishments for RH Bugzilla
// @include
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=*
// ==/UserScript==

//function needInfoReporter(event) {
// alert("Event happened!");
// event.preventDefault();
// return false;
//}

//var StatusSelectTag = document.getElementsByName("newstatus");

//id('navigate')/table/tbody/tr/td[2]/a[3]

//var buttonTab = document.evaluate(
// '//div[@id="navigate"]//td[@align="right"]',
// document.body,
// null,
// XPathResult.ANY_UNORDERED_NODE_TYPE,
// null);
var buttonTab =
document.getElementById("navigate").getElementsByT agName("TD")[1];

var delimiterNode = document.createTextNode("&nbsp;|&nbsp;");
//var newNode = document.createElement("a");
//var newNodeText = document.createTextNode("NEEDINFO from reporter");
//newNode.appendChild(newNodeText);
//newNode.accessKey = "R";
//newNode.addEventListener('click', needInfoReporter, false);

//if (buttonTab.lastChild.nodeType==3) {
buttonTab.replaceChild(delimiterNode,buttonTab.las tChild);
//};
//buttonTab.appendChild(delimiterNode);
//buttonTab.appendChild(newNode);

--------------------------------------------------------------------------------

Any idea what's going on, please?

Thanks a lot,

Matěj

Jan 3 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
matej wrote:
I am trying to write new GM script after couple of months of not
working with Firefox at all, and I am hitting the wall even with the
simplest preliminary steps to it. What I would like to achieve is to
add key shortcut for setting status of the bug to NEEDINFO and
information required from the reporter (which is like 75 % of bugs I
manage). For that I would like to add new <Aelement to the end of the
bottom button bar (see e.g.
https://bugzilla.redhat.com/bugzilla....cgi?id=212188 which is
the bug where I am testing my script) just behind the words "Format for
printing" with acceskey and event listener calling function in the
script.
var buttonTab =
document.getElementById("navigate").getElementsByT agName("TD")[1];
There is only one cell in that table in the div id="navigate" element so
to find that cell you need e.g.

var buttonTab =
document.getElementById("navigate").getElementsByT agName("TD")[0];

I don't remember for sure however whether Greasemonkey script accessing
the DOM of the page need to be run in a load event listener. You might
want to try to put your code accessing those elements and adding stuff
in a load event listener.
var delimiterNode = document.createTextNode("&nbsp;|&nbsp;");
createTextNode expects plain text not HTML markup (and character/entity
references like &nbsp; are markup) so you need e.g.
buttonTab.appendChild(document.createTextNode('\u0 0A0|\u00A0'));
to insert those characters as a text node in the cell.


--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 3 '07 #2

P: n/a
On Jan 3, 3:39 pm, Martin Honnen <mahotr...@yahoo.dewrote:
There is only one cell in that table in the div id="navigate" element so
to find that cell you need e.g.
either I am blind of stupid, but I see two TD elements on page
https://bugzilla.redhat.com/bugzilla....cgi?id=212188 -- one
with align="left" and other with align="right". Moreover, I have tested
existence of the second cell with alert(buttonTab.nodeType);
I don't remember for sure however whether Greasemonkey script accessing
the DOM of the page need to be run in a load event listener. You might
want to try to put your code accessing those elements and adding stuff
in a load event listener.
Do you have any examples of such listener?
var delimiterNode = document.createTextNode("&nbsp;|&nbsp;");createTex tNode expects plain text not HTML markup (and character/entity
references like &nbsp; are markup) so you need e.g.
buttonTab.appendChild(document.createTextNode('\u0 0A0|\u00A0'));
to insert those characters as a text node in the cell.
Hmm, tried that (I use replaceChild, because the lastChild of buttonTab
is apparently textNode):

var delimiterNode = document.createTextNode('\u00A0|\u00A0');
buttonTab.replaceChild(delimiterNode,buttonTab.las tChild);

but still no difference on the page and no message in the Javascript
console.

Any more ideas, please? Thanks for the response so far.

Matěj

Jan 3 '07 #3

P: n/a
matej wrote:
>I don't remember for sure however whether Greasemonkey script accessing
the DOM of the page need to be run in a load event listener. You might
want to try to put your code accessing those elements and adding stuff
in a load event listener.

Do you have any examples of such listener?
function loadHandler (evt) {
// put code here to run once the document has been loaded
}

window.addEventListener('load', loadHandler, false);
--

Martin Honnen
http://JavaScript.FAQTs.com/
Jan 5 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.