LukaVidakovic commited on
Commit
9b0537c
·
verified ·
1 Parent(s): 99c6093

Update src/templates/index.html

Browse files
Files changed (1) hide show
  1. src/templates/index.html +27 -31
src/templates/index.html CHANGED
@@ -5,7 +5,7 @@
5
  <title>Епикриза</title>
6
  <link rel="stylesheet" href="/static/css/style.css"/>
7
  <style>
8
- .chatbot-iframe {
9
  position: fixed;
10
  bottom: 0px;
11
  left: 0px;
@@ -14,8 +14,22 @@
14
  z-index: 9999;
15
  }
16
  .chatbot-iframe.open {
 
 
17
  transition-delay: 0s;
18
  }
 
 
 
 
 
 
 
 
 
 
 
 
19
  </style>
20
  </head>
21
  <body>
@@ -72,9 +86,9 @@
72
  <img src="/static/images/Logo.png" alt="Logo" class="logo-img-pb"/>
73
  </a>
74
  </div>
75
- <iframe
76
  src="https://d1cg2ftwsk9g5q.cloudfront.net"
77
- class="chatbot-iframe"
78
  id="chatbot-iframe"
79
  frameborder="0"
80
  scrolling="no">
@@ -88,11 +102,6 @@
88
  console.error("Chatbot iframe not found.");
89
  return;
90
  }
91
-
92
- // Postavi početne dimenzije
93
- cb.style.width = "80px";
94
- cb.style.height = "80px";
95
-
96
  // Detekcija jezika iz URL-a
97
  const currentUrl = window.location.href;
98
  let detectedLang = "sr";
@@ -110,29 +119,6 @@
110
  const chatbotUrl = `${cb.src}?lang=${detectedLang}`;
111
  cb.src = chatbotUrl;
112
 
113
- // Podesi dimenzije prilikom otvaranja i zatvaranja
114
- window.addEventListener("message", (event) => {
115
- if (event.data === "closeChatbot") {
116
- cb.classList.remove("open");
117
- cb.style.width = "80px";
118
- cb.style.height = "80px";
119
- } else if (event.data === "openChatbot") {
120
- cb.classList.add("open");
121
- if (window.innerWidth <= 768) {
122
- // Podesi za manje ekrane
123
- cb.style.width = "100dvw";
124
- cb.style.height = "100dvh";
125
- cb.style.left = "0";
126
- cb.style.bottom = "0";
127
- } else {
128
- // Podesi za veće ekrane
129
- cb.style.width = "430px";
130
- cb.style.height = "630px";
131
- }
132
- }
133
- });
134
-
135
- // Pošalji veličinu ekrana iframe-u
136
  setTimeout(() => {
137
  cb.contentWindow.postMessage(
138
  {
@@ -142,6 +128,16 @@
142
  "*"
143
  );
144
  }, 250);
 
 
 
 
 
 
 
 
 
 
145
  });
146
  </script>
147
  </body>
 
5
  <title>Епикриза</title>
6
  <link rel="stylesheet" href="/static/css/style.css"/>
7
  <style>
8
+ .chatbot-iframe {
9
  position: fixed;
10
  bottom: 0px;
11
  left: 0px;
 
14
  z-index: 9999;
15
  }
16
  .chatbot-iframe.open {
17
+ width: 430px;
18
+ height: 630px;
19
  transition-delay: 0s;
20
  }
21
+ .chatbot-iframe.close {
22
+ width: 100px;
23
+ height: 100px;
24
+ }
25
+ @media only screen and (max-width: 768px) {
26
+ .chatbot-iframe.open {
27
+ width: 100dvw;
28
+ height: 100dvh;
29
+ left: 0;
30
+ bottom: 0;
31
+ }
32
+ }
33
  </style>
34
  </head>
35
  <body>
 
86
  <img src="/static/images/Logo.png" alt="Logo" class="logo-img-pb"/>
87
  </a>
88
  </div>
89
+ <iframe
90
  src="https://d1cg2ftwsk9g5q.cloudfront.net"
91
+ class="chatbot-iframe close"
92
  id="chatbot-iframe"
93
  frameborder="0"
94
  scrolling="no">
 
102
  console.error("Chatbot iframe not found.");
103
  return;
104
  }
 
 
 
 
 
105
  // Detekcija jezika iz URL-a
106
  const currentUrl = window.location.href;
107
  let detectedLang = "sr";
 
119
  const chatbotUrl = `${cb.src}?lang=${detectedLang}`;
120
  cb.src = chatbotUrl;
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  setTimeout(() => {
123
  cb.contentWindow.postMessage(
124
  {
 
128
  "*"
129
  );
130
  }, 250);
131
+
132
+ window.addEventListener("message", (event) => {
133
+ if (event.data === "closeChatbot") {
134
+ cb.classList.remove("open");
135
+ cb.classList.add("close");
136
+ } else if (event.data === "openChatbot") {
137
+ cb.classList.remove("close");
138
+ cb.classList.add("open");
139
+ }
140
+ });
141
  });
142
  </script>
143
  </body>