php avatar php committed a6c7665 Merge

Merge

Comments (0)

Files changed (5)

File contents unchanged.

static/css/styles.css

 
 dt { font-weight: bold; margin-top: 10px; }
 dt em { font-style: normal; display: block; font-weight: normal; }
+dd em { font-style: normal; font-weight: bolder; }
 dd { background: url(../images/bullet.gif) no-repeat 10px .5em; padding-left: 20px; }
 
 /*
 .latest thead td, .latest thead th { background: #00B5F1; color: #fff; font-weight: bold; }
 thead td, thead th { background: #999; color: #fff; font-weight: bold; }
 tbody td { border-bottom: 1px solid #ccc; }
+tbody td em { font-style: normal; font-weight: bolder; }
 
 /*
  * Quotes

static/js/download.js

-function Download() {
-    this.downloads = {};
+function Download (source) {
+    this.version = source[0];
+    this.regex = source[1];
+    this.url = source[2];
+    this.desc = source[3];
 }
 
 Download.prototype = {
+    matches: function (ua) {
+        if (ua.match(this.regex))
+            return true;
+        return false;
+    },
 
-    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";
+    download: function () {
+        document.location.href = this.url;
+        return false;
+    },
+
+    attr: function (key) {
+        return this[key];
+    },
+
+    write: function (key) {
+        document.write(this[key]);
+    }
+}
+
+
+var Downloader = {
+    downloads: [],
+
+    init: function (sources) {
+        for (i in sources) {
+            var source = new Download(sources[i]);
+            this.downloads.push(source);
+        }
+    },
+
+    select: function () {
+        var ua = navigator.userAgent;
+        for (i in this.downloads) {
+            if (this.downloads[i].matches(ua)) {
+                return this.downloads[i];
             }
         }
-        if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
-        if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
-
-        return OSName;
+        return null;
     },
 
-    os_detection: function() {
-        document.write(this.parse_os());
-    },
+    listall: function () {
+        // copy the download list
+        var downloads = this.downloads.slice(0);
+        // alpha-sort it by description (case-folded)
+        downloads.sort(function (a, b) {
+            a = a.desc.toLowerCase();
+            b = b.desc.toLowerCase();
+            return (b < a) - (a < b);
+        });
 
-    os_link: function() {
-        var os = this.parse_os();
-        if (this.downloads[os]) {
-            document.location.href = this.downloads[os];
-            return false;
+        var desc;
+        for (i in downloads) {
+            var dl = downloads[i];
+            var ua = navigator.userAgent;
+            if (dl.matches(ua))
+                desc = '<em>' + dl.desc + '</em>';
+            else
+                desc = dl.desc;
+            document.write('<tr>\n<td>' + desc + '</td>' +
+                           '<td></td>' +
+                           '<td><a href="' + dl.url + '">download</a></td>' +
+                           '</tr>');
         }
-        return true;
-    },
-
-    register_download:function(type, url) {
-        this.downloads[type] = url;
     }
-}
+};

static/manual.dat

+10	1.7.1	.*Macintosh.*10.6.*	http://mercurial.berkwood.com/binaries/Mercurial-1.7.1-py2.6-macosx10.6.zip	Mercurial 1.7.1 for MacOS X 10.6
+10	1.7.1	.*Macintosh.*10.5.*	http://mercurial.berkwood.com/binaries/Mercurial-1.7.1-py2.5-macosx10.5.zip	Mercurial 1.7.1 for MacOS X 10.5

templates/base.html

-{% from 'data' import downloads %}
-
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
 <html>
         <link href="/css/styles.css" type="text/css" rel="stylesheet">
         <script type="text/javascript" src="/js/typeface.js"></script>
         <script type="text/javascript" src="/js/optimer_regular.typeface.js"></script>
+        <script type="text/javascript" src="/js/common.js"></script>
+        <script type="text/javascript" src="/sources.js"></script>
         <script type="text/javascript" src="/js/download.js"></script>
-        <script type="text/javascript" src="/js/common.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 10.6', "{{ download['Mac OS X 10.6']}}");
-         dl.register_download('Mac OS X 10.5', "{{ download['Mac OS X 10.5']}}");
-         dl.register_download('UNIX', "{{ download['Source code']}}");
-         dl.register_download('Linux', "{{ download['Source code']}}");
+        <script language="javascript">
+          Downloader.init(sources);
+          var dl = Downloader.select();
         </script>
         <link rel="shortcut icon" type="image/x-icon" href="/images/favicon.ico">
 
                     </div>
                     <div class="col">
                         {% block sidebar %}
-                        <a class="download typeface-js" href="/downloads" onClick="javascript:return dl.os_link();">
+                        <a class="download typeface-js" href="/downloads" onClick="return dl.download();">
                                     <strong>Download now</strong>
-                                    Mercurial <em>{{ downloads['current'] }}</em>
-                                    <span><script language="javascript">dl.os_detection();</script></span>
+                                    Mercurial <em><script language="Javascript">dl.write('version');</script></em>
+                                    <span><script language="javascript">dl.write('desc');</script></span>
                         </a>
                         <dl>
                             <dt>Another OS?<br><em>Get Mercurial for:</em></dt>
                             <dd><a href="/downloads">Mac OS X</a></dd>
                             <dd><a href="/downloads">Windows</a></dd>
                             <dd><a href="/downloads">other</a></dd>
-
-                            <dt>Requirements</dt>
-                            <dd><a href="http://www.python.org">Python 2.4</a> (already included in binary packages)</dd>
                         </dl>
                         {% endblock %}
                     </div>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.