annotate src/en/javascript/main.js @ 61:16016cc18ded

Backed out changeset baf1530ba0b0
author David Soria Parra <dsp@php.net>
date Wed, 18 Feb 2009 01:19:32 +0100
parents baf1530ba0b0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
29
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
1 // http://simonwillison.net/2004/May/26/addLoadEvent/
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
2 function addLoadEvent(func) {
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
3 var oldonload = window.onload;
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
4 if (typeof window.onload != 'function') {
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
5 window.onload = func;
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
6 } else {
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
7 window.onload = function() {
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
8 if (oldonload) {
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
9 oldonload();
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
10 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
11 func();
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
12 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
13 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
14 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
15
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
16 var xmlhttp = null;
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
17
61
16016cc18ded Backed out changeset baf1530ba0b0
David Soria Parra <dsp@php.net>
parents: 54
diff changeset
18 function loadXMLDoc(url) {
29
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
19 if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc.
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
20 xmlhttp = new XMLHttpRequest();
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
21 } else if (window.ActiveXObject) {// code for IE6, IE5
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
22 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
23 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
24 if (xmlhttp != null) {
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
25 xmlhttp.onreadystatechange = stateChange;
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
26 xmlhttp.open("GET",url,true);
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
27 xmlhttp.send(null);
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
28 } else {
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
29 alert("Your browser does not support XMLHTTP.");
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
30 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
31 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
32
61
16016cc18ded Backed out changeset baf1530ba0b0
David Soria Parra <dsp@php.net>
parents: 54
diff changeset
33 function stateChange() {
29
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
34 if (xmlhttp.readyState==4) {// 4 = "loaded"
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
35 document.getElementById('replace').innerHTML = xmlhttp.responseText;
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
36 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
37 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
38
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
39 addLoadEvent(function () {
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
40 if (navigator.appVersion.indexOf("Win")!=-1) {
61
16016cc18ded Backed out changeset baf1530ba0b0
David Soria Parra <dsp@php.net>
parents: 54
diff changeset
41 loadXMLDoc("win.html");
29
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
42 }
18110c461824 js: loading another content if OS is Win
Alexander Solovyov <piranha@piranha.org.ua>
parents:
diff changeset
43 });