Prav51 commited on
Commit
b473ef5
·
verified ·
1 Parent(s): 4e5ea86

Changed token word in events

Browse files
Files changed (1) hide show
  1. _events.js +58 -58
_events.js CHANGED
@@ -1,58 +1,58 @@
1
- document.addEventListener("DOMContentLoaded", () => {
2
- // Instantiate Hint for API token
3
- const apiTokenHint = new Hint("hint-icon", "hint-content");
4
-
5
- // Instantiate Hint for Model Info
6
- const modelInfoHint = new Hint("model-hint-icon", "model-hint-content");
7
-
8
- chooseModel.addEventListener("change", updateModelInfo);
9
-
10
- togglePassword.addEventListener("click", () => {
11
- const type =
12
- token.getAttribute("type") === "password" ? "text" : "password";
13
- token.setAttribute("type", type);
14
-
15
- togglePassword.querySelector("i").classList.toggle("fa-eye-slash");
16
- togglePassword.querySelector("i").classList.toggle("fa-eye");
17
- });
18
-
19
- btn.addEventListener("click", async () => {
20
- //form validations
21
- if (text.value.trim() === "") {
22
- notificationInstance.show("error", "Please enter some text.");
23
- return;
24
- }
25
-
26
- if (token.value.trim() === "") {
27
- notificationInstance.show("error", "Please enter your API token.");
28
-
29
- return;
30
- }
31
-
32
- loader.classList.remove("hidden");
33
- img.src = ""; // Clear the current image
34
- downloadBtn.classList.add("hidden");
35
-
36
- try {
37
- const response = await query(chooseModel.value, token.value);
38
- const objectUrl = URL.createObjectURL(response);
39
- img.src = objectUrl;
40
- downloadBtn.classList.remove("hidden");
41
- imageHistoryInstance.addToHistory(objectUrl);
42
- } catch (error) {
43
- notificationInstance.show(
44
- "error",
45
- "Sorry, the model is currently unavailable. Please try again later."
46
- );
47
- } finally {
48
- loader.classList.add("hidden");
49
- }
50
- });
51
-
52
- downloadBtn.addEventListener("click", () => {
53
- const link = document.createElement("a");
54
- link.href = img.src;
55
- link.download = "generated_image.png";
56
- link.click();
57
- });
58
- }); //END OF EVENT LISTENER
 
1
+ document.addEventListener("DOMContentLoaded", () => {
2
+ // Instantiate Hint for API
3
+ const apiKyHint = new Hint("hint-icon", "hint-content");
4
+
5
+ // Instantiate Hint for Model Info
6
+ const modelInfoHint = new Hint("model-hint-icon", "model-hint-content");
7
+
8
+ chooseModel.addEventListener("change", updateModelInfo);
9
+
10
+ togglePassword.addEventListener("click", () => {
11
+ const type =
12
+ yourKy.getAttribute("type") === "password" ? "text" : "password";
13
+ yourKy.setAttribute("type", type);
14
+
15
+ togglePassword.querySelector("i").classList.toggle("fa-eye-slash");
16
+ togglePassword.querySelector("i").classList.toggle("fa-eye");
17
+ });
18
+
19
+ btn.addEventListener("click", async () => {
20
+ //form validations
21
+ if (text.value.trim() === "") {
22
+ notificationInstance.show("error", "Please enter some text.");
23
+ return;
24
+ }
25
+
26
+ if (yourKy.value.trim() === "") {
27
+ notificationInstance.show("error", "Please enter your API yourKy.");
28
+
29
+ return;
30
+ }
31
+
32
+ loader.classList.remove("hidden");
33
+ img.src = ""; // Clear the current image
34
+ downloadBtn.classList.add("hidden");
35
+
36
+ try {
37
+ const response = await query(chooseModel.value, token.value);
38
+ const objectUrl = URL.createObjectURL(response);
39
+ img.src = objectUrl;
40
+ downloadBtn.classList.remove("hidden");
41
+ imageHistoryInstance.addToHistory(objectUrl);
42
+ } catch (error) {
43
+ notificationInstance.show(
44
+ "error",
45
+ "Sorry, the model is currently unavailable. Please try again later."
46
+ );
47
+ } finally {
48
+ loader.classList.add("hidden");
49
+ }
50
+ });
51
+
52
+ downloadBtn.addEventListener("click", () => {
53
+ const link = document.createElement("a");
54
+ link.href = img.src;
55
+ link.download = "generated_image.png";
56
+ link.click();
57
+ });
58
+ }); //END OF EVENT LISTENER