Variable ADMIN_OPERATE_JSConst
ADMIN_OPERATE_JS: "(function () {\n\tconst out = document.getElementById('operate-out');\n\tconst pane = document.getElementById('operate-result');\n\tfunction show(data) {\n\t\tconst pre = document.createElement('pre');\n\t\tpre.style.margin = '0';\n\t\tpre.style.overflowX = 'auto';\n\t\tpre.textContent = typeof data === 'string' ? data : JSON.stringify(data, null, 2);\n\t\tconst card = document.createElement('div');\n\t\tcard.className = 'card';\n\t\tcard.appendChild(pre);\n\t\tpane.replaceChildren(card);\n\t}\n\tasync function ask(path, query) {\n\t\tconst res = await fetch(path + (query ? '?' + query : ''), { credentials: 'same-origin' });\n\t\tif (res.status === 401) {\n\t\t\twindow.location.href =\n\t\t\t\t'__CFW_LOGIN_PATH__?next=' + encodeURIComponent(location.pathname);\n\t\t\treturn null;\n\t\t}\n\t\tconst text = await res.text();\n\t\ttry {\n\t\t\treturn JSON.parse(text);\n\t\t} catch (e) {\n\t\t\treturn text.slice(0, 4000);\n\t\t}\n\t}\n\tdocument.querySelectorAll('button[data-op]').forEach((b) => {\n\t\tb.addEventListener('click', async () => {\n\t\t\tif (\n\t\t\t\tb.dataset.writes === '1' &&\n\t\t\t\t!window.confirm(b.dataset.label + '? This changes the site.')\n\t\t\t)\n\t\t\t\treturn;\n\t\t\tout.textContent = b.dataset.label + '...';\n\t\t\ttry {\n\t\t\t\tconst data = await ask(b.dataset.path, b.dataset.query);\n\t\t\t\tif (data === null) return;\n\t\t\t\tout.textContent = b.dataset.label + ': done';\n\t\t\t\tshow(data);\n\t\t\t} catch (err) {\n\t\t\t\tout.textContent = 'Failed: ' + err.message;\n\t\t\t}\n\t\t});\n\t});\n\tdocument.getElementById('mailtest-form').addEventListener('submit', async (e) => {\n\t\te.preventDefault();\n\t\tconst o = document.getElementById('mailtest-out');\n\t\tconst to = String(new FormData(e.target).get('to') || '');\n\t\tif (!to) {\n\t\t\to.textContent = 'Enter an address to send the test to.';\n\t\t\treturn;\n\t\t}\n\t\to.textContent = 'Sending...';\n\t\ttry {\n\t\t\tconst res = await fetch('/setup/mail?action=test&to=' + encodeURIComponent(to), {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tcredentials: 'same-origin'\n\t\t\t});\n\t\t\tconst data = await res.json();\n\t\t\tconst t = data.test || data;\n\t\t\t// the TRANSPORT either way: \"which one refused\" is the first thing an operator asks\n\t\t\to.textContent = t.ok\n\t\t\t\t? 'Sent through ' +\n\t\t\t\t\t(t.transport || 'the configured transport') +\n\t\t\t\t\t' as ' +\n\t\t\t\t\t(t.from || '?') +\n\t\t\t\t\t'. Check the inbox; delivery is the proof, not this line.'\n\t\t\t\t: 'Refused' +\n\t\t\t\t\t(t.transport ? ' by ' + t.transport : '') +\n\t\t\t\t\t': ' +\n\t\t\t\t\t(t.error || 'no reason given');\n\t\t} catch (err) {\n\t\t\to.textContent = 'Failed: ' + err.message;\n\t\t}\n\t});\n\tdocument.getElementById('restore-form').addEventListener('submit', async (e) => {\n\t\te.preventDefault();\n\t\tconst o = document.getElementById('restore-out');\n\t\tconst form = new FormData(e.target);\n\t\tif (form.get('confirm') !== 'replace') {\n\t\t\to.textContent = 'Type the word replace to confirm, so this cannot happen by accident.';\n\t\t\treturn;\n\t\t}\n\t\tconst bookmark = String(form.get('bookmark') || '');\n\t\tif (!bookmark) {\n\t\t\to.textContent = 'Paste a bookmark from Recovery Points above.';\n\t\t\treturn;\n\t\t}\n\t\to.textContent = 'Scheduling...';\n\t\ttry {\n\t\t\tconst res = await fetch('/pitr?bookmark=' + encodeURIComponent(bookmark), {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tcredentials: 'same-origin'\n\t\t\t});\n\t\t\tconst data = await res.json();\n\t\t\tif (!data.ok) throw new Error(data.error || 'refused');\n\t\t\t// the undo exists ONLY in this reply; there is no second call that can produce it\n\t\t\to.textContent =\n\t\t\t\t\"Scheduled; it applies on this object's next start. Keep this undo bookmark, it is the only way back: \" +\n\t\t\t\t(data.undo || 'none reported');\n\t\t} catch (err) {\n\t\t\to.textContent = 'Failed: ' + err.message;\n\t\t}\n\t});\n})();\n"