summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--public/js/moment-countdown.js11
-rw-r--r--templates/layout.html12
2 files changed, 17 insertions, 6 deletions
diff --git a/public/js/moment-countdown.js b/public/js/moment-countdown.js
index e69de29b..999cfcf5 100644
--- a/public/js/moment-countdown.js
+++ b/public/js/moment-countdown.js
@@ -0,0 +1,11 @@
+$(document).ready(function() {
+ $.each($('.moment-countdown'), function(i, e) {
+ var span = $(e);
+ var text = span.html();
+ var timestamp = moment(parseInt(span.attr("data-timestamp") * 1000));
+ span.html(text.replace("%c", timestamp.fromNow()));
+ setInterval(function() {
+ span.html(text.replace("%c", timestamp.fromNow()));
+ }, 1000);
+ });
+}); \ No newline at end of file
diff --git a/templates/layout.html b/templates/layout.html
index eaef0925..8697f69d 100644
--- a/templates/layout.html
+++ b/templates/layout.html
@@ -12,6 +12,7 @@
<meta name="revisit-after" content="1 days" />
<link rel="stylesheet" type="text/css" href="vendor/bootstrap-3.2.0/css/theme%theme%.css" />
<link rel="stylesheet" type="text/css" href="vendor/icomoon/style.css" />
+<script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
%atom_link%
</head>
<body>
@@ -35,15 +36,14 @@
</div>
</div>
</div>
- <script type="text/javascript" src="vendor/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="vendor/bootstrap-3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/forms.js"></script>
<script type="text/javascript" src="vendor/moment-with-locales.min.js"></script>
- <script type="text/javascript" src="js/moment-countdown.js"></script>
<script type="text/javascript">
- $(function() {
- moment.locale("%locale%");
- });
- </script>
+ $(function() {
+ moment.locale("%locale%");
+ });
+ </script>
+ <script type="text/javascript" src="js/moment-countdown.js"></script>
</body>
</html>