Mercurial > hg-website
changeset 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 | b18d0f96829d |
children | 675c8d8811bf |
files | .hgsubstate static/javascript/download.js templates/base.html templates/data templates/frontpage.html |
diffstat | 5 files changed, 46 insertions(+), 23 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgsubstate Sun Oct 04 04:21:47 2009 +0200 +++ b/.hgsubstate Sun Oct 04 05:03:28 2009 +0200 @@ -1,1 +1,1 @@ -6293e2d423105e6abe6a21f81d3ab67616ea2096 content +a65bad2173f210d817556679c0dfc8ae93c95f66 content
--- a/static/javascript/download.js Sun Oct 04 04:21:47 2009 +0200 +++ b/static/javascript/download.js Sun Oct 04 05:03:28 2009 +0200 @@ -1,10 +1,28 @@ -function os_detection() { - var OSName="Source"; - if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows"; - if (navigator.appVersion.indexOf("Mac")!=-1) OSName="Mac OS X"; - if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX"; - if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux"; - - document.write(OSName); +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) OSName="Mac OS X"; + 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; + } +}
--- a/templates/base.html Sun Oct 04 04:21:47 2009 +0200 +++ b/templates/base.html Sun Oct 04 05:03:28 2009 +0200 @@ -9,6 +9,14 @@ <script type="text/javascript" src="/javascript/typeface.js"></script> <script type="text/javascript" src="/javascript/optimer_regular.typeface.js"></script> <script type="text/javascript" src="/javascript/download.js"></script> + <script language="javascript" type="text/javascript"> + {% set download = downloads[downloads['current']] %} + var dl = new Download(); + dl.register_download('Windows', "{{ download['Windows']}}"); + dl.register_download('Mac OS X', "{{ download['Mac OS X 10.6']}}"); + dl.register_download('UNIX', "{{ download['Source code']}}"); + dl.register_download('Linux', "{{ download['Source code']}}"); + </script> <link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico"> <title>Mercurial SCM</title> @@ -47,10 +55,10 @@ </div> <div class="col"> {% block sidebar %} - <a class="download typeface-js" href="/downloads"> + <a class="download typeface-js" href="#" onClick="javascript:dl.os_link()"> <strong>Download now</strong> Mercurial <em>1.3.1</em> - <span><script language="javascript">os_detection();</script></span> + <span><script language="javascript">dl.os_detection();</script></span> </a> <dl> <dt class="typeface-js">Requirements</dt>
--- a/templates/data Sun Oct 04 04:21:47 2009 +0200 +++ b/templates/data Sun Oct 04 05:03:28 2009 +0200 @@ -1,1 +1,9 @@ -{% set downloads = {'1.3.1': {'windows': 'linkwin', 'os.x': 'linkosx'}} %} \ No newline at end of file +{% set downloads = { + 'current': '1.3.1', + '1.3.1': { + 'Windows (Tortoise HG)': 'http://bitbucket.org/tortoisehg/stable/downloads/TortoiseHg-0.8.1-hg-1.3.1.exe', + 'Windows': 'http://mercurial.berkwood.com/binaries/Mercurial-1.3.1.exe', + 'Mac OS X 10.6': 'http://mercurial.berkwood.com/binaries/Mercurial-1.3.1-py2.6-macosx10.6.zip', + 'Mac OS X 10.5': 'http://mercurial.berkwood.com/binaries/Mercurial-1.3.1-py2.5-macosx10.5.zip', + 'Source code': 'http://www.selenic.com/mercurial/release/mercurial-1.3.1.tar.gz'}} +%}
--- a/templates/frontpage.html Sun Oct 04 04:21:47 2009 +0200 +++ b/templates/frontpage.html Sun Oct 04 05:03:28 2009 +0200 @@ -36,17 +36,6 @@ </ol> </div> <div class="col"> - <h3>Download</h3> - {% for version in downloads %} - <h4><strong>{{ version }}</strong></h4> - <ul> - {% for os in downloads[version] %} - <li>{{ os }}: {{ downloads[version][os] }}</li> - {% endfor %} - </ul> - - {% endfor %} - <h3>Quick Start</h3> <p><em>Clone a project and create a patch</em>