Just as good as a homerun in the world series…
…or a touchdown at the super-bowl.
Well, maybe not. But that’s how it feels when you figure out a chunk of code you’ve been trying to master for 2 months.
I almost yelled “YYYYYEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESSSSSSSSSSSSS!!!!!!!!” in the middle of my office.
If you ever visit my (poorly organized) website, you’ll know that I am working on a firefox extension. The “Status-Bar Calculator”. The thing I’ve been stuck on for two months is how to make something move to a certain location on the status bar upon the browser loading.
The logic is simple (now that I know it) and I’ll outline it on my site soon, but basically it goes like this:
in your .js file add an event listener to listen for a “load” event that fires a function when detected. (basically, when the browser or a new window starts up, run such and such function)
In the function, get the calculator, and remove it from the status-bar (since it gets added at a default location when the browser starts up, you have to remove it to move it) using the “remove child” attribute/function/thing from the status-bar.
Then ADD it at whatever location is specified in the user preferences (using the appendChild function/attribute/thing of the status-bar).
The code is as follows:
function events() { var sbar = document.getElementById("status-bar"); var sbarPanel = document.getElementById("my-panel234");
sbar.removeChild(sbarPanel);
var pos = 1;//this is where you would grab the preference and apply it to pos sbar.insertBefore(sbarPanel, sbar.childNodes[pos]);}
window.addEventListener("load", function(e) { events(); alert("events fired");}, false);
WHY ISN’T THIS IN THE DOCUMENTATION, OR ANYWHERE ON THE WEB????? Maybe it’s just too common sense to everyone else in the world, and nobody thought anybody would have to be TOLD how to do it… Maybe I’m just that dumb. Oh, well. It’s here now, and soon on my site… And I guess the documentation is a wiki, so I can put it there too if I feel like it…

