comparison static/javascript/download.js @ 260:dd7fababf8b6

Working version of the download button with simple OS detection
author David Soria Parra <dsp@php.net>
date Sun, 04 Oct 2009 05:03:28 +0200
parents 4a52186008ee
children
comparison
equal deleted inserted replaced
259:b18d0f96829d 260:dd7fababf8b6
1 function os_detection() { 1 function Download() {
2 var OSName="Source"; 2 this.downloads = new Array();
3 if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
4 if (navigator.appVersion.indexOf("Mac")!=-1) OSName="Mac OS X";
5 if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
6 if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
7
8 document.write(OSName);
9 } 3 }
10 4
5 Download.prototype = {
6
7 parse_os: function() {
8 var OSName="Source code";
9 if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
10 if (navigator.appVersion.indexOf("Mac")!=-1) OSName="Mac OS X";
11 if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
12 if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
13
14 return OSName;
15 },
16
17 os_detection: function() {
18 document.write(this.parse_os());
19 },
20
21 os_link: function() {
22 document.location.href = this.downloads[this.parse_os()];
23 },
24
25 register_download:function(type, url) {
26 this.downloads[type] = url;
27 }
28 }