view static/js/download.js @ 316:f510cd3f37fc

downloads: Mercurial 1.5.4
author David Soria Parra <dsp@php.net>
date Wed, 02 Jun 2010 09:17:53 +0200
parents 657b465caaa2
children fb3ce83c1a48
line wrap: on
line source

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

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() {
        var os = this.parse_os();
        if (this.downloads[os]) {
            document.location.href = this.downloads[os];
            return false;
        }
        return true;
    },

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