aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-25 18:48:33 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-25 18:48:33 +0200
commit1be62a3787d178dad44dd6635969ac6f7ba74749 (patch)
tree5a6181cddc510d91647382efad91919f5f2ed24e
parent9e622e3487268756dd73303789392a08820adc71 (diff)
downloadFlightCore-1be62a3787d178dad44dd6635969ac6f7ba74749.tar.gz
FlightCore-1be62a3787d178dad44dd6635969ac6f7ba74749.zip
Update formatting
-rw-r--r--src-ui/src/main.ts58
1 files changed, 29 insertions, 29 deletions
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts
index 6492a32a..f964a6d5 100644
--- a/src-ui/src/main.ts
+++ b/src-ui/src/main.ts
@@ -1,35 +1,35 @@
-import { invoke } from '@tauri-apps/api';
-import { Event as TauriEvent, listen } from '@tauri-apps/api/event';
+import { invoke } from "@tauri-apps/api";
+import { listen, Event as TauriEvent } from "@tauri-apps/api/event";
+
const $ = document.querySelector.bind(document);
document.addEventListener("DOMContentLoaded", async function () {
- // get the elements
- const helloEl = $("div.hello") as HTMLElement;
- const counterButtonEl = $("counter-button") as HTMLElement;
- const counterResultEl = $("counter-result") as HTMLElement;
- const pingEl = $("backend-ping") as HTMLElement;
-
- // listen backend-ping event
- listen("backend-ping", function (evt: TauriEvent<any>) {
- pingEl.classList.add("on");
- setTimeout(function () {
- pingEl.classList.remove("on")
- }, 500);
- })
+ // get the elements
+ const helloEl = $("div.hello")! as HTMLElement;
+ let counterButtonEl = $("counter-button") as HTMLElement;
+ let counterResultEl = $("counter-result") as HTMLElement;
+ let pingEl = $("backend-ping")! as HTMLElement;
- // counter button click
- counterButtonEl.addEventListener("pointerup", async function () {
- const result = await invoke("add_count", { num: 3 }) as string;
- counterResultEl.textContent = result;
- });
+ // listen backend-ping event (from Tauri Rust App)
+ listen("backend-ping", function (evt: TauriEvent<any>) {
+ pingEl.classList.add("on");
+ setTimeout(function () {
+ pingEl.classList.remove("on");
+ }, 500);
+ })
- // hello click
- helloEl.addEventListener("pointerup", async function () {
- const result = await invoke("hello_world") as string;
- helloEl.textContent = result;
- setTimeout(function () {
- helloEl.textContent = "Click again";
- }, 1000);
- });
+ // counter button click
+ counterButtonEl.addEventListener("pointerup", async function () {
+ const result = await invoke("add_count", { num: 1 }) as string;
+ counterResultEl.textContent = result;
+ });
-}); \ No newline at end of file
+ // hello click
+ helloEl.addEventListener("pointerup", async function () {
+ const result = await invoke("hello_world") as string;
+ helloEl.textContent = result;
+ setTimeout(function () {
+ helloEl.textContent = "Click again";
+ }, 1000);
+ })
+}) \ No newline at end of file