show style version, size, and update age in manager
This commit is contained in:
parent
15eb1b890b
commit
044907fa35
|
@ -260,6 +260,42 @@
|
||||||
"message": "Stop using customized name, switch to the style's own name",
|
"message": "Stop using customized name, switch to the style's own name",
|
||||||
"description": "Tooltip of 'x' button shown in editor when changing the name input of a) styles updated from a URL i.e. not locally created, b) UserCSS styles"
|
"description": "Tooltip of 'x' button shown in editor when changing the name input of a) styles updated from a URL i.e. not locally created, b) UserCSS styles"
|
||||||
},
|
},
|
||||||
|
"dateAbbrDay": {
|
||||||
|
"message": "$value$d",
|
||||||
|
"description": "Day suffix in a short relative date, for example: 8d",
|
||||||
|
"placeholders": {
|
||||||
|
"value": {
|
||||||
|
"content": "$1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dateAbbrHour": {
|
||||||
|
"message": "$value$h",
|
||||||
|
"description": "Hour suffix in a short relative date, for example: 8h",
|
||||||
|
"placeholders": {
|
||||||
|
"value": {
|
||||||
|
"content": "$1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dateAbbrMonth": {
|
||||||
|
"message": "$value$m",
|
||||||
|
"description": "Month suffix in a short relative date, for example: 8m",
|
||||||
|
"placeholders": {
|
||||||
|
"value": {
|
||||||
|
"content": "$1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"dateAbbrYear": {
|
||||||
|
"message": "$value$y",
|
||||||
|
"description": "Year suffix in a short relative date, for example: 8y",
|
||||||
|
"placeholders": {
|
||||||
|
"value": {
|
||||||
|
"content": "$1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"dateInstalled": {
|
"dateInstalled": {
|
||||||
"message": "Date installed",
|
"message": "Date installed",
|
||||||
"description": "Option text for the user to sort the style by install date"
|
"description": "Option text for the user to sort the style by install date"
|
||||||
|
|
14
manage.html
14
manage.html
|
@ -32,7 +32,10 @@
|
||||||
<template data-id="style">
|
<template data-id="style">
|
||||||
<div class="entry">
|
<div class="entry">
|
||||||
<h2 class="style-name">
|
<h2 class="style-name">
|
||||||
<a class="style-name-link"></a>
|
<a class="style-name-link">
|
||||||
|
|
||||||
|
<span class="style-info" data-type="version"></span>
|
||||||
|
</a>
|
||||||
<a target="_blank" class="homepage"></a>
|
<a target="_blank" class="homepage"></a>
|
||||||
</h2>
|
</h2>
|
||||||
<p class="applies-to">
|
<p class="applies-to">
|
||||||
|
@ -54,15 +57,20 @@
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template data-id="styleCompact">
|
<template data-id="styleNewUI">
|
||||||
<div class="entry">
|
<div class="entry">
|
||||||
<h2 class="style-name">
|
<h2 class="style-name">
|
||||||
<div class="checkmate">
|
<div class="checkmate">
|
||||||
<input class="checker" type="checkbox" i18n-title="toggleStyle">
|
<input class="checker" type="checkbox" i18n-title="toggleStyle">
|
||||||
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
<svg class="svg-icon checked"><use xlink:href="#svg-icon-checked"/></svg>
|
||||||
</div>
|
</div>
|
||||||
<a class="style-name-link"></a>
|
<a class="style-name-link">
|
||||||
|
|
||||||
|
<span class="style-info" data-type="version"></span>
|
||||||
|
</a>
|
||||||
</h2>
|
</h2>
|
||||||
|
<p class="style-info" data-type="age"></p>
|
||||||
|
<p class="style-info" data-type="size"></p>
|
||||||
<p class="actions">
|
<p class="actions">
|
||||||
<a target="_blank" class="homepage" tabindex="0"></a>
|
<a target="_blank" class="homepage" tabindex="0"></a>
|
||||||
<a href="#" class="delete" i18n-title="deleteStyleLabel" tabindex="0">
|
<a href="#" class="delete" i18n-title="deleteStyleLabel" tabindex="0">
|
||||||
|
|
|
@ -177,6 +177,25 @@ a:hover {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.style-info {
|
||||||
|
text-align: right;
|
||||||
|
padding: 0 .25em;
|
||||||
|
font-weight: normal;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
|
.style-info[data-type=version] {
|
||||||
|
padding-left: .5em;
|
||||||
|
}
|
||||||
|
.newUI .style-info[data-type=version][data-value="1.0.0"] {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
.newUI .style-info[data-type=size][title^=" "] {
|
||||||
|
opacity: .25;
|
||||||
|
}
|
||||||
|
.newUI .style-info[data-type=size][title^=" "]:hover {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.applies-to {
|
.applies-to {
|
||||||
overflow-wrap: break-word;
|
overflow-wrap: break-word;
|
||||||
}
|
}
|
||||||
|
@ -357,6 +376,10 @@ a:hover {
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.newUI .entry > .style-info {
|
||||||
|
padding-right: .5em;
|
||||||
|
}
|
||||||
|
|
||||||
.newUI .entry .actions {
|
.newUI .entry .actions {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
@ -629,7 +652,7 @@ a:hover {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
max-width: calc(100vw - var(--header-width) - var(--actions-width) - var(--name-padding-left) - 25vw - var(--name-padding-right));
|
max-width: calc(75vw - var(--header-width) - var(--actions-width) - var(--name-padding-left) - var(--name-padding-right) - 6rem);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
padding-right: 1rem;
|
padding-right: 1rem;
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
|
@ -1026,6 +1049,12 @@ a:hover {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1000px) {
|
||||||
|
.newUI .entry > .style-info {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 850px) {
|
@media (max-width: 850px) {
|
||||||
body {
|
body {
|
||||||
display: table;
|
display: table;
|
||||||
|
|
|
@ -32,6 +32,7 @@ let installed;
|
||||||
|
|
||||||
const ENTRY_ID_PREFIX_RAW = 'style-';
|
const ENTRY_ID_PREFIX_RAW = 'style-';
|
||||||
const ENTRY_ID_PREFIX = '#' + ENTRY_ID_PREFIX_RAW;
|
const ENTRY_ID_PREFIX = '#' + ENTRY_ID_PREFIX_RAW;
|
||||||
|
const REVEAL_DATES_FOR = 'h2.style-name, [data-type=age]';
|
||||||
|
|
||||||
const BULK_THROTTLE_MS = 100;
|
const BULK_THROTTLE_MS = 100;
|
||||||
const bulkChangeQueue = [];
|
const bulkChangeQueue = [];
|
||||||
|
@ -60,6 +61,12 @@ newUI.renderClass();
|
||||||
const TARGET_TYPES = ['domains', 'urls', 'urlPrefixes', 'regexps'];
|
const TARGET_TYPES = ['domains', 'urls', 'urlPrefixes', 'regexps'];
|
||||||
const GET_FAVICON_URL = 'https://www.google.com/s2/favicons?domain=';
|
const GET_FAVICON_URL = 'https://www.google.com/s2/favicons?domain=';
|
||||||
const OWN_ICON = chrome.runtime.getManifest().icons['16'];
|
const OWN_ICON = chrome.runtime.getManifest().icons['16'];
|
||||||
|
const AGES = [
|
||||||
|
[24, 'h', t('dateAbbrHour', '\x01')],
|
||||||
|
[30, 'd', t('dateAbbrDay', '\x01')],
|
||||||
|
[12, 'm', t('dateAbbrMonth', '\x01')],
|
||||||
|
[Infinity, 'y', t('dateAbbrYear', '\x01')],
|
||||||
|
];
|
||||||
|
|
||||||
const handleEvent = {};
|
const handleEvent = {};
|
||||||
|
|
||||||
|
@ -184,7 +191,7 @@ function showStyles(styles = [], matchUrlIds) {
|
||||||
function createStyleElement({style, name: nameLC}) {
|
function createStyleElement({style, name: nameLC}) {
|
||||||
// query the sub-elements just once, then reuse the references
|
// query the sub-elements just once, then reuse the references
|
||||||
if ((createStyleElement.parts || {}).newUI !== newUI.enabled) {
|
if ((createStyleElement.parts || {}).newUI !== newUI.enabled) {
|
||||||
const entry = t.template[`style${newUI.enabled ? 'Compact' : ''}`];
|
const entry = t.template[newUI.enabled ? 'styleNewUI' : 'style'];
|
||||||
createStyleElement.parts = {
|
createStyleElement.parts = {
|
||||||
newUI: newUI.enabled,
|
newUI: newUI.enabled,
|
||||||
entry,
|
entry,
|
||||||
|
@ -195,6 +202,9 @@ function createStyleElement({style, name: nameLC}) {
|
||||||
editHrefBase: 'edit.html?id=',
|
editHrefBase: 'edit.html?id=',
|
||||||
homepage: $('.homepage', entry),
|
homepage: $('.homepage', entry),
|
||||||
homepageIcon: t.template[`homepageIcon${newUI.enabled ? 'Small' : 'Big'}`],
|
homepageIcon: t.template[`homepageIcon${newUI.enabled ? 'Small' : 'Big'}`],
|
||||||
|
infoAge: $('[data-type=age]', entry),
|
||||||
|
infoVer: $('[data-type=version]', entry),
|
||||||
|
infoSize: $('[data-type=size]', entry),
|
||||||
appliesTo: $('.applies-to', entry),
|
appliesTo: $('.applies-to', entry),
|
||||||
targets: $('.targets', entry),
|
targets: $('.targets', entry),
|
||||||
expander: $('.expander', entry),
|
expander: $('.expander', entry),
|
||||||
|
@ -209,13 +219,19 @@ function createStyleElement({style, name: nameLC}) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const parts = createStyleElement.parts;
|
const parts = createStyleElement.parts;
|
||||||
const configurable = style.usercssData && style.usercssData.vars && Object.keys(style.usercssData.vars).length > 0;
|
const ud = style.usercssData;
|
||||||
|
const configurable = ud && ud.vars && Object.keys(ud.vars).length > 0;
|
||||||
const name = style.customName || style.name;
|
const name = style.customName || style.name;
|
||||||
parts.checker.checked = style.enabled;
|
parts.checker.checked = style.enabled;
|
||||||
parts.nameLink.textContent = t.breakWord(name);
|
parts.nameLink.firstChild.textContent = t.breakWord(name);
|
||||||
parts.nameLink.href = parts.editLink.href = parts.editHrefBase + style.id;
|
parts.nameLink.href = parts.editLink.href = parts.editHrefBase + style.id;
|
||||||
parts.homepage.href = parts.homepage.title = style.url || '';
|
parts.homepage.href = parts.homepage.title = style.url || '';
|
||||||
if (!newUI.enabled) {
|
parts.infoVer.textContent = ud ? ud.version : '';
|
||||||
|
parts.infoVer.dataset.value = ud ? ud.version : '';
|
||||||
|
if (newUI.enabled) {
|
||||||
|
createSizeText(parts.infoSize, style);
|
||||||
|
createAgeText(parts.infoAge, style);
|
||||||
|
} else {
|
||||||
parts.oldConfigure.classList.toggle('hidden', !configurable);
|
parts.oldConfigure.classList.toggle('hidden', !configurable);
|
||||||
parts.oldCheckUpdate.classList.toggle('hidden', !style.updateUrl);
|
parts.oldCheckUpdate.classList.toggle('hidden', !style.updateUrl);
|
||||||
parts.oldUpdate.classList.toggle('hidden', !style.updateUrl);
|
parts.oldUpdate.classList.toggle('hidden', !style.updateUrl);
|
||||||
|
@ -234,7 +250,7 @@ function createStyleElement({style, name: nameLC}) {
|
||||||
entry.className = parts.entryClassBase + ' ' +
|
entry.className = parts.entryClassBase + ' ' +
|
||||||
(style.enabled ? 'enabled' : 'disabled') +
|
(style.enabled ? 'enabled' : 'disabled') +
|
||||||
(style.updateUrl ? ' updatable' : '') +
|
(style.updateUrl ? ' updatable' : '') +
|
||||||
(style.usercssData ? ' usercss' : '');
|
(ud ? ' usercss' : '');
|
||||||
|
|
||||||
if (style.url) {
|
if (style.url) {
|
||||||
$('.homepage', entry).appendChild(parts.homepageIcon.cloneNode(true));
|
$('.homepage', entry).appendChild(parts.homepageIcon.cloneNode(true));
|
||||||
|
@ -315,6 +331,37 @@ function createStyleTargetsElement({entry, expanded, style = entry.styleMeta}) {
|
||||||
entry._numTargets = numTargets;
|
entry._numTargets = numTargets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createSizeText(el, style) {
|
||||||
|
const size = (style.sourceCode || '').length ||
|
||||||
|
style.sections.reduce((sum, sec) => sum + (sec.code || '').length, 0);
|
||||||
|
if (size) {
|
||||||
|
el.textContent = size < 1000 ? '<1k' : `${size / 1000 | 0}k`;
|
||||||
|
el.title = addBigness(size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createAgeText(el, style) {
|
||||||
|
let val = style.updateDate;
|
||||||
|
if (val) {
|
||||||
|
val = (Date.now() - val) / 3600e3; // age in hours
|
||||||
|
for (const [max, unit, text] of AGES) {
|
||||||
|
const rounded = Math.round(val);
|
||||||
|
if (rounded < max) {
|
||||||
|
el.textContent = text.replace('\x01', rounded);
|
||||||
|
el.dataset.value = addBigness(Math.round(rounded), 2) + unit;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
val /= max;
|
||||||
|
}
|
||||||
|
} else if (el.firstChild) {
|
||||||
|
el.textContent = '';
|
||||||
|
delete el.dataset.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addBigness(val, max = 8) {
|
||||||
|
return ' '.repeat(max - Math.ceil(Math.log10(val))) + val;
|
||||||
|
}
|
||||||
|
|
||||||
function getFaviconImgSrc(container = installed) {
|
function getFaviconImgSrc(container = installed) {
|
||||||
if (!newUI.enabled || !newUI.favicons) return;
|
if (!newUI.enabled || !newUI.favicons) return;
|
||||||
|
@ -505,9 +552,9 @@ Object.assign(handleEvent, {
|
||||||
},
|
},
|
||||||
|
|
||||||
lazyAddEntryTitle({type, target}) {
|
lazyAddEntryTitle({type, target}) {
|
||||||
const cell = target.closest('h2.style-name');
|
const cell = target.closest(REVEAL_DATES_FOR);
|
||||||
if (cell) {
|
if (cell) {
|
||||||
const link = $('.style-name-link', cell);
|
const link = $('.style-name-link', cell) || cell;
|
||||||
if (type === 'mouseover' && !link.title) {
|
if (type === 'mouseover' && !link.title) {
|
||||||
debounce(handleEvent.addEntryTitle, 50, link);
|
debounce(handleEvent.addEntryTitle, 50, link);
|
||||||
} else {
|
} else {
|
||||||
|
@ -541,7 +588,7 @@ function handleBulkChange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleUpdateForId(id, opts) {
|
function handleUpdateForId(id, opts) {
|
||||||
return API.getStyle(id, true).then(style => {
|
return API.getStyle(id).then(style => {
|
||||||
handleUpdate(style, opts);
|
handleUpdate(style, opts);
|
||||||
bulkChangeQueue.time = performance.now();
|
bulkChangeQueue.time = performance.now();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user