1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 15:59:59 +00:00
This commit is contained in:
aldacron 2017-05-14 01:40:10 -07:00
commit a7d3c5a4de
3 changed files with 26 additions and 12 deletions

View file

@ -62,7 +62,14 @@ function _format_time_difference(seconds) {
} }
return prefix + parts.join(" ") + suffix; 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) { document.addEventListener("DOMContentLoaded", function(event) {
var now_timestamp = (Date.now() / 1000) | 0; // UTC timestamp in seconds var now_timestamp = (Date.now() / 1000) | 0; // UTC timestamp in seconds
@ -73,8 +80,15 @@ document.addEventListener("DOMContentLoaded", function(event) {
if (torrent_timestamp) { if (torrent_timestamp) {
var timedelta = now_timestamp - torrent_timestamp; var timedelta = now_timestamp - torrent_timestamp;
target.setAttribute('title', _format_time_difference(timedelta)); 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 // Initialise markdown editors on page

View file

@ -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 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"]) %}
<th {% if th_classes %} class="{{ ' '.join(th_classes) }}"{% endif %} {% if header_title %}title="{{ header_title }}"{% endif %} style="{{ header_style }}"> <th {% if th_classes %} class="{{ ' '.join(th_classes) }}"{% endif %} {% if header_title %}title="{{ header_title }}"{% endif %} style="{{ header_style }}">
{% if sort_key %} {% if sort_key %}
<a href="{% if class_suffix == '_desc' %}{{ modify_query(s=sort_key, o="asc") }}{% else %}{{ modify_query(s=sort_key, o="desc") }}{% endif %}"></a> <a href="{% if class_suffix == '_desc' %}{{ modify_query(s=sort_key, o="asc") }}{% else %}{{ modify_query(s=sort_key, o="desc") }}{% endif %}"></a>
@ -13,31 +13,31 @@
<table class="table table-bordered table-hover table-striped torrent-list"> <table class="table table-bordered table-hover table-striped torrent-list">
<thead> <thead>
<tr> <tr>
{% call render_column_header("width:80px;", center_text=True) %} {% call render_column_header("hdr-category", "width:80px;", center_text=True) %}
<div>Category</div> <div>Category</div>
{% endcall %} {% endcall %}
{% call render_column_header("width:auto;", sort_key="name") %} {% call render_column_header("hdr-name", "width:auto;", sort_key="name") %}
<div>Name</div> <div>Name</div>
{% endcall %} {% endcall %}
{% call render_column_header("width:0;", center_text=True) %} {% call render_column_header("hdr-link", "width:0;", center_text=True) %}
<div>Link</div> <div>Link</div>
{% endcall %} {% endcall %}
{% call render_column_header("width:100px;", center_text=True, sort_key="size") %} {% call render_column_header("hdr-size", "width:100px;", center_text=True, sort_key="size") %}
<div>Size</div> <div>Size</div>
{% endcall %} {% endcall %}
{% call render_column_header("width:140px;", center_text=True, sort_key="id", header_title="In UTC") %} {% call render_column_header("hdr-date", "width:140px;", center_text=True, sort_key="id", header_title="In UTC") %}
<div>Date</div> <div>Date</div>
{% endcall %} {% endcall %}
{% if config.ENABLE_SHOW_STATS %} {% if config.ENABLE_SHOW_STATS %}
{% call render_column_header("width:50px;", center_text=True, sort_key="seeders", header_title="Seeds") %} {% call render_column_header("hdr-seeders", "width:50px;", center_text=True, sort_key="seeders", header_title="Seeds") %}
<i class="fa fa-arrow-up" aria-hidden="true"></i> <i class="fa fa-arrow-up" aria-hidden="true"></i>
{% endcall %} {% endcall %}
{% call render_column_header("width:50px;", center_text=True, sort_key="leechers", header_title="Leeches") %} {% call render_column_header("hdr-leechers", "width:50px;", center_text=True, sort_key="leechers", header_title="Leeches") %}
<i class="fa fa-arrow-down" aria-hidden="true"></i> <i class="fa fa-arrow-down" aria-hidden="true"></i>
{% endcall %} {% endcall %}
{% call render_column_header("width:50px;", center_text=True, sort_key="downloads", header_title="Completed downloads") %} {% call render_column_header("hdr-downloads", "width:50px;", center_text=True, sort_key="downloads", header_title="Completed downloads") %}
<i class="fa fa-check" aria-hidden="true"></i> <i class="fa fa-check" aria-hidden="true"></i>
{% endcall %} {% endcall %}

View file

@ -18,7 +18,7 @@
</div> </div>
<div class="col-md-1">Date:</div> <div class="col-md-1">Date:</div>
<div class="col-md-5" data-timestamp="{{ torrent.created_utc_timestamp|int }}">{{ torrent.created_time.strftime('%Y-%m-%d, %H:%M UTC') }}</div> <div class="col-md-5" data-timestamp="{{ torrent.created_utc_timestamp|int }}">{{ torrent.created_time.strftime('%Y-%m-%d %H:%M UTC') }}</div>
</div> </div>
<div class="row"> <div class="row">