Today I had to build something so I needed to add multiple functions to the window.onload event
So what I discovered today is when you use the following snippet for attaching events .. They don’t get loaded in the right order by this I mean Firefox fires the one that says yay first and then the again one… IE fires first the latter and then the first. Nothing to be worried about for the moment,in my case at least, but when you need it to initialise some functions.. it can get you into a lot of head scratching.
function myAddEvent(obj, event, listener, useCapture) {
// Non-IE
if(obj.addEventListener) {
if(!useCapture) useCapture = false;
obj.addEventListener(event, listener, useCapture);
return true;
}
// IE
else if(obj.attachEvent) {
return obj.attachEvent(‘on’+event, listener);
}
}
function myListener() {
alert(‘yay’);
}
function myListener2() {
alert(‘yay again’);
}
myAddEvent(window, ‘load’, myListener);
myAddEvent(window, ‘load’, myListener2);
I thought I was busy before I got this thing on my hand. Now it’s even worse.
I don’t know where to crawl first.
I got my MYOB professional partner subscription last week and am trying to integrate it now in the program I’m writing. And I have to say.. It’s not all that hard.. just open the docs and you’re good to go.
But what annoys the hell out of me, apart from not being able to run myob on a win2k3 server, is that myob is slow as a dog. A request can easily take up to 30 seconds to complete. This gives me an excuse to delve into the async pattern. It appeals a lot to me.. but seens as I ‘m always pressed for time I don’t get to experiment all that often.. But this problem does give me the necessity to do it.
Maybe I will post my findings later. If the async pattern doesn’t give me a good viable solution to my problem I have another way of going about it. SQL server 2005 supports managed code, which we are all very aware off, so I can reference and consume a webservice and stick all the myob datatable queries in a sql db as xml, index it and it is also searchable.
But first let’s get to the async pattern..
I have been suffering from tendonitis and I found the time was come to take a break. So did my doctor who told me no pc for one month.. Well this has just been horrible because on top of not using a pc I was also banned from writing. In fact it was better to just not use or move my right hand completely.
Uhm, I failed
The writing no problemo I hardly ever write on a piece of paper (Save the trees !!!). The not using my right hand, well i interpreted unless you absolutely have to, because even now I still can’t roll a cigarette with only my left (bad) hand.
The not using a pc .. let’s say : Hello Dragon Natural Speaking. That’s the name of my new friend
It took a while before it recognized my english, I’m suffering from a bad accent, somewhere between German and Dutch I’m told.
But programming C# or Javascript with natural speaking is not what you want to do, so my pc usage was limited to writing English mails and having English chats or skyping to some the friends.
Anyway I’m back in action now and am not planning to take a break for some time to come.