Download:
child 18:95430744fb8d
parent 16:784e5bd0fcba
17:ba794747cbdc
Anton Shestakov <av6@dwimlabs.net>, Wed, 15 Jun 2016 15:55:13 +0800
viewer: use moment.js for relative time

1 файлов изменено, 13 вставок(+), 0 удалений(-) [+]
templates/base.html file | annotate | diff | comparison | revisions
--- a/templates/base.html Wed Jun 15 15:48:54 2016 +0800
+++ b/templates/base.html Wed Jun 15 15:55:13 2016 +0800
@@ -9,6 +9,7 @@
<link rel="stylesheet" href="/static/main.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js" integrity="sha384-rY/jv8mMhqDabXSo+UCggqKtdmBfd3qC2/KvyTDNQ6PcUJXaxK1tMepoQda4g5vB" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/uikit/2.26.3/js/uikit.min.js" integrity="sha384-6OYggLGXv4OPaVsh9O/0baGeEYFu1r1FE3+sNtPeDk6JofnNNZb2sHKzUa7wum04" crossorigin="anonymous"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.13.0/moment.min.js" integrity="sha384-MV8AwEgYXLMw5ZPj4763CSPk+tYGoUZGdwr/+EfkAZ1Dl2rGHxOMpQ1IW7VtyUPn" crossorigin="anonymous"></script>
</head>
<body>
<nav class="uk-navbar uk-navbar-attached">
@@ -19,5 +20,17 @@
{% block content %}{% end %}
+ <script>
+ (function($) {
+ var humanizeTimestamps = function() {
+ $('time[datetime]').each(function() {
+ var $this = $(this);
+ $this.text(moment($this.attr('datetime')).fromNow());
+ });
+ };
+ humanizeTimestamps();
+ window.setInterval(humanizeTimestamps, 15 * 1000);
+ })(jQuery);
+ </script>
</body>
</html>