mirror of
https://github.com/webui-dev/webui.git
synced 2024-09-11 14:06:09 +03:00
Update webui_fn to webui.call
* Update all old js APIs `webui_fn()` to `webui.call()`
This commit is contained in:
parent
52885648d2
commit
3133bcb92a
@ -9,7 +9,7 @@
|
||||
void my_function_string(webui::window::event* e) {
|
||||
|
||||
// JavaScript:
|
||||
// webui_fn('MyID_One', 'Hello');
|
||||
// webui.call('MyID_One', 'Hello');
|
||||
|
||||
std::string str = e->get_string();
|
||||
std::cout << "my_function_string: " << str << std::endl; // Hello
|
||||
@ -28,7 +28,7 @@ void my_function_string(webui::window::event* e) {
|
||||
void my_function_integer(webui::window::event* e) {
|
||||
|
||||
// JavaScript:
|
||||
// webui_fn('MyID_Two', 123456789);
|
||||
// webui.call('MyID_Two', 123456789);
|
||||
|
||||
long long number = e->get_int();
|
||||
std::cout << "my_function_integer: " << number << std::endl; // 123456789
|
||||
@ -37,7 +37,7 @@ void my_function_integer(webui::window::event* e) {
|
||||
void my_function_boolean(webui::window::event* e) {
|
||||
|
||||
// JavaScript:
|
||||
// webui_fn('MyID_Three', true);
|
||||
// webui.call('MyID_Three', true);
|
||||
|
||||
bool status = e->get_bool(); // True
|
||||
if(status)
|
||||
@ -49,7 +49,7 @@ void my_function_boolean(webui::window::event* e) {
|
||||
void my_function_with_response(webui::window::event* e) {
|
||||
|
||||
// JavaScript:
|
||||
// const result = webui_fn('MyID_Four', number);
|
||||
// const result = webui.call('MyID_Four', number);
|
||||
|
||||
long long number = e->get_int();
|
||||
number = number * 2;
|
||||
@ -80,13 +80,13 @@ int main() {
|
||||
<h2>WebUI - Call C++ from JavaScript Example</h2>
|
||||
<p>Call C++ function with argument (<em>See the logs in your terminal</em>)</p>
|
||||
<br>
|
||||
<button onclick="webui_fn('MyID_One', 'Hello');">Call my_function_string()</button>
|
||||
<button onclick="webui.call('MyID_One', 'Hello');">Call my_function_string()</button>
|
||||
<br>
|
||||
<br>
|
||||
<button onclick="webui_fn('MyID_Two', 123456789);">Call my_function_integer()</button>
|
||||
<button onclick="webui.call('MyID_Two', 123456789);">Call my_function_integer()</button>
|
||||
<br>
|
||||
<br>
|
||||
<button onclick="webui_fn('MyID_Three', true);">Call my_function_boolean()</button>
|
||||
<button onclick="webui.call('MyID_Three', true);">Call my_function_boolean()</button>
|
||||
<br>
|
||||
<br>
|
||||
<p>Call C++ function and wait for the response</p>
|
||||
@ -99,7 +99,7 @@ int main() {
|
||||
function MyJS() {
|
||||
const MyInput = document.getElementById('MyInputID');
|
||||
const number = MyInput.value;
|
||||
webui_fn('MyID_Four', number).then((response) => {
|
||||
webui.call('MyID_Four', number).then((response) => {
|
||||
MyInput.value = response;
|
||||
});
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
void my_function_string(webui_event_t* e) {
|
||||
|
||||
// JavaScript:
|
||||
// webui_fn('MyID_One', 'Hello');
|
||||
// webui.call('MyID_One', 'Hello');
|
||||
|
||||
const char* str = webui_get_string(e);
|
||||
printf("my_function_string: %s\n", str); // Hello
|
||||
@ -24,7 +24,7 @@ void my_function_string(webui_event_t* e) {
|
||||
void my_function_integer(webui_event_t* e) {
|
||||
|
||||
// JavaScript:
|
||||
// webui_fn('MyID_Two', 123456789);
|
||||
// webui.call('MyID_Two', 123456789);
|
||||
|
||||
long long number = webui_get_int(e);
|
||||
printf("my_function_integer: %lld\n", number); // 123456789
|
||||
@ -33,7 +33,7 @@ void my_function_integer(webui_event_t* e) {
|
||||
void my_function_boolean(webui_event_t* e) {
|
||||
|
||||
// JavaScript:
|
||||
// webui_fn('MyID_Three', true);
|
||||
// webui.call('MyID_Three', true);
|
||||
|
||||
bool status = webui_get_bool(e); // True
|
||||
if(status)
|
||||
@ -45,7 +45,7 @@ void my_function_boolean(webui_event_t* e) {
|
||||
void my_function_with_response(webui_event_t* e) {
|
||||
|
||||
// JavaScript:
|
||||
// const result = webui_fn('MyID_Four', number);
|
||||
// const result = webui.call('MyID_Four', number);
|
||||
|
||||
long long number = webui_get_int(e);
|
||||
number = number * 2;
|
||||
@ -76,13 +76,13 @@ int main() {
|
||||
" <h2>WebUI - Call C from JavaScript Example</h2>"
|
||||
" <p>Call C function with argument (<em>See the logs in your terminal</em>)</p>"
|
||||
" <br>"
|
||||
" <button onclick=\"webui_fn('MyID_One', 'Hello');\">Call my_function_string()</button>"
|
||||
" <button onclick=\"webui.call('MyID_One', 'Hello');\">Call my_function_string()</button>"
|
||||
" <br>"
|
||||
" <br>"
|
||||
" <button onclick=\"webui_fn('MyID_Two', 123456789);\">Call my_function_integer()</button>"
|
||||
" <button onclick=\"webui.call('MyID_Two', 123456789);\">Call my_function_integer()</button>"
|
||||
" <br>"
|
||||
" <br>"
|
||||
" <button onclick=\"webui_fn('MyID_Three', true);\">Call my_function_boolean()</button>"
|
||||
" <button onclick=\"webui.call('MyID_Three', true);\">Call my_function_boolean()</button>"
|
||||
" <br>"
|
||||
" <br>"
|
||||
" <p>Call C function and wait for the response</p>"
|
||||
@ -95,7 +95,7 @@ int main() {
|
||||
" function MyJS() {"
|
||||
" const MyInput = document.getElementById('MyInputID');"
|
||||
" const number = MyInput.value;"
|
||||
" webui_fn('MyID_Four', number).then((response) => {"
|
||||
" webui.call('MyID_Four', number).then((response) => {"
|
||||
" MyInput.value = response;"
|
||||
" });"
|
||||
" }"
|
||||
|
@ -75,7 +75,7 @@ function addText(text) {
|
||||
// Save the file
|
||||
function SaveFile() {
|
||||
const content = codeMirrorInstance.getValue();
|
||||
webui_fn('Save', content);
|
||||
webui.call('Save', content);
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
|
Loading…
Reference in New Issue
Block a user