Re: primer javascript

> I already mentioned in our personal email exchange that I think the scripts
> are fine now. But looking at the code again, I was a little bit surprised that
> your solution looks more complicated than I had imagined.
> 
> You have inserted script snippets in two places at the end of the document:
> 
> (1) At the end of the primer HTML, there is a <script>-block that just runs
> primerOnLoad(): <script type=3D"text/javascript">primerOnLoad();</script>
> 
> (2) After that, there is a block that registers an runOnloadHook which I did
> not find defined anywhere in the current page:
> 
> <script type=3D"text/javascript">if (window.runOnloadHook)=20
> runOnloadHook();</script>
> 
> 
> I think (2) is not used at the moment

Right, that was a mistake, a leftover from my first attempt to handle
this.  I've taken it out of my code, so it should come out when I next
generate drafts.

> and (1) may not be fully robust (or maybe it is, not sure). 

Yeah, I used to think it was a bad practice, but it's what mediawiki
actually does, so I figured it was good enough. 


> What I would have done was to begin the body with=20
> <body onload=3D"primerOnLoad()">. This is what I meant in my earlier mail o=
> n the=20
> issue (obviously, this cannot be done in the wiki, since <body> is produced=
>  by=20
> the software, hence the hook there). But maybe the current solution (1) is=
> =20
> okay, it just feels somewhat hacky since the script is run on the DOM of a=
> =20
> partially loaded page (try putting (1) higher up in the document: it works=
> =20
> only for things that have been loaded before; so I guess some DOM=20
> completion/repair must be done in the browser to execute the script).

Yeah, for my code (as for media wiki) it's kind of hard to put it on the
<body> element.

     -- Sandro

Received on Wednesday, 10 June 2009 17:13:44 UTC