view 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
line wrap: on
line source

function Download() {
    this.downloads = new Array();
}

Download.prototype = {

    parse_os: function() {
        var OSName="Source code";
        if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
        if (navigator.appVersion.indexOf("Mac")!=-1) {
            if (navigator.userAgent.indexOf("10.6")!=-1 || /* firefox */
                navigator.userAgent.indexOf("10_6") !=-1) { /* chrome */
                OSName="Mac OS X 10.6";
            } else {
                OSName="Mac OS X 10.5";
            }
        }
        if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
        if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";

        return OSName;
    },

    os_detection: function() {
        document.write(this.parse_os());
    },

    os_link: function() {
        document.location.href = this.downloads[this.parse_os()];
    },

    register_download:function(type, url) {
        this.downloads[type] = url;
    }
}