doctorbetaq commited on
Commit
ac08b84
1 Parent(s): 2c62b1a

Upload index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +351 -0
templates/index.html ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta name="viewport" content="width=device-width, initial-scale=1">
5
+ <title>ChatNBA</title>
6
+ <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
7
+ <style>
8
+ ::-webkit-scrollbar {
9
+ width: 10px;
10
+ }
11
+ /* 對於滾動條的滑塊 */
12
+ ::-webkit-scrollbar-thumb {
13
+ background: #e0e0e0;
14
+ border-radius: 20px; /* 橢圓的滑塊 */
15
+ }
16
+ /* 滾動條的滑塊滑過時的顏色 */
17
+ ::-webkit-scrollbar-thumb:hover {
18
+ background: #afafaf;
19
+ }
20
+ @keyframes dotPulse {
21
+ 0% { content: "." }
22
+ 33% { content: ".." }
23
+ 66% { content: "..." }
24
+ 100% { content: "...." }
25
+ }
26
+ .loading:after {
27
+ animation: dotPulse 1s infinite;
28
+ content: "";
29
+ }
30
+ .animate-fade-up {
31
+ animation: fadeInUp .5s both;
32
+ }
33
+ @keyframes fadeInUp {
34
+ from {
35
+ opacity: 0;
36
+ transform: translate3d(0, 100%, 0);
37
+ }
38
+ to {
39
+ opacity: 1;
40
+ transform: none;
41
+ }
42
+ }
43
+ body {
44
+ background-color: #ffffff;
45
+ color: rgb(28, 32, 59);
46
+ display: flex;
47
+ flex-direction: column;
48
+ align-items: center;
49
+ justify-content: center;
50
+ min-height: 100vh;
51
+ margin: 0;
52
+ padding: 0;
53
+ }
54
+ .container {
55
+ width: 100%; /* Adjust this for your preference */
56
+ max-width: 1000px;
57
+ }
58
+ #chat {
59
+ width: 100%;
60
+ height: 400px;
61
+ overflow: auto;
62
+ margin: auto;
63
+ position: relative;
64
+ }
65
+ #input {
66
+ width: 90%; /* Adjust this for your preference */
67
+ margin: 20px auto;
68
+ box-shadow: 0px 3px 15px rgba(0,0,0,0.2); /* shadow for input */
69
+ }
70
+ .chat-entry {
71
+ text-align: left;
72
+ padding: 10px;
73
+ border-radius: 15px;
74
+ }
75
+ .chat-entry img {
76
+ height: 50px;
77
+ width: 50px;
78
+ object-fit: cover;
79
+ }
80
+ .btn-secondary {
81
+ height: 40px;
82
+ }
83
+ .chat-entry-user {
84
+ background-color: #fafeff;
85
+ }
86
+ .chat-entry-bot {
87
+ background-color: #f8f7ff;
88
+ }
89
+ .chat-entry-user, .chat-entry-bot {
90
+ display: flex;
91
+ flex-direction: row;
92
+ align-items: stretch;
93
+ margin-bottom: 10px;
94
+ }
95
+ .chat-entry-user > div, .chat-entry-bot > div {
96
+ margin-left: 10px;
97
+ word-break: break-word;
98
+ }
99
+ h1 {
100
+ text-align: center;
101
+ }
102
+ p {
103
+ text-align: center;
104
+ }
105
+ h6 {
106
+ color: #bbbbbb
107
+ }
108
+ h4{
109
+ color:#555555
110
+ }
111
+ #intro-message {
112
+ position: absolute;
113
+ top: 50%;
114
+ left: 50%;
115
+ transform: translate(-50%, -50%);
116
+ text-align: center;
117
+ }
118
+ .loading {
119
+ color: #aaaaaa;
120
+ }
121
+ .loading div:after {
122
+ content: ' .';
123
+ animation: dots 1s steps(5, end) infinite;
124
+ }
125
+ @keyframes dots {
126
+ 0%, 20% {
127
+ color: rgba(0,0,0,0);
128
+ text-shadow:
129
+ .25em 0 0 rgba(0,0,0,0),
130
+ .5em 0 0 rgba(0,0,0,0);}
131
+ 40% {
132
+ color: white;
133
+ text-shadow:
134
+ .25em 0 0 rgba(0,0,0,0),
135
+ .5em 0 0 rgba(0,0,0,0);}
136
+ 60% {
137
+ text-shadow:
138
+ .25em 0 0 white,
139
+ .5em 0 0 rgba(0,0,0,0);}
140
+ 100% {
141
+ text-shadow:
142
+ .25em 0 0 white,
143
+ .5em 0 0 white;}}
144
+ @media (max-width: 600px) {
145
+ #chat {
146
+ height: 350px;
147
+ }
148
+ }
149
+ .switch {
150
+ position: relative;
151
+ display: inline-block;
152
+ width: 40px;
153
+ height: 20px;
154
+ }
155
+ .switch input {
156
+ opacity: 0;
157
+ width: 0;
158
+ height: 0;
159
+ }
160
+ .slider {
161
+ position: absolute;
162
+ cursor: pointer;
163
+ top: 0;
164
+ left: 0;
165
+ right: 0;
166
+ bottom: 0;
167
+ background-color: #ccc;
168
+ transition: .4s;
169
+ }
170
+ .slider:before {
171
+ position: absolute;
172
+ content: "";
173
+ height: 16px;
174
+ width: 16px;
175
+ left: 2px;
176
+ bottom: 2px;
177
+ background-color: white;
178
+ transition: .4s;
179
+ }
180
+ input:checked + .slider {
181
+ background-color: #b4f0eb;
182
+ }
183
+ input:focus + .slider {
184
+ box-shadow: 0 0 1px #b4f0eb;
185
+ }
186
+ input:checked + .slider:before {
187
+ transform: translateX(20px);
188
+ }
189
+ .slider.round {
190
+ border-radius: 34px;
191
+ }
192
+ .slider.round:before {
193
+ border-radius: 50%;
194
+ }
195
+ </style>
196
+ <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> <!-- 引入完整的jQuery版本 -->
197
+ <script>
198
+ function submit() {
199
+ var input = document.getElementById('input').value;
200
+ document.getElementById('input').value = '';
201
+ document.getElementById('intro-message').style.display = 'none';
202
+ var chat = document.getElementById('chat');
203
+ var userEntry = document.createElement('div');
204
+ userEntry.className = "chat-entry chat-entry-user animate-fade-up";;
205
+
206
+ var userImg = document.createElement('img');
207
+ userImg.src = "/static/icon/U.png";
208
+
209
+ var userInput = document.createElement('div');
210
+ userInput.textContent = input;
211
+
212
+ userEntry.appendChild(userImg);
213
+ userEntry.appendChild(userInput);
214
+ chat.appendChild(userEntry);
215
+ chat.scrollTop = chat.scrollHeight;
216
+
217
+ // 創建bot回應的元素並添加到chat
218
+ var botEntry = document.createElement('div');
219
+ botEntry.className = "chat-entry chat-entry-bot loading";
220
+ var botImg = document.createElement('img');
221
+ botImg.src = "/static/icon/N.png";
222
+ var botResponse = document.createElement('div');
223
+ botResponse.textContent = "學長姐們努力查資料中";
224
+
225
+ botEntry.appendChild(botImg);
226
+ botEntry.appendChild(botResponse);
227
+ chat.appendChild(botEntry);
228
+
229
+ // 設定不同的訊息並每10秒輪換
230
+ var messages = ["學長姐們正在用力查資料,請稍等片刻", "別逼我們啊~~我們快好了~~~QQQQQ","先別說這個了,你聽過楊老師嗎","NBA不是美國的NBA唷~這是奈米生醫材料應用實驗室的英文縮寫唷!"];
231
+ var index = 0;
232
+ function updateMessage() {
233
+ botResponse.textContent = messages[index];
234
+ index = (index + 1) % messages.length; // 更新索引,如果超過陣列長度,就重置為0
235
+ }
236
+
237
+ // 每10秒更新一次訊息
238
+ var timer = setInterval(updateMessage, 10000);
239
+
240
+ //新的呼叫方法(包含翻譯)
241
+ $.ajax({
242
+ url: '/get_response',
243
+ type: 'POST',
244
+ contentType: 'application/json',
245
+ data: JSON.stringify({
246
+ user_input: input,
247
+ should_translate: $('#translationCheck').prop('checked'),
248
+ target_lang: 'zh-tw'
249
+ }),
250
+ success: function(response) {
251
+ clearTimeout(timer); // 收到回應後,取消定時器
252
+ botResponse.textContent = response.response;
253
+ botEntry.classList.remove('loading');
254
+ chat.scrollTop = chat.scrollHeight;
255
+ }
256
+ });
257
+ // // 呼叫後端取得回應
258
+ // fetch('/get_response', {
259
+ // method: 'POST',
260
+ // headers: {
261
+ // 'Content-Type': 'application/json',
262
+ // },
263
+ // body: JSON.stringify({ user_input: input }),
264
+ // })
265
+ // .then(response => response.json())
266
+ // .then(data => {
267
+ // clearTimeout(timer); // 收到回應後,取消定時器
268
+ // botResponse.textContent = data.response;
269
+ // botEntry.classList.remove('loading');
270
+ // chat.scrollTop = chat.scrollHeight;
271
+ // });
272
+ }
273
+ </script>
274
+
275
+ <!-- <script>
276
+ function submit() {
277
+ var input = document.getElementById('input').value;
278
+ document.getElementById('input').value = '';
279
+ var chat = document.getElementById('chat');
280
+ var userEntry = document.createElement('div');
281
+ userEntry.className = "chat-entry chat-entry-user animate-fade-up";
282
+ var userImg = document.createElement('img');
283
+ userImg.src = "/static/icon/U.png";
284
+ var userInput = document.createElement('div');
285
+ userInput.textContent = input;
286
+ userEntry.appendChild(userImg);
287
+ userEntry.appendChild(userInput);
288
+ chat.appendChild(userEntry);
289
+ setTimeout(function() {
290
+ var botImg = document.createElement('img');
291
+ botImg.src = "/static/icon/N.png";
292
+ var botEntry = document.createElement('div');
293
+ botEntry.className = "chat-entry chat-entry-bot loading";
294
+ var botResponse = document.createElement('div');
295
+ botResponse.textContent = "學長姐們努力查資料中";
296
+ botEntry.appendChild(botImg);
297
+ botEntry.appendChild(botResponse);
298
+ chat.appendChild(botEntry);
299
+ chat.scrollTop = chat.scrollHeight;
300
+ fetch('/get_response', {
301
+ method: 'POST',
302
+ headers: {
303
+ 'Content-Type': 'application/json',
304
+ },
305
+ body: JSON.stringify({ user_input: input }),
306
+ })
307
+ .then(response => response.json())
308
+ .then(data => {
309
+ botResponse.textContent = data.response;
310
+ botEntry.classList.remove('loading');
311
+ chat.scrollTop = chat.scrollHeight;
312
+ });
313
+ }, 500); // 延遲500毫秒後再顯示 loading
314
+ }
315
+ </script> -->
316
+ </head>
317
+ <body>
318
+ <div class="container">
319
+ <div class="row justify-content-center"> <!-- Added a row with centered content -->
320
+ <div class="col-lg-10 col-md-12 col-14"> <!--Adjusted column sizes for different screen sizes-->
321
+
322
+ <div class="container">
323
+ <h1>ChatNBA</h1>
324
+ <h4><p>
325
+ </p></h4>
326
+ <div id="chat">
327
+ <div id="intro-message">Wellcome to the ChatNBA! <br> Please enter your question below.👇<br> Then chat with your seniors 👨‍🎓👩‍🎓(and their thesis📖)! <br> Have fun!🚀<br>English question only, hahahahha~🖖<br><br>
328
+ ❔What you can ask:<br>
329
+
330
+ 🧫cell culture<br>
331
+ 🧬DNAs/RNAs/Proteins<br>
332
+ 🧪Experiments<br>
333
+ 🔬sensors<br><br>
334
+
335
+
336
+ </div>
337
+ </div>
338
+ <div class="input-group">
339
+ <input id="input" type="text" class="form-control" placeholder="Send a question." onkeydown="if(event.key==='Enter')submit()">
340
+ </div>
341
+ <!-- <label class="switch">
342
+ <input type="checkbox" id="translationCheck">
343
+ <span class="slider round"></span>
344
+ </label> Translate to Chinese, please~ -->
345
+ </div>
346
+ <h6><p>The ChatNBA model is still in training (like you) and may generate wrong response to your question. <br> ©Copyright 2023 Lab of Nano-Biomaterials Applications. All rights reserved. <br>ChatNBA(preview) ver. 0.0.1 <br> Designed by Hao-Han Pang, PhD</p></h6>
347
+ </div>
348
+ </div>
349
+ </div>
350
+ </body>
351
+ </html>