[fix] catch errs

This commit is contained in:
Andy Bunce 2025-11-03 16:36:30 +00:00
parent 6ff94888ef
commit 4c6570e2b4
2 changed files with 37 additions and 55 deletions

View file

@ -48,30 +48,6 @@
</quiet-button> </quiet-button>
<quiet-select id="load" style="width:16em;">
<option selected value="">load..</option>
<optgroup label="XQuery3">
<option
value="https://raw.githubusercontent.com/expkg-zone58/pdfbox/refs/heads/main/src/Pdfbox3.xqm">
Pdfbox3.xqm</option>
<option
value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm">
model.xqm</option>
</optgroup>
<optgroup label="XQuery4">
<option
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm">
lsp-text.xqm</option>
<option value="../../../lsp/lsp-text.xqm">
lsp-text.xqm</option>
</optgroup>
<optgroup label="xpath">
<option
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq">
generator.xquery</option>
</optgroup>
</quiet-select>
</quiet-button-group> </quiet-button-group>
<quiet-button-group> <quiet-button-group>
@ -94,7 +70,6 @@
<quiet-toolbar> <quiet-toolbar>
<quiet-button-group> <quiet-button-group>
<button id="search" title="Search" type="button"><i class="codicon codicon-search"></i></button> <button id="search" title="Search" type="button"><i class="codicon codicon-search"></i></button>
<button id="lint" title="Display diagnostics" type="button"><i <button id="lint" title="Display diagnostics" type="button"><i
@ -113,6 +88,7 @@
<button id="cmdList" type="button" title="Command and key mapping help"> <button id="cmdList" type="button" title="Command and key mapping help">
<i class="codicon codicon-record-keys"></i> <i class="codicon codicon-record-keys"></i>
</button> </button>
<button type="button" popovertarget="popSettings" title="Settings"> <button type="button" popovertarget="popSettings" title="Settings">
<i class="codicon codicon-settings"></i></button> <i class="codicon codicon-settings"></i></button>
</quiet-button-group> </quiet-button-group>
@ -122,13 +98,12 @@
<i class="codicon codicon-screen-full"></i> <i class="codicon codicon-screen-full"></i>
</button> </button>
<button id="bnSave" type="button" title="save view"> <button id="bnSave" type="button" title="save view">
<i class="codicon codicon-git-stash"></i></button> <i class="codicon codicon-git-stash"></i></button>
<button id="bnLoad" type="button" title="load view"> <button id="bnLoad" type="button" title="load view">
<i class="codicon codicon-git-stash-pop"></i></button> <i class="codicon codicon-git-stash-pop"></i></button>
<button id="bnWordAt" type="button" title="word at"> <button id="bnWordAt" type="button" title="word at">
<i class="codicon codicon-whole-word"></i></button> <i class="codicon codicon-whole-word"></i></button>
@ -201,9 +176,11 @@
</select> </select>
</footer> </footer>
</div> </div>
<!-- dialogs --> <!-- dialogs -->
<quiet-popover for="popover__url"> <quiet-popover id="popWeb" for="popover__url">
<form style="background: #ffecb3;"> <form id="popUrl" style="background: #ffecb3;">
<quiet-text-field type="url" name="url" label="URL to fetch" placeholder="http://..." with-clear required <quiet-text-field type="url" name="url" label="URL to fetch" placeholder="http://..." with-clear required
style="width: 20em;"> style="width: 20em;">
<datalist> <datalist>
@ -214,8 +191,8 @@
value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm"> value="https://raw.githubusercontent.com/Quodatum/xqdoca/refs/heads/master/src/main/lib/model.xqm">
model.xqm (Quodatum/xqdoca)</option> model.xqm (Quodatum/xqdoca)</option>
<option <option
value="https://git.quodatum.duckdns.org/quodatum/basex-lsp/raw/branch/main/webapp/lsp/lsp-text.xqm"> value="https://git.quodatum.duckdns.org/api/v1/repos/quodatum/basex-lsp/raw/webapp/lsp/lsp-text.xqm">
lsp-text.xqm</option> lsp-text.xqm (quodatum/basex-lsp FORGEIO)</option>
<option <option
value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq"> value="https://raw.githubusercontent.com/dnovatchev/Articles/refs/heads/main/Generators/Code/generator.xq">
generator.xquery</option> generator.xquery</option>

View file

@ -42,16 +42,15 @@ $("connect").onclick = e => { e.preventDefault(); connect() };
$("symTrigger").onclick = e => { e.preventDefault(); }; $("symTrigger").onclick = e => { e.preventDefault(); };
$("symOptions").onclick = e => { e.preventDefault(); }; $("symOptions").onclick = e => { e.preventDefault(); };
$("bnNew").onclick = e => { $("bnNew").onclick = e => {
let name = prompt("New file name?"); let name = prompt("New file name?", "untitled.xq");
if (name === null) return; if (name === null) return;
alert("TODO") docSwitch("", name);
}; };
$("search").onclick = e => lsp.openSearchPanel(view); $("search").onclick = e => lsp.openSearchPanel(view);
$("fullscreen").onclick = e => $("editor").requestFullscreen(); $("fullscreen").onclick = e => $("editor").requestFullscreen();
$("bnWordAt").onclick = e => { $("bnWordAt").onclick = e => {
let pos = view.state.selection.main.head; let pos = view.state.selection.main.head;
let w = view.state.wordAt(pos); let w = view.state.wordAt(pos);
@ -64,7 +63,6 @@ $("symbols2").onclick = e => {
.then(r => { .then(r => {
console.log("symbols", r) console.log("symbols", r)
$("symPanel").open = true; $("symPanel").open = true;
$("symList").setData(r); $("symList").setData(r);
}); });
}; };
@ -102,34 +100,30 @@ $("bnLoad").onclick = e => { const v = workspace[iFile]; if (v) view.setState(v)
// select local file // select local file
$("bnRead").onclick = e => { $("fileElem").click(); }; $("bnRead").onclick = e => { $("fileElem").click(); };
$("fileElem").onchange = e => { $("fileElem").onchange = e => {
let file = e.target.files[0]
let fr = new FileReader(); let fr = new FileReader();
fr.onload = function () { fr.onload = () => docSwitch(fr.result, file.name);
alert(fr.result); fr.readAsText(file);
}
fr.readAsText(e.target.files[0]);
}; };
$("format").onclick = e => { console.log("FMT", lsp.formatDocument(view)); }; $("format").onclick = e => { console.log("FMT", lsp.formatDocument(view)); };
$("load").onchange = e => { $("popUrl").onsubmit = e => {
const url = e.target.value; e.preventDefault();
if (url.length == 0) return const f = objectFromForm("popUrl");
fetch(url) fetch(f.url)
.then(response => response.text()) .then(response => response.text())
.then(t => { .then(t => {
view.dispatch({ docSwitch(t, f.url)
$("popWeb").open = false;
changes: {
from: 0,
to: view.state.doc.length,
insert: t
}
}) })
//client.sync(); .catch(error => {
//console.log("SYNC"); alert("CORS?: " + error)
}); });
$("load").value = "";
}; };
$("tConnect").addEventListener('quiet-change', e => { $("tConnect").addEventListener('quiet-change', e => {
e.preventDefault(); e.preventDefault();
$("popConnect").showPopover() $("popConnect").showPopover()
@ -185,6 +179,17 @@ function connect() {
}; };
// change active doc
function docSwitch(text, url) {
view.dispatch({
changes: {
from: 0,
to: view.state.doc.length,
insert: text
}
})
$("iFile").value = url;
};
function incoming(msg) { function incoming(msg) {