forked from rDrama/rDrama
do this https://watchpeopledie.tv/h/meta/post/61549/megathread-for-bugs-and-suggestions/1685005#context
parent
7a57781013
commit
0c9a7e76bc
|
@ -1,23 +1,14 @@
|
||||||
function timeSince(timeStamp) {
|
function formatDate(d) {
|
||||||
const now = new Date(),
|
const hour = ("0" + d.getHours()).slice(-2);
|
||||||
secondsPast = (now.getTime() - timeStamp) / 1000;
|
const minute = ("0" + d.getMinutes()).slice(-2);
|
||||||
if (secondsPast < 60) {
|
const second = ("0" + d.getSeconds()).slice(-2);
|
||||||
return parseInt(secondsPast) + 's';
|
return hour + ":" + minute + ":" + second;
|
||||||
}
|
|
||||||
if (secondsPast < 3600) {
|
|
||||||
return parseInt(secondsPast / 60) + 'm';
|
|
||||||
}
|
|
||||||
if (secondsPast <= 86400) {
|
|
||||||
return parseInt(secondsPast / 3600) + 'h';
|
|
||||||
}
|
|
||||||
if (secondsPast > 86400) {
|
|
||||||
day = timeStamp.getDate();
|
|
||||||
month = timeStamp.toDateString().match(/ [a-zA-Z]*/)[0].replace(" ", "");
|
|
||||||
year = timeStamp.getFullYear() == now.getFullYear() ? "" : " " + timeStamp.getFullYear();
|
|
||||||
return day + " " + month + year;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const e of timestamps) {
|
||||||
|
e.innerHTML = formatDate(new Date(e.dataset.time*1000));
|
||||||
|
};
|
||||||
|
|
||||||
const ua=window.navigator.userAgent
|
const ua=window.navigator.userAgent
|
||||||
let socket
|
let socket
|
||||||
|
|
||||||
|
@ -125,10 +116,7 @@ socket.on('speak', function(json) {
|
||||||
|
|
||||||
document.getElementsByClassName('user_id')[0].value = json.user_id
|
document.getElementsByClassName('user_id')[0].value = json.user_id
|
||||||
|
|
||||||
if (Date.now() - json.time*1000 > 5000)
|
document.getElementsByClassName('time')[0].innerHTML = formatDate(new Date(json.time*1000))
|
||||||
document.getElementsByClassName('time')[0].innerHTML = timeSince(json.time*1000) + ' ago'
|
|
||||||
else
|
|
||||||
document.getElementsByClassName('time')[0].innerHTML = "just now"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementsByClassName('chat-line')[0].id = json.id
|
document.getElementsByClassName('chat-line')[0].id = json.id
|
||||||
|
|
|
@ -235,7 +235,7 @@
|
||||||
</div>
|
</div>
|
||||||
<span {% if m and m.patron %}class="username patron" style="background-color:#{{m.namecolor}}"{% else %}class="username"{% endif %}>{% if m %}{{m.username}}{% endif %}</span>
|
<span {% if m and m.patron %}class="username patron" style="background-color:#{{m.namecolor}}"{% else %}class="username"{% endif %}>{% if m %}{{m.username}}{% endif %}</span>
|
||||||
</a>
|
</a>
|
||||||
<span class="text-black time ml-1 mb-3 text-center">{% if m %}{{m.time | timestamp}}{% else %}just now{% endif %}</span>
|
<span class="text-black time ml-1 mb-3 text-center" {% if m %}data-time="{{m.time}}"{% endif %}></span>
|
||||||
<input hidden class="user_id" {% if m %}value="{{m.user_id}}"{% endif %}>
|
<input hidden class="user_id" {% if m %}value="{{m.user_id}}"{% endif %}>
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue