Add: Add 'applies to' to install page
This commit is contained in:
parent
f74641e20d
commit
6e52d48c6c
|
@ -24,8 +24,8 @@ body {
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.meta {
|
h1 small {
|
||||||
font-size: 1.4em;
|
font-size: 0.6em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.warning {
|
.warning {
|
||||||
|
@ -48,6 +48,21 @@ body {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.external {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.external > * {
|
||||||
|
margin: 0 7.5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.install {
|
||||||
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
|
font-size: 2em;
|
||||||
|
padding: 0.4em 0.8em;
|
||||||
|
}
|
||||||
|
|
||||||
.code {
|
.code {
|
||||||
padding: 2em;
|
padding: 2em;
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
|
|
|
@ -24,7 +24,7 @@ function install(style) {
|
||||||
});
|
});
|
||||||
return communicate(request)
|
return communicate(request)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
$$('.meta-version + .warning')
|
$$('.warning')
|
||||||
.forEach(el => el.remove());
|
.forEach(el => el.remove());
|
||||||
$('button.install').textContent = 'Installed';
|
$('button.install').textContent = 'Installed';
|
||||||
$('button.install').disabled = true;
|
$('button.install').disabled = true;
|
||||||
|
@ -46,6 +46,23 @@ function communicate(request) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAppliesTo(style) {
|
||||||
|
function *_gen() {
|
||||||
|
for (const section of style.sections) {
|
||||||
|
for (const type of ['urls', 'urlPrefixes', 'domains', 'regexps']) {
|
||||||
|
if (section[type]) {
|
||||||
|
yield *section[type];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const result = [..._gen()];
|
||||||
|
if (!result.length) {
|
||||||
|
result.push('All URLs');
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function initInstallPage({style, dup}) {
|
function initInstallPage({style, dup}) {
|
||||||
pendingResource.then(() => {
|
pendingResource.then(() => {
|
||||||
const versionTest = dup && usercss.semverTest(style.version, dup.version);
|
const versionTest = dup && usercss.semverTest(style.version, dup.version);
|
||||||
|
@ -54,21 +71,30 @@ function initInstallPage({style, dup}) {
|
||||||
document.body.appendChild(tHTML(`
|
document.body.appendChild(tHTML(`
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<h1>Install Usercss</h1>
|
<h1>${style.name} <small class="meta-version">v${style.version}</small></h1>
|
||||||
<h2>Name</h2>
|
<p>${style.description}</p>
|
||||||
<span class="meta meta-name">${style.name}</span>
|
<h3>Author</h3>
|
||||||
<h2>Version</h2>
|
${style.author}
|
||||||
<span class="meta meta-version">${style.version}</span>
|
<h3>License</h3>
|
||||||
|
${style.license}
|
||||||
|
<h3>Applies to</h3>
|
||||||
|
<ul>
|
||||||
|
${getAppliesTo(style).map(s => `<li>${s}</li>`)}
|
||||||
|
</ul>
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<button class="install">${!dup ? 'Install' : versionTest > 0 ? 'Update' : 'Reinstall'}</button>
|
<button class="install">${!dup ? 'Install' : versionTest > 0 ? 'Update' : 'Reinstall'}</button>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="external">
|
||||||
|
<a href="${style.url}" target="_blank">Homepage</a>
|
||||||
|
<a href="${style.supportURL}" target="_blank">Support</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="code"></div>
|
<div class="code"></div>
|
||||||
</div>
|
</div>
|
||||||
`));
|
`));
|
||||||
if (versionTest < 0) {
|
if (versionTest < 0) {
|
||||||
// FIXME: i18n
|
// FIXME: i18n
|
||||||
$('.meta-version').after(tHTML(`
|
$('.actions').before(tHTML(`
|
||||||
<div class="warning">
|
<div class="warning">
|
||||||
The version is older then installed style.
|
The version is older then installed style.
|
||||||
</div>
|
</div>
|
||||||
|
@ -93,7 +119,8 @@ function initErrorPage(err, source) {
|
||||||
// FIXME: i18n
|
// FIXME: i18n
|
||||||
document.body.appendChild(tHTML(`
|
document.body.appendChild(tHTML(`
|
||||||
<div class="warning">
|
<div class="warning">
|
||||||
Stylus failed to parse usercss: ${err}
|
Stylus failed to parse usercss:
|
||||||
|
<pre>${err}</pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="code"></div>
|
<div class="code"></div>
|
||||||
`));
|
`));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user