[mod] samples
This commit is contained in:
parent
2f54b3370e
commit
6e88dd1509
22 changed files with 1048 additions and 142 deletions
|
|
@ -12,15 +12,23 @@
|
|||
|
||||
<body>
|
||||
<header>BaseX LSP client <button id="search">🔍</button>
|
||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||
<button id="lint">⚠️</button>
|
||||
<div style="float:right">
|
||||
<input id="iServer" type="text" value="ws://localhost:3000/ws/lsp" /><button id="connect">connect</button>
|
||||
<span id="state">🔴</span>
|
||||
<input id="iServer" type="text" value="ws://localhost:3000/ws/lsp" style="width:25em" /><button id="connect">connect</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div class="item">stuff</div>
|
||||
<!-- Editor goes in here -->
|
||||
<div class="item">
|
||||
<div>
|
||||
<label for="file">File:</label><input id="iFile" type="url" value="file:///some/file.xml" />
|
||||
</div>
|
||||
<div>
|
||||
<label for="symbols">Symbols:</label><select id="symbols" disabled="disabled"></select>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Editor goes in here -->
|
||||
<div id="editor" class="item"></div>
|
||||
</div>
|
||||
|
||||
|
|
@ -28,19 +36,7 @@
|
|||
<script src="./lsp.bundle.js"></script>
|
||||
<script>
|
||||
|
||||
const server = "ws://localhost:3000/ws/lsp";
|
||||
let doc = `/**
|
||||
*
|
||||
* @param {string[]} items
|
||||
* @param nada
|
||||
*/
|
||||
function foo(items, nada) {
|
||||
for (var i=0; i<items.length; i++) {
|
||||
alert(items[i] + 'juhu');
|
||||
} // Real Tab.
|
||||
//
|
||||
//
|
||||
}`;
|
||||
let doc = `<foo at=42><bar>test</bar></foo>`;
|
||||
// Load saved content from localStorage when the page loads
|
||||
window.addEventListener('load', () => {
|
||||
const savedText = localStorage.getItem('code');
|
||||
|
|
@ -59,21 +55,27 @@ function foo(items, nada) {
|
|||
localStorage.setItem('code', doc);
|
||||
});
|
||||
document.getElementById("connect").onclick = e => {
|
||||
const v = document.getElementById("iServer").value;
|
||||
alert(v)
|
||||
|
||||
connect()
|
||||
};
|
||||
document.getElementById("search").onclick = e => {
|
||||
lsp.openSearchPanel(view);
|
||||
};
|
||||
|
||||
lsp.simpleWebSocketTransport(server)
|
||||
.then(transport => {
|
||||
let link = lsp.lsp(transport, "file:///some/file.xml");
|
||||
const state = lsp.createEditorState(doc, [...lsp.baseExts, link]);
|
||||
view.setState(state);
|
||||
})
|
||||
.catch(r => alert("fail"));
|
||||
|
||||
document.getElementById("lint").onclick = e => {
|
||||
lsp.openLintPanel(view);
|
||||
};
|
||||
function connect() {
|
||||
const server = document.getElementById("iServer").value;
|
||||
const file = document.getElementById("iFile").value;
|
||||
lsp.simpleWebSocketTransport(server)
|
||||
.then(transport => {
|
||||
let link = lsp.lsp(transport, file);
|
||||
const state = lsp.createEditorState(doc, [...lsp.baseExts, link]);
|
||||
view.setState(state);
|
||||
})
|
||||
.catch(r => alert("fail"));
|
||||
};
|
||||
connect();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue