-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68698a8
commit 885840a
Showing
133 changed files
with
14,625 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// This file gets called like follow: | ||
// | ||
// 1. UI `Index.html` request: | ||
// `http://localhost:xxx/bun_test.ts?foo=123&bar=456` | ||
// | ||
// 2. WebUI runs command: | ||
// `bun run "bun_test.ts" "foo=123&bar=456"` | ||
// | ||
// 3. Bun parses args and prints the response | ||
|
||
// Get Query (HTTP GET) | ||
const args = process.argv.slice(2); | ||
const query = args[0]; | ||
|
||
// Variables | ||
let foo: string = ''; | ||
let bar: string = ''; | ||
|
||
// Read Query | ||
const params = new URLSearchParams(query); | ||
for (const [key, value] of params.entries()) { | ||
if (key === 'foo') foo = value; // 123 | ||
else if (key === 'bar') bar = value; // 456 | ||
} | ||
|
||
console.log('Response from Bun: ' + (parseInt(foo) + parseInt(bar))); // 579 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>WebUI - Virtual File System</title> | ||
<style> | ||
body { | ||
font-family: 'Arial', sans-serif; | ||
color: white; | ||
background: linear-gradient(to right, #507d91, #1c596f, #022737); | ||
text-align: center; | ||
font-size: 18px; | ||
} | ||
button, | ||
input { | ||
padding: 10px; | ||
border-radius: 3px; | ||
border: 1px solid #ccc; | ||
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1); | ||
transition: 0.2s; | ||
} | ||
button { | ||
background: #3498db; | ||
color: #fff; | ||
cursor: pointer; | ||
font-size: 16px; | ||
} | ||
h1 { | ||
text-shadow: -7px 10px 7px rgb(67 57 57 / 76%); | ||
} | ||
button:hover { | ||
background: #c9913d; | ||
} | ||
input:focus { | ||
outline: none; | ||
border-color: #3498db; | ||
} | ||
|
||
a:link { | ||
color: #fd5723; | ||
} | ||
a:active { | ||
color: #fd5723; | ||
} | ||
a:visited { | ||
color: #fd5723; | ||
} | ||
a:hover { | ||
color: #f0bcac; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h3 id="title">Virtual File System Example</h3> | ||
<br /> | ||
<img src="svg/webui.svg"> | ||
<br /> | ||
<p> | ||
This file is embedded in this application.<br /> | ||
</p> | ||
<h4><a href="sub">/sub</a></h4> | ||
<br /> | ||
<button id="Exit">Exit</button> | ||
</body> | ||
|
||
<!-- Connect this window to the background app --> | ||
<script src="/webui.js"></script> | ||
|
||
<script> | ||
|
||
// JavaScript Example | ||
/* | ||
document.addEventListener('DOMContentLoaded', function() { | ||
// DOM is loaded. Check if `webui` object is available | ||
if (typeof webui !== 'undefined') { | ||
// Set events callback | ||
webui.setEventCallback((e) => { | ||
if (e == webui.event.CONNECTED) { | ||
// Connection to the backend is established | ||
console.log('Connected.'); | ||
webuiTest(); | ||
} else if (e == webui.event.DISCONNECTED) { | ||
// Connection to the backend is lost | ||
console.log('Disconnected.'); | ||
} | ||
}); | ||
} else { | ||
// The virtual file `webui.js` is not included | ||
alert('Please add webui.js to your HTML.'); | ||
} | ||
}); | ||
function webuiTest() { | ||
// Call a backend function | ||
if (webui.isConnected()) { | ||
// When you bind a func in the backend | ||
// webui will create the `func` object | ||
// in three places: | ||
// | ||
// Global : func(...) | ||
// Property : webui.func(...) | ||
// Method : webui.call('func', ...) | ||
// | ||
// [!] Note: Objects creation fails when | ||
// a similar object already exist. | ||
const foo = 'Hello'; | ||
const bar = 123456; | ||
// Calling as global object | ||
myBackendFunction(foo, bar).then((response) => { | ||
// Do something with `response` | ||
}); | ||
// Calling as property of `webui.` object | ||
webui.myBackendFunction(foo, bar).then((response) => { | ||
// Do something with `response` | ||
}); | ||
// Calling using the method `webui.call()` | ||
webui.call('myBackendFunction', foo, bar).then((response) => { | ||
// Do something with `response` | ||
}); | ||
// Using await | ||
// const response = await myBackendFunction(foo, bar); | ||
// const response = await webui.myBackendFunction(foo, bar); | ||
// const response = await webui.call('myBackendFunction', foo, bar); | ||
} | ||
} | ||
*/ | ||
|
||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>WebUI - Virtual File System</title> | ||
<style> | ||
body { | ||
font-family: 'Arial', sans-serif; | ||
color: white; | ||
background: linear-gradient(to right, #507d91, #1c596f, #022737); | ||
text-align: center; | ||
font-size: 18px; | ||
} | ||
button, | ||
input { | ||
padding: 10px; | ||
border-radius: 3px; | ||
border: 1px solid #ccc; | ||
box-shadow: 0 3px 5px rgba(0, 0, 0, 0.1); | ||
transition: 0.2s; | ||
} | ||
button { | ||
background: #3498db; | ||
color: #fff; | ||
cursor: pointer; | ||
font-size: 16px; | ||
} | ||
h1 { | ||
text-shadow: -7px 10px 7px rgb(67 57 57 / 76%); | ||
} | ||
button:hover { | ||
background: #c9913d; | ||
} | ||
input:focus { | ||
outline: none; | ||
border-color: #3498db; | ||
} | ||
|
||
a:link { | ||
color: #fd5723; | ||
} | ||
a:active { | ||
color: #fd5723; | ||
} | ||
a:visited { | ||
color: #fd5723; | ||
} | ||
a:hover { | ||
color: #f0bcac; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<p> | ||
This is another file embedded in this application.<br /> | ||
</p> | ||
<br /> | ||
<button id="Exit">Exit</button> | ||
</body> | ||
|
||
<!-- Connect this window to the background app --> | ||
<script src="/webui.js"></script> | ||
|
||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.