Mercurial > hg-website
view 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 |
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; } }