[fix] form persist
This commit is contained in:
parent
c4bf51233a
commit
145334a0d7
1 changed files with 8 additions and 3 deletions
|
@ -21,8 +21,9 @@ window.addEventListener('load', () => {
|
|||
svr = x.href;
|
||||
}
|
||||
$("iServer").value = svr;
|
||||
view.setState(lsp.EditorState.create({ doc: doc, extensions: lsp.baseExts }));
|
||||
formFromStore('fSettings');
|
||||
view.setState(lsp.EditorState.create({ doc: doc, extensions: lsp.baseExts }));
|
||||
lsp.updateCompartment(objectFromForm('fSettings'))
|
||||
connect();
|
||||
});
|
||||
|
||||
|
@ -129,8 +130,7 @@ $("load").onchange = e => {
|
|||
|
||||
function updateSettings(event) {
|
||||
event.preventDefault();
|
||||
const form = $('fSettings');
|
||||
console.log("ser..", formSerialize(form))
|
||||
|
||||
console.log("COPTS", lsp.curOpts);
|
||||
const opts = {
|
||||
lineWrap: $("lineWrap").checked,
|
||||
|
@ -209,6 +209,11 @@ function formToStore(name) {
|
|||
localStorage.setItem(name, formSerialize($(name)));
|
||||
};
|
||||
|
||||
function objectFromForm(name) {
|
||||
const data = new FormData($(name));
|
||||
//https://stackabuse.com/convert-form-data-to-javascript-object/
|
||||
return Object.fromEntries(data.entries());
|
||||
}
|
||||
function formSerialize(form) {
|
||||
const data = new FormData(form);
|
||||
//https://stackoverflow.com/a/44033425/1869660
|
||||
|
|
Loading…
Add table
Reference in a new issue