annotate static/js/download.js @ 308:b7d326bc57f9

Detect Mac OS 10.6
author David Soria Parra <dsp@php.net>
date Mon, 03 May 2010 09:57:58 +0200
parents 59e0087c784a
children 1de4a7a49d94
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
260
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
1 function Download() {
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
2 this.downloads = new Array();
255
4a52186008ee Add a first version of the sidebar
David Soria Parra <dsp@php.net>
parents:
diff changeset
3 }
4a52186008ee Add a first version of the sidebar
David Soria Parra <dsp@php.net>
parents:
diff changeset
4
260
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
5 Download.prototype = {
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
6
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
7 parse_os: function() {
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
8 var OSName="Source code";
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
9 if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
308
b7d326bc57f9 Detect Mac OS 10.6
David Soria Parra <dsp@php.net>
parents: 303
diff changeset
10 if (navigator.appVersion.indexOf("Mac")!=-1) {
b7d326bc57f9 Detect Mac OS 10.6
David Soria Parra <dsp@php.net>
parents: 303
diff changeset
11 if (navigator.userAgent.indexOf("10.6")!=-1 || /* firefox */
b7d326bc57f9 Detect Mac OS 10.6
David Soria Parra <dsp@php.net>
parents: 303
diff changeset
12 navigator.userAgent.indexOf("10_6") !=-1) { /* chrome */
b7d326bc57f9 Detect Mac OS 10.6
David Soria Parra <dsp@php.net>
parents: 303
diff changeset
13 OSName="Mac OS X 10.6";
b7d326bc57f9 Detect Mac OS 10.6
David Soria Parra <dsp@php.net>
parents: 303
diff changeset
14 } else {
b7d326bc57f9 Detect Mac OS 10.6
David Soria Parra <dsp@php.net>
parents: 303
diff changeset
15 OSName="Mac OS X 10.5";
b7d326bc57f9 Detect Mac OS 10.6
David Soria Parra <dsp@php.net>
parents: 303
diff changeset
16 }
b7d326bc57f9 Detect Mac OS 10.6
David Soria Parra <dsp@php.net>
parents: 303
diff changeset
17 }
260
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
18 if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
19 if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
20
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
21 return OSName;
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
22 },
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
23
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
24 os_detection: function() {
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
25 document.write(this.parse_os());
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
26 },
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
27
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
28 os_link: function() {
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
29 document.location.href = this.downloads[this.parse_os()];
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
30 },
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
31
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
32 register_download:function(type, url) {
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
33 this.downloads[type] = url;
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
34 }
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
35 }