Re: primer javascript

On Sonntag, 31. Mai 2009, Sandro Hawke wrote:
> [reply to myself]
>
> > It's not clear to me how to get your onLoad function to work without
> > lots of mediawiki javascript that I don't think we should include in a
> > TR.  Can you trim it down to work without mediawiki code?  Thanks.
>
> Ah, I think I got it.  Please check it, though.

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="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="text/javascript">if (window.runOnloadHook) 
runOnloadHook();</script>


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

Markus

>
>      -- Sandro


-- 
Markus Krötzsch
Institut AIFB, Universität Karlsruhe (TH), 76128 Karlsruhe
phone +49 (0)721 608 7362          fax +49 (0)721 608 5998
mak@aifb.uni-karlsruhe.de          www  http://korrekt.org

Received on Tuesday, 2 June 2009 06:59:10 UTC