[PATCH hg-website-content] downloads: put each available version into a separate table
David Champion
dgc at uchicago.edu
Tue Nov 23 11:18:39 CST 2010
# HG changeset patch
# User David Champion <dgc at uchicago.edu>
# Date 1290526584 21600
# Node ID bdab8d06d6ba39155f35d0ad45b0925e44f0c0e5
# Parent 6e7e8b5aa2c317fb1d185265b87d64f054e6c9fa
downloads: put each available version into a separate table
With this update we generate a separate table on the /downloads page for
each version that is represented in sources.js. Downloader.maxversions
is the number of versions to display by default; 0 means to display all.
If any versions are not displayed by default, a "more versions" label
appears. Clicking it reveals the remaining versions.
diff -r 6e7e8b5aa2c3 -r bdab8d06d6ba downloads/index.html
--- a/downloads/index.html Sat Nov 20 19:53:07 2010 -0600
+++ b/downloads/index.html Tue Nov 23 09:36:24 2010 -0600
@@ -3,23 +3,46 @@
{% block content %}
<h1>Mercurial downloads</h1>
- <table border="0" cellspacing="0" cellpadding="0" class="latest" width="100%">
- <thead>
- <tr>
- <th>Mercurial
- <script language="javascript">
- dl.write('version');
- </script></th>
- <th></th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <script language="javascript">
- Downloader.listall();
- </script>
- </tbody>
- </table>
+ <script language="javascript">
+ var versions = Downloader.versions();
+ var more = Downloader.maxversions &&
+ versions.length > Downloader.maxversions;
+
+ // Show tables for Downloader.maxversions versions
+ for (i in versions) {
+ if (more && i >= Downloader.maxversions)
+ break;
+ // Need to localize this variable to closure it correctly
+ var current = versions[i];
+ document.write(Downloader.table(versions[i], function (o) {
+ return o.version == current;
+ }));
+ }
+
+ function exposeversions (node) {
+ // Emit but do not render tables for remaining versions
+ var html = ''
+ for (i in versions) {
+ if (i < Downloader.maxversions)
+ continue;
+ // Need to localize this variable to closure it correctly
+ var current = versions[i];
+ html += Downloader.table(versions[i], function (o) {
+ return o.version == current;
+ });
+ }
+ node.innerHTML = html;
+ }
+
+ if (more) {
+ document.write('\
+ <div onclick="exposeversions(this);">\
+ <center id="more">[more versions]</center>\
+ </div>\
+ <br/>\
+');
+ }
+ </script>
<h5>Requirements</h5>
<dl>
More information about the Mercurial-devel
mailing list