summaryrefslogtreecommitdiff
path: root/pred_gui/frontend/src/main.ts
diff options
context:
space:
mode:
authorPhysick <96335032+DegustatorPonos@users.noreply.github.com>2025-11-29 20:18:11 +0500
committerPhysick <96335032+DegustatorPonos@users.noreply.github.com>2025-11-29 20:18:11 +0500
commite07dca81d05f304865a59c8afee98a3cde8bce8c (patch)
tree2dd01bbc5fd20b6ae024f0c18eb8946887ae9339 /pred_gui/frontend/src/main.ts
Project init
Diffstat (limited to 'pred_gui/frontend/src/main.ts')
-rw-r--r--pred_gui/frontend/src/main.ts49
1 files changed, 49 insertions, 0 deletions
diff --git a/pred_gui/frontend/src/main.ts b/pred_gui/frontend/src/main.ts
new file mode 100644
index 0000000..b68d7d9
--- /dev/null
+++ b/pred_gui/frontend/src/main.ts
@@ -0,0 +1,49 @@
+import './style.css';
+import './app.css';
+
+import logo from './assets/images/logo-universal.png';
+import {Greet} from '../wailsjs/go/main/App';
+
+// Setup the greet function
+window.greet = function () {
+ // Get name
+ let name = nameElement!.value;
+
+ // Check if the input is empty
+ if (name === "") return;
+
+ // Call App.Greet(name)
+ try {
+ Greet(name)
+ .then((result) => {
+ // Update result with data back from App.Greet()
+ resultElement!.innerText = result;
+ })
+ .catch((err) => {
+ console.error(err);
+ });
+ } catch (err) {
+ console.error(err);
+ }
+};
+
+document.querySelector('#app')!.innerHTML = `
+ <img id="logo" class="logo">
+ <div class="result" id="result">Please enter your name below 👇</div>
+ <div class="input-box" id="input">
+ <input class="input" id="name" type="text" autocomplete="off" />
+ <button class="btn" onclick="greet()">Greet</button>
+ </div>
+ </div>
+`;
+(document.getElementById('logo') as HTMLImageElement).src = logo;
+
+let nameElement = (document.getElementById("name") as HTMLInputElement);
+nameElement.focus();
+let resultElement = document.getElementById("result");
+
+declare global {
+ interface Window {
+ greet: () => void;
+ }
+}