Cleanup updateDate code
This commit is contained in:
parent
52f012daf5
commit
9368c27990
|
@ -66,9 +66,6 @@ function initGlobalEvents() {
|
|||
btn.onclick = btn.onclick || (() => openURL({url: URLS.configureCommands}));
|
||||
|
||||
$$('#header a[href^="http"]').forEach(a => (a.onclick = handleEvent.external));
|
||||
// show date installed & last update on hover
|
||||
installed.addEventListener('mouseover', handleEvent.lazyAddEntryTitle);
|
||||
installed.addEventListener('mouseout', handleEvent.lazyAddEntryTitle);
|
||||
|
||||
document.addEventListener('visibilitychange', onVisibilityChange);
|
||||
|
||||
|
@ -272,28 +269,8 @@ Object.assign(handleEvent, {
|
|||
config(event, {styleMeta}) {
|
||||
event.preventDefault();
|
||||
configDialog(styleMeta);
|
||||
},
|
||||
|
||||
lazyAddEntryTitle({type, target}) {
|
||||
const cell = target.closest('h2.style-name');
|
||||
if (cell) {
|
||||
const link = $('.style-name-link', cell);
|
||||
if (type === 'mouseover' && !link.title) {
|
||||
debounce(handleEvent.addEntryTitle, 50, link);
|
||||
} else {
|
||||
debounce.unregister(handleEvent.addEntryTitle);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
addEntryTitle(link) {
|
||||
const entry = link.closest('.entry');
|
||||
link.title = [
|
||||
{prop: 'installDate', name: 'dateInstalled'},
|
||||
{prop: 'updateDate', name: 'dateUpdated'},
|
||||
].map(({prop, name}) =>
|
||||
t(name) + ': ' + (formatDate(entry.styleMeta[prop]) || '—')).join('\n');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function handleUpdate(style, {reason, method} = {}) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
global prefs $ $$ $create template tWordBreak
|
||||
installed sorter filterAndAppend
|
||||
global prefs t $ $$ $create template tWordBreak
|
||||
installed sorter filterAndAppend handleEvent
|
||||
animateElement scrollElementIntoView formatDate
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
|
@ -158,10 +159,13 @@ const UI = {
|
|||
|
||||
$('.entry-version', entry).textContent = style.usercssData && style.usercssData.version || '';
|
||||
|
||||
let lastUpdate = style.updateDate ? new Date(style.updateDate) : '';
|
||||
lastUpdate = lastUpdate instanceof Date && isFinite(lastUpdate) ? lastUpdate.toISOString() : '';
|
||||
$('.entry-last-update', entry).textContent = lastUpdate.split('T')[0].replace(/-/g, '.');
|
||||
$('.entry-last-update', entry).title = lastUpdate;
|
||||
const lastUpdate = $('.entry-last-update', entry);
|
||||
lastUpdate.textContent = UI.getDateString(style.updateDate);
|
||||
// Show install & last update in title
|
||||
lastUpdate.title = [
|
||||
{prop: 'installDate', name: 'dateInstalled'},
|
||||
{prop: 'updateDate', name: 'dateUpdated'},
|
||||
].map(({prop, name}) => t(name) + ': ' + (formatDate(entry.styleMeta[prop]) || '—')).join('\n');
|
||||
|
||||
UI.createStyleTargetsElement({entry, style});
|
||||
UI.addLabels(entry);
|
||||
|
@ -169,6 +173,13 @@ const UI = {
|
|||
return entry;
|
||||
},
|
||||
|
||||
getDateString: date => {
|
||||
const newDate = new Date(date);
|
||||
return newDate instanceof Date && isFinite(newDate)
|
||||
? newDate.toISOString().split('T')[0].replace(/-/g, '.')
|
||||
: '';
|
||||
},
|
||||
|
||||
|
||||
createStyleTargetsElement: ({entry, style}) => {
|
||||
const parts = UI._parts;
|
||||
|
|
Loading…
Reference in New Issue
Block a user