28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
// The look of the panel, as each user set it (Аккаунт › Вид): applied at
|
||
// once on load from what the page came with, and again on every change.
|
||
(function () {
|
||
'use strict';
|
||
let p = Object.assign({}, (window.APP && window.APP.prefs) || {});
|
||
function apply() {
|
||
const b = document.body;
|
||
b.dataset.tabicons = p.tabIcons || 'left';
|
||
b.classList.toggle('compact', !!p.compact);
|
||
b.classList.toggle('no-ftime', p.fileTime === 'hide');
|
||
b.classList.toggle('no-motion', p.motion === 'off');
|
||
// Open terminals take the new size at once.
|
||
if (window.Workspace) Workspace.panes().forEach(t => {
|
||
if (t.term && t.term.options.fontSize !== termFont()) { t.term.options.fontSize = termFont(); t.fit(); }
|
||
});
|
||
}
|
||
const termFont = () => p.termFont || (matchMedia('(pointer: coarse)').matches ? 13 : 14);
|
||
async function set(k, v) {
|
||
p[k] = v;
|
||
apply();
|
||
const r = await fetch('/api/panel/account/prefs', {method: 'POST', headers: {'Content-Type': 'application/json'},
|
||
credentials: 'same-origin', body: JSON.stringify(p)}).then(x => x.json()).catch(() => ({ok: false}));
|
||
return r.ok;
|
||
}
|
||
apply();
|
||
window.Prefs = {get: () => Object.assign({}, p), set, apply, termFont};
|
||
})();
|