diff --git a/nyaa/static/js/main.js b/nyaa/static/js/main.js index 9cc120a..b9c140b 100644 --- a/nyaa/static/js/main.js +++ b/nyaa/static/js/main.js @@ -62,7 +62,14 @@ function _format_time_difference(seconds) { } return prefix + parts.join(" ") + suffix; } +function _format_date(date) { + var pad = function (n) { return ("00" + n).slice(-2); } + var ymd = date.getFullYear() + "-" + pad(date.getMonth()+1) + "-" + pad(date.getDate()); + var hm = pad(date.getHours()) + ":" + pad(date.getMinutes()); + return ymd + " " + hm; +} +// Add title text to elements with data-timestamp attribute document.addEventListener("DOMContentLoaded", function(event) { var now_timestamp = (Date.now() / 1000) | 0; // UTC timestamp in seconds @@ -73,8 +80,15 @@ document.addEventListener("DOMContentLoaded", function(event) { if (torrent_timestamp) { var timedelta = now_timestamp - torrent_timestamp; target.setAttribute('title', _format_time_difference(timedelta)); + + target.innerText = _format_date(new Date(torrent_timestamp*1000)); } }; + + var header_date = document.querySelector('.hdr-date'); + if (header_date) { + header_date.setAttribute('title', 'In local time'); + } }); // Initialise markdown editors on page @@ -124,4 +138,4 @@ document.addEventListener("DOMContentLoaded", function() { // bsThemeLink.href = '/static/css/bootstrap.min.css'; // localStorage.setItem('theme', 'light'); // } -// } \ No newline at end of file +// } diff --git a/nyaa/templates/search_results.html b/nyaa/templates/search_results.html index 95d18d5..52c27f0 100644 --- a/nyaa/templates/search_results.html +++ b/nyaa/templates/search_results.html @@ -1,6 +1,6 @@ -{% macro render_column_header(header_style, center_text=False, sort_key=None, header_title=None) %} +{% macro render_column_header(header_class, header_style, center_text=False, sort_key=None, header_title=None) %} {% set class_suffix = (search.sort == sort_key) and ("_" + search.order) or "" %} -{% set th_classes = filter_truthy([sort_key and "sorting" + class_suffix, center_text and "text-center"]) %} +{% set th_classes = filter_truthy([header_class, sort_key and "sorting" + class_suffix, center_text and "text-center"]) %}