push
This commit is contained in:
+2
-40
@@ -1,49 +1,11 @@
|
||||
/*
|
||||
APP — shared chrome for every page: settings dialog, footer API label,
|
||||
toast notifications.
|
||||
APP — shared chrome for every page: footer API label, toast notifications.
|
||||
(Settings moved to its own page: settings.html)
|
||||
*/
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
function initChrome() {
|
||||
const modal = document.getElementById('settingsModal');
|
||||
const openBtn = document.getElementById('settingsBtn');
|
||||
const input = document.getElementById('apiBaseInput');
|
||||
|
||||
if (openBtn && modal && input) {
|
||||
const close = () => {
|
||||
modal.hidden = true;
|
||||
};
|
||||
openBtn.addEventListener('click', () => {
|
||||
input.value = SR.config.getBase();
|
||||
modal.hidden = false;
|
||||
input.focus();
|
||||
input.select();
|
||||
});
|
||||
const closeBtn = document.getElementById('settingsClose');
|
||||
if (closeBtn) closeBtn.addEventListener('click', close);
|
||||
modal.addEventListener('click', (e) => {
|
||||
if (e.target === modal) close();
|
||||
});
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape' && !modal.hidden) close();
|
||||
});
|
||||
const saveBtn = document.getElementById('apiBaseSave');
|
||||
if (saveBtn) {
|
||||
saveBtn.addEventListener('click', () => {
|
||||
SR.config.setBase(input.value);
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
const resetBtn = document.getElementById('apiBaseReset');
|
||||
if (resetBtn) {
|
||||
resetBtn.addEventListener('click', () => {
|
||||
SR.config.clearBase();
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const label = document.getElementById('apiBaseLabel');
|
||||
if (label) {
|
||||
const base = SR.config.getBase();
|
||||
|
||||
Reference in New Issue
Block a user