This commit is contained in:
tophf 2021-07-30 09:15:09 +03:00
parent 3a935bd1d5
commit 15e6a64573
3 changed files with 8 additions and 6 deletions

View File

@ -395,7 +395,7 @@
<details id="publish" data-pref="editor.publish.expanded" class="ignore-pref-if-compact">
<summary><h2 i18n-text="publish"></h2></summary>
<div>
<a id="usw-url" href="https://userstyles.world" i18n-text-append="publishUsw" target="_blank"></a>
<a id="usw-url" href="https://userstyles.world" target="_blank">&nbsp;</a>
<div id="usw-link-info">
<dl><dt i18n-text="styleName"></dt><dd data-usw="name"></dd></dl>
<dl><dt i18n-text="genericDescription"></dt><dd data-usw="description"></dd></dl>

View File

@ -298,8 +298,9 @@ input:invalid {
#publish a:visited {
margin-top: .75em;
}
#publish[data-connected] h2:first-letter {
color: darkcyan;
#publish[data-connected] summary::marker,
#publish[data-connected] h2 {
color: hsl(180, 100%, 20%);
}
#publish:not([data-connected]) #usw-link-info,
#publish:not([data-connected]) #usw-disconnect {

View File

@ -36,15 +36,16 @@
}
const code = editor.getValue();
const isDiff = code !== prevCode;
prevCode = code;
const res = isDiff ? await API.usw.publish(id, code) : t('importReportUnchanged');
const title = `${new Date().toLocaleString()}\n${res}`;
$(PROGRESS).append(.../^Error:/.test(res) && [
const failed = /^Error:/.test(res);
$(PROGRESS).append(...failed && [
$create('div.error', {title}, res),
$create('div', t('publishReconnect')),
] || [
$create(`span.${isDiff ? 'success' : 'unchanged'}`, {title}),
]);
if (!failed) prevCode = code;
}
async function disconnect() {
@ -61,7 +62,7 @@
}
const elUrl = $('#usw-url');
elUrl.href = `${URLS.usw}${usw.id ? `style/${usw.id}` : ''}`;
elUrl.textContent = elUrl.textContent.replace(/#\d+/, '').replace(elUrl.hostname, '$&' + (usw.id ? `#${usw.id}` : ''));
elUrl.textContent = t('publishUsw').replace(/<(.+)>/, `$1${usw.id ? `#${usw.id}` : ''}`);
}
//#endregion