I am trying to rewrite my rather largish Greasemonkey script
(http://mcepl.fedorapeople.org/scripts/bugzillaBugTriage.user.js) into
Jetpack (currently
http://mcepl.fedorapeople.org/scripts/bugzillaBugTriage.jetpack.js) and
I have to admit I am not succesful. I am working on differences (mainly
different scope for variables) by rewriting into jQuery one-liners (my
original script is very pure DOM), but now I hit this very strange
statement:
Error: document.getElementById is not a function
Source file:
file:///home/matej/.mozilla/firefox/o0b919i8.jetpack/extensions/jet...@labs.mozilla.com/content/js/ext/jquery.js
Line: 61
What?
I am currently using jetpack 0.6pre2, because 0.5 doesn't seem to be
available in Linux/x86_64 version, which leads me to another question:
will be Linux/x86_64 officially supported in 0.6 when it is released?
Third question is whether it is possible to use full strength of Firebug
for debugging jetpacks (that was one thing I missed with Greasemonkey)?
Could I put breakpoints into Jetpack code, stepping through it, etc.?
Also, somehow most of the error messages still goes to plain Firefox
Javascript console instead of the Firebug's one. Is it PEBKAC? Should I
configure something somewhere?
Thanks a lot for any replies,
Matěj Cepl
--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
Pain is inevitable, but misery is optional. We cannot avoid pain,
but we can avoid joy.
-- Tim Hansel
Can be related to jquey sandboxing (introduced from jetpack 0.5
as security feature).
Have you tried to pass the document objecte as second parameter of the
jQuery function?
Something like:
$("#myid", doc)
Happy hacking,
Luca Greco @ Alca Società Cooperativa
Hmm, now it is even more weird ...
Error: document is not defined
Source file:
file:///home/matej/Dokumenty/projekty/triage/jetpack/bugzillaBugTriage.js
Line: 1369
when having this code
if (debug) {
$("#bz_field_status",document).append("<span
inline='font-size:x-small'>"+jsonDataURL+"</span>");
}
BTW, the file itself is available as
http://git.fedoraproject.org/git/triage.git?p=triage.git;a=blob_plain;f=jetpack/bugzillaBugTriage.js;hb=jetpack
(or http://is.gd/4LZEn if the previous URL gets badly broken).
Any ideas?
Matěj
because document is not defined in your main function's scope (remember
all your jetpack is sandboxed so there's not any document or window object
in global scope, as you surely have in a webcontent javascript script)
Try something like this:
function main(document) {
...
}
...
var callback = function(document) {
jetpack.statusBar.append({
onReady: function(widget) {
console.log("Boom!");
main(document);
},
});
};
---
+1000
I am now immersing myself into wonderful deep waters of OOP with
Javascript (because of global variables I don't have access to
otherwise; see bzPage on
http://git.fedorahosted.org/git/?p=triage.git;a=blob_plain;f=jetpack/bugzillaBugTriage.js;hb=jetpack),
but I really don't think this is for anyone “who can build a Web site”
(as advertised on Jetpack web page). Actually, I would say that it is
much more complicated than Greasemonkey script ever was (which is where
my script is coming from, so I know what I am talking about).
It is certainly still much less complicated than writing a proper
Firefox extension, which is what I was planning to do, so I will stick
with Jetpack for some time more, but I am quite sure I have hit couple
of thresholds of pain for most Greasemonkey script writers.
I guess we need our own wrapper around jQuery object which would hide
all this “document is not document” stuff?
Moreover, nobody answered my question about Firebug. I have now two
types of error messages (when I hit refresh button in about:jetpack, and
when I reload the page where pageMods activates) which are going
seemingly randomly to Firebug console and to the original Firefox
Javascript console. And console.log goes always to Firefox Javascript
console. Seems kind of messy.
Matěj
--
http://www.ceplovi.cz/matej/, Jabber: mcepl<at>ceplovi.cz
GPG Finger: 89EF 4BC6 288A BF43 1BAB 25C3 E09F EF25 D964 84AC
Nemo plus iuris ad alium transfere potest quam ipse habet.