timestamps as title and not replacing text

This commit is contained in:
Pau Capó 2019-06-14 10:08:36 +02:00
parent cacd9d9bcc
commit 8ea3d74c8c

View file

@ -16,7 +16,6 @@ class AdminerReadableDates
function __construct()
{
$this->prepend = <<<EOT
document.addEventListener('DOMContentLoaded', function(event) {
var date = new Date();
var tds = document.querySelectorAll('td[id^="val"]');
@ -24,24 +23,10 @@ document.addEventListener('DOMContentLoaded', function(event) {
var text = tds[i].innerHTML.trim();
if (text.match(/^\d{10}$/)) {
date.setTime(parseInt(text) * 1000);
tds[i].oldDate = text;
// tds[i].newDate = date.toUTCString().substr(5); // UTC format
tds[i].newDate = date.toLocaleString(); // Local format
// tds[i].newDate = date.toLocaleFormat('%e %b %Y %H:%M:%S'); // Custom format - works in Firefox only
tds[i].newDate = '<span style="color: #009900">' + tds[i].newDate + '</span>';
tds[i].innerHTML = tds[i].newDate;
tds[i].dateIsNew = true;
tds[i].addEventListener('click', function(event) {
this.innerHTML = (this.dateIsNew ? this.oldDate : this.newDate);
this.dateIsNew = !this.dateIsNew;
});
tds[i].title = date.toLocaleString();
}
}
});
EOT;
}