##// END OF EJS Templates
Set timestamps to local ones by JS
neko259 -
r1017:67ce9645 default
parent child Browse files
Show More
@@ -40,6 +40,34 b' function highlightCode(node) {'
40 });
40 });
41 }
41 }
42
42
43 /**
44 * Translate timestamps to local ones
45 */
46 function translate_time() {
47 var els = $('time');
48 if (!els.length) {
49 return;
50 }
51
52 var locale = window.navigator.language;
53 var formatter = new Intl.DateTimeFormat(
54 locale,
55 {
56 weekday: 'short', year: 'numeric', month: 'short', day: 'numeric',
57 hour: 'numeric', minute: '2-digit', second: '2-digit'
58 }
59 );
60
61 els.each(function() {
62 var el = $(this);
63 var dateAttr = el.attr('datetime');
64 if (dateAttr) {
65 var date = new Date(dateAttr);
66 el.text(formatter.format(date));
67 }
68 });
69 }
70
43 $( document ).ready(function() {
71 $( document ).ready(function() {
44 hideEmailFromForm();
72 hideEmailFromForm();
45
73
@@ -53,4 +81,6 b' function highlightCode(node) {'
53 addRefLinkPreview();
81 addRefLinkPreview();
54
82
55 highlightCode($(document));
83 highlightCode($(document));
84
85 translate_time();
56 });
86 });
@@ -106,6 +106,8 b' function getThreadDiff() {'
106
106
107 // TODO Process removed posts if any
107 // TODO Process removed posts if any
108 $('.metapanel').attr('data-last-update', data.last_update);
108 $('.metapanel').attr('data-last-update', data.last_update);
109
110 translate_time();
109 })
111 })
110 }
112 }
111
113
@@ -140,7 +142,7 b' function updatePost(postHtml) {'
140 showNewPostsTitle(1);
142 showNewPostsTitle(1);
141
143
142 lastUpdate = post.children('.post-info').first()
144 lastUpdate = post.children('.post-info').first()
143 .children('.pub_time').first().text();
145 .children('.pub_time').first().html();
144
146
145 if (bottom) {
147 if (bottom) {
146 scrollToBottom();
148 scrollToBottom();
@@ -195,7 +197,7 b' function updateMetadataPanel(lastUpdate)'
195
197
196 if (lastUpdate !== '') {
198 if (lastUpdate !== '') {
197 var lastUpdateField = $('#last-update');
199 var lastUpdateField = $('#last-update');
198 lastUpdateField.text(lastUpdate);
200 lastUpdateField.html(lastUpdate);
199 blink(lastUpdateField);
201 blink(lastUpdateField);
200 }
202 }
201
203
@@ -18,7 +18,7 b''
18 onclick="javascript:addQuickReply('{{ post.id }}'); return false;"
18 onclick="javascript:addQuickReply('{{ post.id }}'); return false;"
19 title="{% trans 'Quote' %}" {% endif %}>({{ post.get_absolute_id }})</a>
19 title="{% trans 'Quote' %}" {% endif %}>({{ post.get_absolute_id }})</a>
20 <span class="title">{{ post.title }}</span>
20 <span class="title">{{ post.title }}</span>
21 <span class="pub_time">{{ post.pub_time|date:'r' }}</span>
21 <span class="pub_time"><time datetime="{{ post.pub_time|date:'c' }}">{{ post.pub_time|date:'r' }}</time></span>
22 {% comment %}
22 {% comment %}
23 Thread death time needs to be shown only if the thread is alredy archived
23 Thread death time needs to be shown only if the thread is alredy archived
24 and this is an opening post (thread death time) or a post for popup
24 and this is an opening post (thread death time) or a post for popup
@@ -85,7 +85,7 b''
85 <button id="autoupdate">{% trans 'Update' %}</button>
85 <button id="autoupdate">{% trans 'Update' %}</button>
86 <span id="reply-count">{{ thread.get_reply_count }}</span>/{{ max_replies }} {% trans 'messages' %},
86 <span id="reply-count">{{ thread.get_reply_count }}</span>/{{ max_replies }} {% trans 'messages' %},
87 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
87 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
88 {% trans 'Last update: ' %}<span id="last-update">{{ thread.last_edit_time|date:'r' }}</span>
88 {% trans 'Last update: ' %}<span id="last-update"><time datetime="{{ thread.last_edit_time|date:'c' }}">{{ thread.last_edit_time|date:'r' }}</time></span>
89 [<a href="rss/">RSS</a>]
89 [<a href="rss/">RSS</a>]
90 {% endcache %}
90 {% endcache %}
91 </span>
91 </span>
@@ -58,7 +58,7 b''
58 <span id="reply-count">{{ thread.get_reply_count }}</span>/{{ max_replies }}
58 <span id="reply-count">{{ thread.get_reply_count }}</span>/{{ max_replies }}
59 {% trans 'messages' %},
59 {% trans 'messages' %},
60 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
60 <span id="image-count">{{ thread.get_images_count }}</span> {% trans 'images' %}.
61 {% trans 'Last update: ' %}{{ thread.last_edit_time|date:'r' }}
61 {% trans 'Last update: ' %}<time datetime="{{ thread.last_edit_time|date:'c' }}">{{ thread.last_edit_time|date:'r' }}</time>
62 [<a href="rss/">RSS</a>]
62 [<a href="rss/">RSS</a>]
63 {% endcache %}
63 {% endcache %}
64 </span>
64 </span>
General Comments 0
You need to be logged in to leave comments. Login now