update cookie handling, process saved state and defaults
This commit is contained in:
parent
e64897654c
commit
758cee8d46
3 changed files with 23 additions and 20 deletions
13
app.js
13
app.js
|
|
@ -62,14 +62,15 @@ function init(mod) {
|
|||
|
||||
mod.on.reload(() => level.close());
|
||||
mod.on.test((req) => {
|
||||
let vmatch = mod.meta.version || undefined;
|
||||
let strict = (vmatch && mod.vmatch !== "*") ? true : false;
|
||||
let cookie = cookieValue(req.headers.cookie, "version") || undefined;
|
||||
if (strict) {
|
||||
return cookie === mod.meta.version;
|
||||
} else {
|
||||
return (!vmatch && !cookie) || (vmatch && cookie);
|
||||
let vmatch = mod.meta.version || "*";
|
||||
if (!Array.isArray(vmatch)) {
|
||||
vmatch = [ vmatch ];
|
||||
}
|
||||
if (vmatch.indexOf("*") >= 0) {
|
||||
return true;
|
||||
}
|
||||
return vmatch.indexOf(cookie) >= 0;
|
||||
});
|
||||
|
||||
mod.add(handleOptions);
|
||||
|
|
|
|||
|
|
@ -554,9 +554,10 @@
|
|||
s = settings(),
|
||||
def = "default",
|
||||
cp = s.process,
|
||||
pl = s.sproc[mode];
|
||||
pl = s.sproc[mode],
|
||||
lp = s.cproc[mode];
|
||||
|
||||
UC.prompt("Save Settings As", cp ? cp.processName || def : def).then(name => {
|
||||
UC.prompt("Save Settings As", cp ? lp || def : def).then(name => {
|
||||
if (name) {
|
||||
let np = pl[name] = {};
|
||||
cp.processName = name;
|
||||
|
|
@ -564,7 +565,6 @@
|
|||
if (!cp.hasOwnProperty(k)) continue;
|
||||
np[k] = cp[k];
|
||||
}
|
||||
s.cproc[mode] = name;
|
||||
s.devproc[s.device.deviceName] = name;
|
||||
API.conf.save();
|
||||
API.conf.update();
|
||||
|
|
@ -1140,7 +1140,7 @@
|
|||
|
||||
renm.setAttribute('class', 'rename');
|
||||
renm.setAttribute('title', 'rename file');
|
||||
renm.appendChild(DOC.createTextNode('n'));
|
||||
renm.innerHTML = '<i class="far fa-edit"></i>';
|
||||
renm.onclick = () => {
|
||||
let newname = prompt(`rename file`, short);
|
||||
if (newname && newname !== short) {
|
||||
|
|
@ -1158,7 +1158,7 @@
|
|||
del.setAttribute('del', name);
|
||||
del.setAttribute('title', "remove '"+name+"'");
|
||||
del.onclick = deleteCatalogFile;
|
||||
del.appendChild(DOC.createTextNode('x'));
|
||||
del.innerHTML = '<i class="far fa-trash-alt"></i>';
|
||||
|
||||
size.setAttribute("disabled", true);
|
||||
size.setAttribute("class", "label");
|
||||
|
|
|
|||
|
|
@ -1497,8 +1497,8 @@
|
|||
if (view.left || view.up) {
|
||||
settings.controller.view = view;
|
||||
}
|
||||
const mode = settings.mode, name = settings.process.processName;
|
||||
settings.sproc[mode][name] = settings.process;
|
||||
const mode = settings.mode;
|
||||
settings.sproc[mode].default = settings.process;
|
||||
settings.device.bedRound = UI.deviceRound.checked;
|
||||
settings.device.originCenter = UI.deviceOrigin.checked;
|
||||
SDB.setItem('ws-settings', JSON.stringify(settings));
|
||||
|
|
@ -1833,7 +1833,7 @@
|
|||
|
||||
function loadSettings(e, named) {
|
||||
let mode = getMode(),
|
||||
name = e ? e.target.getAttribute("load") : named || settings.cproc[mode],
|
||||
name = e ? e.target.getAttribute("load") : named || "default",
|
||||
load = settings.sproc[mode][name];
|
||||
|
||||
if (!load) return;
|
||||
|
|
@ -1842,11 +1842,12 @@
|
|||
settings.process = clone(load);
|
||||
// update process name
|
||||
settings.process.processName = name;
|
||||
// set currenet process name for this mode
|
||||
settings.cproc[mode] = name;
|
||||
// save named process with the current device
|
||||
settings.devproc[currentDeviceName()] = name;
|
||||
|
||||
// preserve name of last library loaded
|
||||
if (name !== 'default') {
|
||||
settings.cproc[mode] = name;
|
||||
}
|
||||
// allow mode driver to take any necessary actions
|
||||
API.event.emit("settings.load", settings);
|
||||
|
||||
|
|
@ -1871,7 +1872,7 @@
|
|||
for (let k in sp) {
|
||||
if (sp.hasOwnProperty(k)) list.push(k);
|
||||
}
|
||||
list.sort().forEach(function(sk) {
|
||||
list.filter(n => n !=='default').sort().forEach(function(sk) {
|
||||
let row = DOC.createElement('div'),
|
||||
load = DOC.createElement('button'),
|
||||
edit = DOC.createElement('button'),
|
||||
|
|
@ -1882,6 +1883,7 @@
|
|||
load.onclick = (ev) => {
|
||||
API.conf.load(undefined, sk);
|
||||
updateSettingsList();
|
||||
hideModal();
|
||||
}
|
||||
load.appendChild(DOC.createTextNode(sk));
|
||||
if (sk == settings.process.processName) {
|
||||
|
|
@ -1890,12 +1892,12 @@
|
|||
|
||||
del.setAttribute('del', sk);
|
||||
del.setAttribute('title', "remove '"+sk+"'");
|
||||
del.innerHTML = '<i class="far fa-trash-alt"></i>';
|
||||
del.onclick = deleteSettings;
|
||||
del.appendChild(DOC.createTextNode('x'));
|
||||
|
||||
edit.innerHTML = '↑';
|
||||
edit.setAttribute('name', sk);
|
||||
edit.setAttribute('title', 'edit');
|
||||
edit.innerHTML = '<i class="far fa-edit"></i>';
|
||||
edit.onclick = editSettings;
|
||||
|
||||
row.setAttribute("class", "flow-row");
|
||||
|
|
|
|||
Loading…
Reference in a new issue