This commit is contained in:
wukko 2023-05-17 02:31:22 +06:00
parent d85205649e
commit 61357c76f2
2 changed files with 12 additions and 13 deletions

View file

@ -414,25 +414,24 @@ async function loadCelebrationsEmoji() {
} }
} }
async function loadOnDemand(elementId, blockId) { async function loadOnDemand(elementId, blockId) {
let j = {};
store.historyButton = eid(elementId).innerHTML; store.historyButton = eid(elementId).innerHTML;
let j = {} eid(elementId).innerHTML = "...";
eid(elementId).innerHTML = "..."
try { try {
if (store.historyContent) { if (store.historyContent) {
j = store.historyContent; j = store.historyContent;
} else { } else {
j = await fetch(`${apiURL}/api/onDemand?blockId=${blockId}`).then((r) => { if (r.status === 200) { return r.json() } else { return false } }).catch(() => { return false }); await fetch(`${apiURL}/api/onDemand?blockId=${blockId}`).then(async(r) => {
j = await r.json();
if (j && j.status === "success") { if (j && j.status === "success") {
store.historyContent = j; store.historyContent = j;
} else { } else throw new Error();
throw new Error(); }).catch(() => { throw new Error() });
}
} }
if (j.text) { if (j.text) {
eid(elementId).innerHTML = `<button class="switch bottom-margin" onclick="restoreUpdateHistory()">${loc.collapseHistory}</button>${j.text}`; eid(elementId).innerHTML = `<button class="switch bottom-margin" onclick="restoreUpdateHistory()">${loc.collapseHistory}</button>${j.text}`;
} else { } else throw new Error()
throw new Error()
}
} catch (e) { } catch (e) {
eid(elementId).innerHTML = store.historyButton; eid(elementId).innerHTML = store.historyButton;
internetError() internetError()

View file

@ -131,8 +131,8 @@ export function popupWithBottomButtons(obj) {
export function backdropLink(link, text) { export function backdropLink(link, text) {
return `<a class="text-backdrop italic" href="${link}" target="_blank">${text}</a>` return `<a class="text-backdrop italic" href="${link}" target="_blank">${text}</a>`
} }
export function socialLink(emoji, name, handle, url) { export function socialLink(emji, name, handle, url) {
return `<div class="cobalt-support-link">${emoji} ${name}: <a class="text-backdrop italic" href="${url}" target="_blank">${handle}</a></div>` return `<div class="cobalt-support-link">${emji} ${name}: <a class="text-backdrop italic" href="${url}" target="_blank">${handle}</a></div>`
} }
export function settingsCategory(obj) { export function settingsCategory(obj) {
return `<div id="settings-${obj.name}" class="settings-category"> return `<div id="settings-${obj.name}" class="settings-category">