diff --git a/autoindex.css b/autoindex.css index 6075c5a..a761c89 100644 --- a/autoindex.css +++ b/autoindex.css @@ -129,6 +129,9 @@ button .tooltip { .movie-buttons a { margin-right: 0.5rem; } +.timestamp .original { + color: gray; +} @media screen and (max-width: 1200px) { .inner { width: 100%; diff --git a/autoindex.js b/autoindex.js index 4ffc7c7..563898c 100644 --- a/autoindex.js +++ b/autoindex.js @@ -50,6 +50,14 @@ function findByInfoFile(infoFile) { return found; } +const pZ = (n) => n.toString().padStart(2, '0'); +function restampDateTime(datetime, includeTime = true) { + const date = new Date(datetime); + const [month, day, year] = [date.getMonth() + 1, date.getDate(), date.getFullYear()]; + const [hour, minutes, seconds] = [date.getHours(), date.getMinutes(), date.getSeconds()]; + return `${pZ(day)}/${pZ(month)}/${year}${includeTime ? ` ${pZ(hour)}:${pZ(minutes)}:${pZ(seconds)}` : ''}`; +} + function deduplicateJointEpisode(textContent) { return new Promise((resolve, reject) => { const lns = textContent.split('\n'); @@ -99,7 +107,11 @@ function fillMeta( if (airedEl || premieredEl) { const timestamp = original.parentElement.parentElement.querySelector('.timestamp'); if (timestamp) { - timestamp.innerText = (airedEl || premieredEl).textContent; + const original = timestamp.innerText; + const airdate = restampDateTime((airedEl || premieredEl).textContent, false); + const wrapper = `${airdate}`; + const originalWrapper = ` (${original})`; + timestamp.innerHTML = wrapper + originalWrapper; } } @@ -196,6 +208,12 @@ function createOrImproveMovieMeta(original, thumbnail, nfo) { } } +function timestampify() { + Array.from(document.body.querySelectorAll('.timestamp')).forEach((stamp) => { + stamp.innerText = restampDateTime(stamp.innerText); + }); +} + // Promise that resolves when all info files that were found have been parsed function waitUntilInfoComplete() { return new Promise((resolve, reject) => { @@ -331,10 +349,12 @@ function createToggleCheckbox(field, value, description) { if ('localStorage' in window) { const plainMode = window.localStorage.getItem('plainMode'); if (plainMode !== 'true') { + timestampify(); accountForMetadata(); } createToggleCheckbox('plainMode', plainMode, 'Disable metadata / display plain index listing (less bandwidth required)'); } else { + timestampify(); accountForMetadata(); }