Mercurial > hg-website
annotate static/js/download.js @ 313:1de4a7a49d94
Link to download page when javascript disabled or OS not detected. (issue2192)
author | Laurens Holst <laurens.hg@grauw.nl> |
---|---|
date | Sun, 16 May 2010 14:47:03 +0200 |
parents | b7d326bc57f9 |
children | 657b465caaa2 |
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 | 10 if (navigator.appVersion.indexOf("Mac")!=-1) { |
11 if (navigator.userAgent.indexOf("10.6")!=-1 || /* firefox */ | |
12 navigator.userAgent.indexOf("10_6") !=-1) { /* chrome */ | |
13 OSName="Mac OS X 10.6"; | |
14 } else { | |
15 OSName="Mac OS X 10.5"; | |
16 } | |
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 } |