Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make the current date linkable

  • Loading branch information...
commit b6c819392999bc809e77683b649152c5f6247708 1 parent 2dbfa0f
@miyagawa authored
Showing with 14 additions and 14 deletions.
  1. +14 −14 static/versions/index.html
View
28 static/versions/index.html
@@ -21,29 +21,29 @@
$(function(){
$(".prev-date").click(function(){moveDate(-1)});
$(".next-date").click(function(){moveDate(+1)});
- moveDate(0);
+ var match = location.href.match(/date=(\d{8})/);
+ if (match) {
+ updateChart(match[1])
+ } else {
+ updateChart('current')
+ }
});
function callback(res) {
current_date = moment([res.date[0], res.date[1]-1, res.date[2]]);
if (!newest_date) newest_date = current_date.clone();
- $(".current-date").text(res.date.join('-'));
+ $(".current-date").attr('href', '?date=' + current_date.format('YYYYMMDD')).text(res.date.join('-'));
drawChart(res.data);
}
function moveDate(offset) {
- if (current_date) {
- var new_date = current_date.clone().add('days', offset);
- console.log(new_date, newest_date);
- if (+new_date > +newest_date) {
- alert("Statistics is not yet available for the specified date.");
- } else if (+new_date < +moment([2013, 2, 11])) {
- alert("Statistics is not available for the date older than March 11th, 2013.");
- } else {
- updateChart(new_date.format("YYYYMMDD"));
- }
+ var new_date = current_date.clone().add('days', offset);
+ if (+new_date > +newest_date) {
+ alert("Statistics is not yet available for the specified date.");
+ } else if (+new_date < +moment([2013, 2, 11])) {
+ alert("Statistics is not available for the date older than March 11th, 2013.");
} else {
- updateChart('current')
+ updateChart(new_date.format("YYYYMMDD"));
}
}
@@ -54,7 +54,7 @@
</head>
<body>
<h2>Perl versions with cpanm</h2>
- <div class="date-picker"><a href="#" class="prev-date">&laquo;</a> <span class="current-date"></span> <a href="#" class="next-date">&raquo;</a></div>
+ <div class="date-picker"><a href="#" class="prev-date">&laquo;</a> &nbsp; <a class="current-date"></a> &nbsp; <a href="#" class="next-date">&raquo;</a></div>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
<p class="note">This graph is based on the sample requests sent to the <a href="http://cpanmetadb.plackperl.org/">CPAN Meta DB</a> from cpanm (version 1.6004 or later).</p>
</body>
Please sign in to comment.
Something went wrong with that request. Please try again.