annotate static/js/download.js @ 314:657b465caaa2

Download::downloads property is used as a hash object, not array.
author Laurens Holst <laurens.hg@grauw.nl>
date Sun, 16 May 2010 14:48:58 +0200
parents 1de4a7a49d94
children fb3ce83c1a48
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() {
314
657b465caaa2 Download::downloads property is used as a hash object, not array.
Laurens Holst <laurens.hg@grauw.nl>
parents: 313
diff changeset
2 this.downloads = {};
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() {
313
1de4a7a49d94 Link to download page when javascript disabled or OS not detected. (issue2192)
Laurens Holst <laurens.hg@grauw.nl>
parents: 308
diff changeset
29 var os = this.parse_os();
1de4a7a49d94 Link to download page when javascript disabled or OS not detected. (issue2192)
Laurens Holst <laurens.hg@grauw.nl>
parents: 308
diff changeset
30 if (this.downloads[os]) {
1de4a7a49d94 Link to download page when javascript disabled or OS not detected. (issue2192)
Laurens Holst <laurens.hg@grauw.nl>
parents: 308
diff changeset
31 document.location.href = this.downloads[os];
1de4a7a49d94 Link to download page when javascript disabled or OS not detected. (issue2192)
Laurens Holst <laurens.hg@grauw.nl>
parents: 308
diff changeset
32 return false;
1de4a7a49d94 Link to download page when javascript disabled or OS not detected. (issue2192)
Laurens Holst <laurens.hg@grauw.nl>
parents: 308
diff changeset
33 }
1de4a7a49d94 Link to download page when javascript disabled or OS not detected. (issue2192)
Laurens Holst <laurens.hg@grauw.nl>
parents: 308
diff changeset
34 return true;
260
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
35 },
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
36
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
37 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
38 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
39 }
dd7fababf8b6 Working version of the download button with simple OS detection
David Soria Parra <dsp@php.net>
parents: 255
diff changeset
40 }