LukaVidakovic commited on
Commit
fd7b686
·
verified ·
1 Parent(s): 5c7751e

Update src/templates/index.html

Browse files
Files changed (1) hide show
  1. src/templates/index.html +63 -48
src/templates/index.html CHANGED
@@ -5,33 +5,29 @@
5
  <title>Епикриза</title>
6
  <link rel="stylesheet" href="/static/css/style.css"/>
7
  <style>
8
-
9
-
10
- .chatbot-iframe {
11
- position: fixed;
12
- bottom: 0px;
13
- right: 0px; /* Manje udaljeno od desnog ugla */
14
- width: 100px;
15
- height: 100px;
16
- border: none;
17
- transition-delay: 0.8s;
18
- z-index: 9999
19
- }
20
-
 
 
 
21
  .chatbot-iframe.open {
22
- width: 430px;
23
- height: 630px;
24
- transition-delay:0s
25
- }
26
-
27
- @media only screen and (max-width: 768px) {
28
- .chatbot-iframe.open {
29
- width: 100dvw;
30
- height: 100dvh;
31
- right: 0;
32
- bottom: 0;
33
- }
34
  }
 
35
  </style>
36
  </head>
37
  <body>
@@ -88,38 +84,57 @@
88
  <img src="/static/images/Logo.png" alt="Logo" class="logo-img-pb"/>
89
  </a>
90
  </div>
91
- <iframe
92
- src="https://d35cvlgrys9egv.cloudfront.net/"
93
- class="chatbot-iframe open"
94
- id="chatbot-iframe"
95
- frameborder="0"
96
- scrolling="no"></iframe>
 
97
  <script src="/static/js/record.js"></script>
98
  <script src="https://kit.fontawesome.com/e8304ae722.js" crossorigin="anonymous"></script>
99
  <script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
100
  <script>
101
- document.addEventListener('DOMContentLoaded', function() {
102
- const cb = document.querySelector('.chatbot-iframe');
103
  if (!cb) {
104
- console.error('Chatbot iframe nije pronađen.');
105
- return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
 
108
- cb.contentWindow.postMessage({
109
- screenWidth: window.innerWidth,
110
- screenHeight: window.innerHeight
111
- }, "*");
 
 
 
 
112
 
113
- // Dodavanje event listenera za poruku iz iframe-a
114
- window.addEventListener('message', (event) => {
115
- console.log(`Primljena poruka: ${event.data}`);
116
- if (event.data === 'closeChatbot') {
117
- cb.classList.remove('open');
118
- } else if (event.data === 'openChatbot') {
119
- cb.classList.add('open');
120
- }
121
  });
122
- });
123
  </script>
124
  </body>
125
  </html>
 
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;
12
+ width: 100px;
13
+ height: 100px;
14
+ border: none;
15
+ transition-delay: 0.8s;
16
+ z-index: 9999;
17
+ }
18
+ .chatbot-iframe.open {
19
+ width: 430px;
20
+ height: 630px;
21
+ transition-delay: 0s;
22
+ }
23
+ @media only screen and (max-width: 768px) {
24
  .chatbot-iframe.open {
25
+ width: 100dvw;
26
+ height: 100dvh;
27
+ left: 0;
28
+ bottom: 0;
 
 
 
 
 
 
 
 
29
  }
30
+ }
31
  </style>
32
  </head>
33
  <body>
 
84
  <img src="/static/images/Logo.png" alt="Logo" class="logo-img-pb"/>
85
  </a>
86
  </div>
87
+ <iframe
88
+ src="https://d1cg2ftwsk9g5q.cloudfront.net/"
89
+ class="chatbot-iframe open"
90
+ id="chatbot-iframe"
91
+ frameborder="0"
92
+ scrolling="no">
93
+ </iframe>
94
  <script src="/static/js/record.js"></script>
95
  <script src="https://kit.fontawesome.com/e8304ae722.js" crossorigin="anonymous"></script>
96
  <script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
97
  <script>
98
+ document.addEventListener("DOMContentLoaded", function () {
99
+ const cb = document.querySelector(".chatbot-iframe");
100
  if (!cb) {
101
+ console.error("Chatbot iframe not found.");
102
+ return;
103
+ }
104
+
105
+ // Detekcija jezika iz URL-a
106
+ const currentUrl = window.location.href;
107
+ let detectedLang = "sr"; // Podrazumevani jezik je 'sr'
108
+
109
+ if (currentUrl.includes("/en/")) {
110
+ detectedLang = "en";
111
+ } else if (currentUrl.includes("/zh-hans/")) {
112
+ detectedLang = "zh-hans";
113
+ } else if (currentUrl.includes("/de/")) {
114
+ detectedLang = "de";
115
+ } else if (currentUrl.includes("/ru/")) {
116
+ detectedLang = "ru";
117
+ } else if (currentUrl.includes("/sr/")) {
118
+ detectedLang = "sr";
119
  }
120
 
121
+ cb.contentWindow.postMessage(
122
+ {
123
+ screenWidth: window.innerWidth,
124
+ screenHeight: window.innerHeight,
125
+ },
126
+ "*"
127
+ );
128
+ console.log(window.innerWidth, window.innerHeight);
129
 
130
+ window.addEventListener("message", (event) => {
131
+ if (event.data === "closeChatbot") {
132
+ cb.classList.remove("open");
133
+ } else if (event.data === "openChatbot") {
134
+ cb.classList.add("open");
135
+ }
 
 
136
  });
137
+ });
138
  </script>
139
  </body>
140
  </html>