HarshSanghavi commited on
Commit
71c288d
·
verified ·
1 Parent(s): a26cd26

Update templates/chatwidget.html

Browse files
Files changed (1) hide show
  1. templates/chatwidget.html +871 -892
templates/chatwidget.html CHANGED
@@ -1,892 +1,871 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Document</title>
7
- </head>
8
-
9
- <body>
10
- <div id="body">
11
- <style>
12
- body {
13
- /* Add the background image */
14
- background-image: url("mu-logo-mood-03.jpg");
15
- /* Adjust background properties */
16
- background-repeat: no-repeat;
17
- background-size: cover; /* or contain, depending on your preference */
18
- /* Add other background properties if needed */
19
- }
20
- .cm-msg-text {
21
- overflow-wrap: break-word;
22
- /* Break long words */
23
- word-wrap: break-word;
24
- /* Break long words */
25
- word-break: break-word;
26
- /* Break words */
27
- max-width: 100%;
28
- /* Limit maximum width */
29
- }
30
-
31
- [data-block="list11-v4-1-1-b2"] .sw-border-bottom-color-000000 {
32
- border-bottom-color: #000000 !important;
33
- }
34
-
35
- [data-block="list11-v4-1-1-b2"] .sw-border-bottom-width-none {
36
- border-bottom-width: 0px !important;
37
- }
38
-
39
- [data-block="list11-v4-1-1-b2"] .sw-border-bottom-style-none {
40
- border-bottom-style: none !important;
41
- }
42
-
43
- [data-block="list11-v4-1-1-b2"] .sw-border-top-color-000000 {
44
- border-top-color: #000000 !important;
45
- }
46
-
47
- [data-block="list11-v4-1-1-b2"] .sw-border-top-width-none {
48
- border-top-width: 0px !important;
49
- }
50
-
51
- [data-block="list11-v4-1-1-b2"] .sw-border-top-style-none {
52
- border-top-style: none !important;
53
- }
54
-
55
- [data-block="list11-v4-1-1-b2"] .sw-padding-bottom-m {
56
- padding-bottom: 3rem !important;
57
- }
58
-
59
- [data-block="list11-v4-1-1-b2"] .sw-padding-top-m {
60
- padding-top: 3rem !important;
61
- }
62
-
63
- [data-block="list11-v4-1-1-b2"] .sw-background-color-ffffff {
64
- background-color: #ffffff !important;
65
- }
66
-
67
- #body {
68
- z-index: 1999;
69
- position: fixed;
70
- margin: 0;
71
- padding: 0;
72
- font-family: "Lato", sans-serif;
73
- background-color: #f6f7f9;
74
- }
75
-
76
- @mixin chabox-container {
77
- display: flex;
78
- position: absolute;
79
- box-shadow: 5px 5px 25px 0 rgba(46, 61, 73, 0.2);
80
- flex-direction: column;
81
- }
82
-
83
- @mixin chatbox-header {
84
- box-sizing: border-box;
85
- display: flex;
86
- width: 100%;
87
- padding: 16px;
88
- color: #fff;
89
- background-color: #0360a5;
90
- align-items: center;
91
- justify-content: space-around;
92
- }
93
-
94
- @mixin chatbox-main {
95
- box-sizing: border-box;
96
- width: 100%;
97
- padding: calc(2 * 16px) 16px;
98
- line-height: calc(16px + 16px / 2);
99
- color: #888;
100
- text-align: center;
101
- }
102
-
103
- @mixin chatbox-footer {
104
- box-sizing: border-box;
105
- display: flex;
106
- width: 100%;
107
- padding: 16px;
108
- border-top: 1px solid #ddd;
109
- align-items: center;
110
- justify-content: space-around;
111
- }
112
-
113
- @mixin chatbox-floating-button {
114
- position: fixed;
115
- bottom: 0;
116
- right: 0;
117
- width: 52px;
118
- height: 52px;
119
- color: #fff;
120
- background-color: #0360a5;
121
- background-position: center center;
122
- background-repeat: no-repeat;
123
- box-shadow: 12px 15px 20px 0 rgba(46, 61, 73, 0.15);
124
- border: 0;
125
- border-radius: 50%;
126
- cursor: pointer;
127
- }
128
-
129
- h1 {
130
- margin: 0;
131
- font-size: 16px;
132
- line-height: 1;
133
- }
134
-
135
- button {
136
- color: inherit;
137
- background-color: transparent;
138
- border: 0;
139
- outline: 0 !important;
140
- cursor: pointer;
141
- }
142
-
143
- #center-text {
144
- display: flex;
145
- flex: 1;
146
- flex-direction: column;
147
- justify-content: center;
148
- align-items: center;
149
- height: 100%;
150
- }
151
-
152
- #chat-circle {
153
- position: fixed;
154
- bottom: 50px;
155
- z-index: 1999;
156
- align-items: center;
157
- right: 50px;
158
- background: #000;
159
- width: 60px;
160
- justify-content: center;
161
- height: 60px;
162
- display: flex;
163
- border-radius: 50%;
164
- color: white;
165
- padding: 8px;
166
- cursor: pointer;
167
- box-shadow: 0px 3px 16px 0px rgba(0, 0, 0, 0.4),
168
- 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
169
- }
170
-
171
- .btn#my-btn {
172
- background: white;
173
- padding-top: 13px;
174
- padding-bottom: 12px;
175
- border-radius: 45px;
176
- padding-right: 40px;
177
- padding-left: 40px;
178
- color: #5865c3;
179
- }
180
-
181
- #chat-overlay {
182
- background: rgba(255, 255, 255, 0.1);
183
- position: absolute;
184
- top: 0;
185
- left: 0;
186
- width: 100%;
187
- height: 100%;
188
- border-radius: 50%;
189
- display: none;
190
- }
191
-
192
- .chat-box {
193
- display: none;
194
- background: #efefef;
195
- position: fixed;
196
- right: 30px;
197
- z-index: 1999;
198
- bottom: 50px;
199
- width: 470px;
200
- max-width: 85vw;
201
- max-height: 100vh;
202
- border-radius: 5px;
203
- /* box-shadow: 0px 5px 35px 9px #464a92; */
204
- box-shadow: 0px 5px 35px 9px #ccc;
205
- }
206
-
207
- .chat-box-toggle {
208
- float: right;
209
- margin-right: 15px;
210
- cursor: pointer;
211
- }
212
-
213
- .chat-box-header {
214
- background: #000;
215
- height: 70px;
216
- border-top-left-radius: 5px;
217
- border-top-right-radius: 5px;
218
- color: white;
219
- text-align: center;
220
- font-size: 20px;
221
- padding-top: 17px;
222
- padding-left: 36px;
223
- }
224
-
225
- .chat-box-body {
226
- position: relative;
227
- height: 370px;
228
- height: auto;
229
- border: 1px solid #ccc;
230
- overflow: hidden;
231
- }
232
-
233
- .chat-box-body:after {
234
- content: "";
235
- background: #fff;
236
- opacity: 0.1;
237
- top: 0;
238
- left: 0;
239
- bottom: 0;
240
- right: 0;
241
- height: 100%;
242
- position: absolute;
243
- z-index: -1;
244
- }
245
-
246
- #chat_input {
247
- background: #f4f7f9;
248
- width: 100%;
249
- position: relative;
250
- height: 47px;
251
- padding-top: 10px;
252
- padding-right: 50px;
253
- padding-bottom: 10px;
254
- padding-left: 15px;
255
- border: none;
256
- resize: none;
257
- outline: none;
258
- border: 1px solid #ccc;
259
- color: #888;
260
- border-top: none;
261
- border-bottom-right-radius: 5px;
262
- border-bottom-left-radius: 5px;
263
- overflow: hidden;
264
- }
265
-
266
- .chat_input > form {
267
- margin-bottom: 0;
268
- }
269
-
270
- #chat_input::-webkit-input-placeholder {
271
- /* Chrome/Opera/Safari */
272
- color: #ccc;
273
- }
274
-
275
- #chat_input::-moz-placeholder {
276
- /* Firefox 19+ */
277
- color: #ccc;
278
- }
279
-
280
- #chat_input:-ms-input-placeholder {
281
- /* IE 10+ */
282
- color: #ccc;
283
- }
284
-
285
- #chat_input:-moz-placeholder {
286
- /* Firefox 18- */
287
- color: #ccc;
288
- }
289
-
290
- .chat-submit {
291
- position: absolute;
292
- bottom: 3px;
293
- right: 10px;
294
- background: transparent;
295
- box-shadow: none;
296
- border: none;
297
- border-radius: 50%;
298
- color: #000;
299
- width: 35px;
300
- height: 35px;
301
- }
302
-
303
- .chat_logs {
304
- padding: 15px;
305
- height: 370px;
306
- overflow-y: scroll;
307
- margin-bottom: 48px;
308
- }
309
-
310
- .chat_logs::-webkit-scrollbar-track {
311
- -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
312
- background-color: #f5f5f5;
313
- }
314
-
315
- .chat_logs::-webkit-scrollbar {
316
- width: 5px;
317
- background-color: #f5f5f5;
318
- }
319
-
320
- .chat_logs::-webkit-scrollbar-thumb {
321
- background-color: #000;
322
- }
323
-
324
- @media only screen and (max-width: 500px) {
325
- .chat_logs {
326
- height: 40vh;
327
- }
328
- }
329
-
330
- .chat-msg.user > .msg-avatar img {
331
- width: 45px;
332
- height: 45px;
333
- border-radius: 50%;
334
- float: left;
335
- width: 15%;
336
- }
337
-
338
- .chat-msg.self > .msg-avatar img {
339
- width: 45px;
340
- height: 45px;
341
- border-radius: 50%;
342
- float: right;
343
- width: 15%;
344
- }
345
-
346
- .cm-msg-text {
347
- z-index: 1999;
348
- background: white;
349
- padding: 10px 15px 10px 15px;
350
- color: #666;
351
- max-width: 75%;
352
- float: left;
353
- margin-left: 10px;
354
- position: relative;
355
- margin-bottom: 20px;
356
- border-radius: 30px;
357
- border-bottom-left-radius: 0px;
358
- }
359
-
360
- .svg-bot {
361
- height: 24px;
362
- width: 24px;
363
- }
364
-
365
- .chat-msg {
366
- clear: both;
367
- z-index: 1999;
368
- }
369
-
370
- .chat-msg.self > .cm-msg-text {
371
- float: right;
372
- margin-right: 10px;
373
- border-radius: 30px;
374
- border-bottom-right-radius: 0px;
375
- background: #000;
376
- color: white;
377
- }
378
-
379
- .cm-msg-button > ul > li {
380
- list-style: none;
381
- float: left;
382
- width: 50%;
383
- }
384
-
385
- .cm-msg-button {
386
- clear: both;
387
- margin-bottom: 70px;
388
- }
389
-
390
- .chat-btn {
391
- z-index: 1999;
392
- }
393
-
394
- .cancel {
395
- display: none;
396
- border: none;
397
- border-radius: 5px;
398
- background-color: #d6d6d6;
399
- color: black;
400
- z-index: 1999;
401
- bottom: 3px;
402
- position: absolute;
403
- padding: 5px 5px;
404
- margin: 0 172px;
405
- }
406
-
407
- [data-block^="list11-v4-1-1"] .vertical-list-item {
408
- height: 100%;
409
- overflow: hidden;
410
- }
411
-
412
- [data-block^="list11-v4-1-1"] .additional-elements-wrapper {
413
- width: 100%;
414
- }
415
-
416
- [data-block^="list11-v4-1-1"] .label-wrapper.vertical {
417
- flex-direction: column;
418
- }
419
-
420
- [data-block^="list11-v4-1-1"] .label-wrapper {
421
- display: flex;
422
- }
423
-
424
- p,
425
- h1,
426
- h2,
427
- h3,
428
- h4,
429
- h5,
430
- small {
431
- white-space: pre-line;
432
- }
433
-
434
- h1,
435
- h2,
436
- h3,
437
- h4,
438
- h5,
439
- h6,
440
- .h1,
441
- .h2,
442
- .h3,
443
- .h4,
444
- .h5,
445
- .h6 {
446
- margin-bottom: 0.25rem;
447
- font-family: inherit;
448
- font-weight: 400;
449
- line-height: 1.1;
450
- color: inherit;
451
- }
452
-
453
- [data-block^="list11-v4-1-1"] .list-container dl,
454
- [data-block^="list11-v4-1-1"] .list-container h1,
455
- [data-block^="list11-v4-1-1"] .list-container h2,
456
- [data-block^="list11-v4-1-1"] .list-container h3,
457
- [data-block^="list11-v4-1-1"] .list-container h4,
458
- [data-block^="list11-v4-1-1"] .list-container h5,
459
- [data-block^="list11-v4-1-1"] .list-container h6,
460
- [data-block^="list11-v4-1-1"] .list-container ol,
461
- [data-block^="list11-v4-1-1"] .list-container p,
462
- [data-block^="list11-v4-1-1"] .list-container ul {
463
- margin: 0;
464
- padding: 0;
465
- }
466
-
467
- [data-block="list11-v4-1-1-b2"] .sw-text-align-center {
468
- text-align: center !important;
469
- }
470
-
471
- [data-block="list11-v4-1-1-b2"] .sw-margin-top-none {
472
- margin-top: 0rem !important;
473
- }
474
-
475
- [data-block="list11-v4-1-1-b2"] .sw-margin-bottom-none {
476
- margin-bottom: 0rem !important;
477
- }
478
-
479
- [data-block="list11-v4-1-1-b2"] .sw-font-size-2xl {
480
- font-size: 1.5rem !important;
481
- }
482
-
483
- [data-block="list11-v4-1-1-b2"] .sw-padding-bottom-5xs {
484
- padding-bottom: 0.75rem !important;
485
- }
486
-
487
- [data-block="list11-v4-1-1-b2"] .sw-padding-top-none {
488
- padding-top: 0rem !important;
489
- }
490
-
491
- [data-block="list11-v4-1-1-b2"] .sw-letter-spacing-normal {
492
- letter-spacing: 0rem !important;
493
- }
494
-
495
- [data-block="list11-v4-1-1-b2"] .sw-text-color-0A0A0A {
496
- color: #0a0a0a !important;
497
- }
498
-
499
- [data-block="list11-v4-1-1-b2"] .sw-padding-right-none {
500
- padding-right: 0rem !important;
501
- }
502
-
503
- [data-block="list11-v4-1-1-b2"] .sw-padding-left-none {
504
- padding-left: 0rem !important;
505
- }
506
-
507
- [data-block="list11-v4-1-1-b2"] .sw-font-weight-semibold {
508
- font-weight: 600 !important;
509
- }
510
-
511
- h1.sw-text-color-default,
512
- h2.sw-text-color-default,
513
- h3.sw-font-family-default {
514
- color: #000000;
515
- }
516
-
517
- h1.sw-font-weight-default,
518
- h2.sw-font-weight-default,
519
- h3.sw-font-family-default {
520
- font-weight: 600;
521
- }
522
-
523
- h1.sw-font-family-default,
524
- h2.sw-font-family-default,
525
- h3.sw-font-family-default {
526
- font-family: "IBM Plex Sans";
527
- }
528
-
529
- /* .bg-img {
530
- background-image: url("./MU_LOGO_BLACK.jpg");
531
- background-repeat: no-repeat;
532
- position: relative;
533
- background-position: center;
534
- background-size: cover;
535
- } */
536
-
537
- .marwadi {
538
- width: 100vw;
539
- height: 100vh;
540
- text-align: center;
541
- margin: auto;
542
- font-size: xx-large;
543
- font-weight: bolder;
544
- display: flex;
545
- flex-direction: column;
546
- justify-content: center;
547
- align-items: center;
548
- }
549
-
550
- .bestie {
551
- margin: 1rem;
552
- display: flex;
553
- justify-content: center;
554
- align-items: center;
555
- text-align: center;
556
- width: 100vw;
557
- }
558
- #user_id {
559
- width: 20%;
560
- height: 2rem;
561
- border-radius: 5px;
562
- border: 1px solid #000;
563
- padding: 0.5rem;
564
- font-size: medium;
565
- }
566
-
567
- .input-submit-button {
568
- padding: 5px 10px;
569
- background: gray;
570
- color: white;
571
- margin: 16px;
572
- font-size: medium;
573
- border-radius: 25px;
574
- }
575
- </style>
576
-
577
- <div class="marwadi">
578
- Welcome To AI Bestie
579
- <div class="bestie">
580
- <label>User Name</label>&nbsp;&nbsp;&nbsp;
581
- <input type="text" id="user_id" oninput="enableSubmitButton()" />
582
- <button class="input-submit-button" disabled id="submit-button">
583
- Submit
584
- </button>
585
- </div>
586
- </div>
587
- <div id="chat-circle" class="btn btn-raised" style="">
588
- <div id="chat-overlay"></div>
589
- AI
590
- </div>
591
-
592
- <div class="chat-box" style="display: none">
593
- <div class="chat-box-header">
594
- AI Bestie
595
- <span class="chat-box-toggle"
596
- ><i class="material-icons">close</i></span
597
- >
598
- </div>
599
-
600
- <div class="chat-box-body">
601
- <div class="chat-box-overlay"></div>
602
- <div class="chat_logs" id="chat_logs"></div>
603
- <!--chat-log -->
604
- <button type="submit" class="cancel" id="cancel">
605
- Stop Response
606
- </button>
607
- </div>
608
- <div class="chat_input">
609
- <form>
610
- <input
611
- type="text"
612
- id="chat_input"
613
- placeholder="Send a message..."
614
- />
615
- <button type="submit" class="chat-submit" id="submit">
616
- <i class="material-icons">send</i>
617
- </button>
618
- </form>
619
- </div>
620
- </div>
621
- </div>
622
- <!-- Scripts -->
623
- <link
624
- rel="stylesheet"
625
- href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
626
- />
627
- <link
628
- rel="stylesheet"
629
- href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/4.0.2/bootstrap-material-design.css"
630
- />
631
- <link
632
- rel="stylesheet"
633
- href="https://fonts.googleapis.com/icon?family=Material+Icons"
634
- />
635
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
636
- <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
637
- <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"></script>
638
- <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/4.0.2/bootstrap-material-design.css"></script>
639
- <script id="rendered-js">
640
- function enableSubmitButton() {
641
- var user_id_input = document.getElementById("user_id");
642
- var submit_button = document.getElementById("submit-button");
643
- console.log(user_id_input.value)
644
- submit_button.disabled = user_id_input.value === "";
645
- submit_button.style.background = user_id_input.value === "" ? "gray" : "#000";
646
- }
647
- function chatWidget(id, name, status) {
648
- $.ajax({
649
- url: "/chatwidget",
650
- type: "POST",
651
- data: JSON.stringify({
652
- user_id: id,
653
- status: status,
654
- user_name: name,
655
- }),
656
- headers: {
657
- "Content-Type": "application/json",
658
- },
659
- success: function (data) {
660
- if (status == "end") {
661
- return true;
662
- } else {
663
- generate_message(data.response, "user");
664
- }
665
- },
666
- });
667
- }
668
- // chatWidget(
669
- // window.logged_in_user.airtable_record_id,
670
- // window.logged_in_user.Name,
671
- // "end"
672
- // );
673
- // setTimeout(() => {
674
- // chatWidget(
675
- // window.logged_in_user.airtable_record_id,
676
- // window.logged_in_user.Name,
677
- // "start"
678
- // );
679
- // }, 300);
680
- function generate_message(msg, type) {
681
- var str = "";
682
- str += "<div id='cm-msg" + "' class=\"chat-msg " + type + '">';
683
- str += ' <div class="cm-msg-text">';
684
- var lines = msg.includes("\n") ? msg.split("\n") : [msg];
685
-
686
- lines.forEach((line) => {
687
- // Check if the line contains a URL
688
- var urlRegex = /(https?:\/\/[^\s]+)/g;
689
- var messageWithLinks = line.replace(
690
- urlRegex,
691
- '<a href="$1" target="_blank">$1</a>'
692
- );
693
-
694
- // Append the line with links to the message string
695
- str += messageWithLinks;
696
-
697
- // Only add <br> if not last line
698
- if (line !== lines[lines.length - 1]) {
699
- str += "<br>";
700
- }
701
- });
702
- str += " <\/div>";
703
- str += " <\/div>";
704
- $(".chat_logs").append(str);
705
-
706
- // Adjust scroll position
707
- var chatLogs = document.getElementById("chat_logs");
708
- chatLogs.scrollTop = chatLogs.scrollHeight;
709
- }
710
-
711
- function error_message(msg, type) {
712
- INDEX++;
713
- var str = "";
714
- str += "<div id='cm-msg" + "' class=\"chat-msg " + type + '">';
715
- str += ' <div class="cm-msg-text">';
716
- var lines = msg.includes("\n") ? msg.split("\n") : [msg];
717
-
718
- lines.forEach((line) => {
719
- str += line;
720
-
721
- // Only add <br> if not last line
722
- if (line !== lines[lines.length - 1]) {
723
- str += "<br>";
724
- }
725
- });
726
- str += " <\/div>";
727
- str += " <\/div>";
728
- $("#chat_logs").append(str);
729
- if (type == "self") {
730
- $("#chat_input").val("");
731
- }
732
- $("#chat_logs")
733
- .stop()
734
- .animate({ scrollTop: $("#chat_logs")[0].scrollHeight }, 1000);
735
- }
736
- $(function () {
737
- var INDEX = 0;
738
- var input = document.getElementById("chat_input");
739
- var submitBtn = document.getElementById("submit");
740
- var cancelRequest = document.getElementById("cancel");
741
-
742
- var userId = document.getElementById("user_id");
743
- $("#cancel").click(function (e) {
744
- input.disabled = false;
745
- e.preventDefault();
746
- submitBtn.disabled = false;
747
- input.style.opacity = 1;
748
- cancelRequest.style.display = "none";
749
- });
750
-
751
- $("#submit").click(function (e) {
752
- cancelRequest.style.display = "block";
753
- input.disabled = true;
754
- input.style.opacity = 0.5;
755
- submitBtn.disabled = true;
756
- e.preventDefault();
757
- var msg = $("#chat_input").val();
758
- if (msg.trim() == "") {
759
- return false;
760
- }
761
- generate_message(msg, "self");
762
- input.value = "";
763
- $.ajax({
764
- url: "/chatwidget",
765
- type: "POST",
766
- data: JSON.stringify({
767
- query: msg,
768
- user_id: userId.value,
769
- // message: `${msg} | ${window.logged_in_user.airtable_record_id}`,
770
- }),
771
- headers: {
772
- "Content-Type": "application/json",
773
- "Access-Control-Allow-Origin": "*",
774
- "Access-Control-Allow-Headers": "Content-Type",
775
- },
776
-
777
- success: function (data) {
778
- console.log(data);
779
- /* data.map(item => generate_message(item.text, "user")) */
780
- generate_message(data, "user");
781
- /* generate_message(data.response, "user"); */
782
- input.disabled = false;
783
- submitBtn.disabled = false;
784
- input.style.opacity = 1;
785
- cancelRequest.style.display = "none";
786
- },
787
- error: function (data) {
788
- error_message(
789
- "We are sorry. we can't proceess Your Request Please Try again after some times.",
790
- "user"
791
- );
792
- input.disabled = false;
793
- submitBtn.disabled = false;
794
- input.style.opacity = 1;
795
- cancelRequest.style.display = "none";
796
- },
797
- });
798
- });
799
- $(document).delegate(".chat-btn", "click", function () {
800
- var value = $(this).attr("chat-value");
801
- var name = $(this).html();
802
- $("#chat_input").attr("disabled", false);
803
- generate_message(name);
804
- });
805
-
806
- $(".chat-box-toggle").click(function () {
807
- $("#chat-circle").toggle("scale");
808
- $(".chat-box").toggle("scale");
809
- $("#sub-button").prop("disabled", false);
810
- userId.disabled = "false"
811
- location.reload();
812
- });
813
- });
814
-
815
- $("#submit-button").click(function () {
816
- $("#chat-circle").toggle("scale");
817
- $(".chat-box").toggle("scale");
818
-
819
-
820
- var input = document.getElementById("chat_input");
821
- var submitBtn = document.getElementById("submit");
822
- var cancelRequest = document.getElementById("cancel");
823
-
824
- var userId = document.getElementById("user_id");
825
-
826
- var submit_button = document.getElementById("submit-button");
827
- submit_button.style.display = 'none'
828
- user_id.style.border = 'none'
829
- user_id.style.background = 'none'
830
- userId.disabled = "true"
831
- $("#sub-button").prop("disabled", true);
832
- cancelRequest.style.display = "block";
833
- input.disabled = true;
834
- $.ajax({
835
- url: "/start-session",
836
- type: "POST",
837
- data: JSON.stringify({
838
- user_id: userId.value,
839
- // message: `${msg} | ${window.logged_in_user.airtable_record_id}`,
840
- }),
841
- headers: {
842
- "Content-Type": "application/json",
843
- },
844
- success: function (data) {
845
- $.ajax({
846
- url: "/chatwidget",
847
- type: "POST",
848
- data: JSON.stringify({
849
- query: "START",
850
- user_id: userId.value,
851
- // message: `${msg} | ${window.logged_in_user.airtable_record_id}`,
852
- }),
853
- headers: {
854
- "Content-Type": "application/json",
855
- "Access-Control-Allow-Origin": "*",
856
- "Access-Control-Allow-Headers": "Content-Type",
857
- },
858
-
859
- success: function (data) {
860
- console.log(data);
861
- /* data.map(item => generate_message(item.text, "user")) */
862
- generate_message(data, "user");
863
- /* generate_message(data.response, "user"); */
864
- input.disabled = false;
865
- submitBtn.disabled = false;
866
- input.style.opacity = 1;
867
- cancelRequest.style.display = "none";
868
- },
869
- error: function (data) {
870
- error_message(
871
- "We are sorry. we can't proceess Your Request Please Try again after some times.",
872
- "user"
873
- );
874
- input.disabled = false;
875
- submitBtn.disabled = false;
876
- input.style.opacity = 1;
877
- cancelRequest.style.display = "none";
878
- },
879
- });
880
- if (status == "end") {
881
- return true;
882
- } else {
883
- console.log(data.response, "session_id");
884
- }
885
- },
886
- });
887
- console.log(userId, userId.value);
888
- });
889
- </script>
890
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
891
- </body>
892
- </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Document</title>
7
+ </head>
8
+
9
+ <body>
10
+ <div id="body">
11
+ <style>
12
+ body {
13
+ /* Add the background image */
14
+ background-image: url("mu-logo-mood-03.jpg");
15
+ /* Adjust background properties */
16
+ background-repeat: no-repeat;
17
+ background-size: cover; /* or contain, depending on your preference */
18
+ /* Add other background properties if needed */
19
+ }
20
+ .cm-msg-text {
21
+ overflow-wrap: break-word;
22
+ /* Break long words */
23
+ word-wrap: break-word;
24
+ /* Break long words */
25
+ word-break: break-word;
26
+ /* Break words */
27
+ max-width: 100%;
28
+ /* Limit maximum width */
29
+ }
30
+
31
+ [data-block="list11-v4-1-1-b2"] .sw-border-bottom-color-000000 {
32
+ border-bottom-color: #000000 !important;
33
+ }
34
+
35
+ [data-block="list11-v4-1-1-b2"] .sw-border-bottom-width-none {
36
+ border-bottom-width: 0px !important;
37
+ }
38
+
39
+ [data-block="list11-v4-1-1-b2"] .sw-border-bottom-style-none {
40
+ border-bottom-style: none !important;
41
+ }
42
+
43
+ [data-block="list11-v4-1-1-b2"] .sw-border-top-color-000000 {
44
+ border-top-color: #000000 !important;
45
+ }
46
+
47
+ [data-block="list11-v4-1-1-b2"] .sw-border-top-width-none {
48
+ border-top-width: 0px !important;
49
+ }
50
+
51
+ [data-block="list11-v4-1-1-b2"] .sw-border-top-style-none {
52
+ border-top-style: none !important;
53
+ }
54
+
55
+ [data-block="list11-v4-1-1-b2"] .sw-padding-bottom-m {
56
+ padding-bottom: 3rem !important;
57
+ }
58
+
59
+ [data-block="list11-v4-1-1-b2"] .sw-padding-top-m {
60
+ padding-top: 3rem !important;
61
+ }
62
+
63
+ [data-block="list11-v4-1-1-b2"] .sw-background-color-ffffff {
64
+ background-color: #ffffff !important;
65
+ }
66
+
67
+ #body {
68
+ z-index: 1999;
69
+ position: fixed;
70
+ margin: 0;
71
+ padding: 0;
72
+ font-family: "Lato", sans-serif;
73
+ background-color: #f6f7f9;
74
+ }
75
+
76
+ @mixin chabox-container {
77
+ display: flex;
78
+ position: absolute;
79
+ box-shadow: 5px 5px 25px 0 rgba(46, 61, 73, 0.2);
80
+ flex-direction: column;
81
+ }
82
+
83
+ @mixin chatbox-header {
84
+ box-sizing: border-box;
85
+ display: flex;
86
+ width: 100%;
87
+ padding: 16px;
88
+ color: #fff;
89
+ background-color: #0360a5;
90
+ align-items: center;
91
+ justify-content: space-around;
92
+ }
93
+
94
+ @mixin chatbox-main {
95
+ box-sizing: border-box;
96
+ width: 100%;
97
+ padding: calc(2 * 16px) 16px;
98
+ line-height: calc(16px + 16px / 2);
99
+ color: #888;
100
+ text-align: center;
101
+ }
102
+
103
+ @mixin chatbox-footer {
104
+ box-sizing: border-box;
105
+ display: flex;
106
+ width: 100%;
107
+ padding: 16px;
108
+ border-top: 1px solid #ddd;
109
+ align-items: center;
110
+ justify-content: space-around;
111
+ }
112
+
113
+ @mixin chatbox-floating-button {
114
+ position: fixed;
115
+ bottom: 0;
116
+ right: 0;
117
+ width: 52px;
118
+ height: 52px;
119
+ color: #fff;
120
+ background-color: #0360a5;
121
+ background-position: center center;
122
+ background-repeat: no-repeat;
123
+ box-shadow: 12px 15px 20px 0 rgba(46, 61, 73, 0.15);
124
+ border: 0;
125
+ border-radius: 50%;
126
+ cursor: pointer;
127
+ }
128
+
129
+ h1 {
130
+ margin: 0;
131
+ font-size: 16px;
132
+ line-height: 1;
133
+ }
134
+
135
+ button {
136
+ color: inherit;
137
+ background-color: transparent;
138
+ border: 0;
139
+ outline: 0 !important;
140
+ cursor: pointer;
141
+ }
142
+
143
+ #center-text {
144
+ display: flex;
145
+ flex: 1;
146
+ flex-direction: column;
147
+ justify-content: center;
148
+ align-items: center;
149
+ height: 100%;
150
+ }
151
+
152
+ #chat-circle {
153
+ position: fixed;
154
+ bottom: 50px;
155
+ z-index: 1999;
156
+ align-items: center;
157
+ right: 50px;
158
+ background: #000;
159
+ width: 60px;
160
+ justify-content: center;
161
+ height: 60px;
162
+ display: flex;
163
+ border-radius: 50%;
164
+ color: white;
165
+ padding: 8px;
166
+ cursor: pointer;
167
+ box-shadow: 0px 3px 16px 0px rgba(0, 0, 0, 0.4),
168
+ 0 3px 1px -2px rgba(0, 0, 0, 0.2), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
169
+ }
170
+
171
+ .btn#my-btn {
172
+ background: white;
173
+ padding-top: 13px;
174
+ padding-bottom: 12px;
175
+ border-radius: 45px;
176
+ padding-right: 40px;
177
+ padding-left: 40px;
178
+ color: #5865c3;
179
+ }
180
+
181
+ #chat-overlay {
182
+ background: rgba(255, 255, 255, 0.1);
183
+ position: absolute;
184
+ top: 0;
185
+ left: 0;
186
+ width: 100%;
187
+ height: 100%;
188
+ border-radius: 50%;
189
+ display: none;
190
+ }
191
+
192
+ .chat-box {
193
+ display: none;
194
+ background: #efefef;
195
+ position: fixed;
196
+ right: 30px;
197
+ z-index: 1999;
198
+ bottom: 50px;
199
+ width: 470px;
200
+ max-width: 85vw;
201
+ max-height: 100vh;
202
+ border-radius: 5px;
203
+ /* box-shadow: 0px 5px 35px 9px #464a92; */
204
+ box-shadow: 0px 5px 35px 9px #ccc;
205
+ }
206
+
207
+ .chat-box-toggle {
208
+ float: right;
209
+ margin-right: 15px;
210
+ cursor: pointer;
211
+ }
212
+
213
+ .chat-box-header {
214
+ background: #000;
215
+ height: 70px;
216
+ border-top-left-radius: 5px;
217
+ border-top-right-radius: 5px;
218
+ color: white;
219
+ text-align: center;
220
+ font-size: 20px;
221
+ padding-top: 17px;
222
+ padding-left: 36px;
223
+ }
224
+
225
+ .chat-box-body {
226
+ position: relative;
227
+ height: 370px;
228
+ height: auto;
229
+ border: 1px solid #ccc;
230
+ overflow: hidden;
231
+ }
232
+
233
+ .chat-box-body:after {
234
+ content: "";
235
+ background: #fff;
236
+ opacity: 0.1;
237
+ top: 0;
238
+ left: 0;
239
+ bottom: 0;
240
+ right: 0;
241
+ height: 100%;
242
+ position: absolute;
243
+ z-index: -1;
244
+ }
245
+
246
+ #chat_input {
247
+ background: #f4f7f9;
248
+ width: 100%;
249
+ position: relative;
250
+ height: 47px;
251
+ padding-top: 10px;
252
+ padding-right: 50px;
253
+ padding-bottom: 10px;
254
+ padding-left: 15px;
255
+ border: none;
256
+ resize: none;
257
+ outline: none;
258
+ border: 1px solid #ccc;
259
+ color: #888;
260
+ border-top: none;
261
+ border-bottom-right-radius: 5px;
262
+ border-bottom-left-radius: 5px;
263
+ overflow: hidden;
264
+ }
265
+
266
+ .chat_input > form {
267
+ margin-bottom: 0;
268
+ }
269
+
270
+ #chat_input::-webkit-input-placeholder {
271
+ /* Chrome/Opera/Safari */
272
+ color: #ccc;
273
+ }
274
+
275
+ #chat_input::-moz-placeholder {
276
+ /* Firefox 19+ */
277
+ color: #ccc;
278
+ }
279
+
280
+ #chat_input:-ms-input-placeholder {
281
+ /* IE 10+ */
282
+ color: #ccc;
283
+ }
284
+
285
+ #chat_input:-moz-placeholder {
286
+ /* Firefox 18- */
287
+ color: #ccc;
288
+ }
289
+
290
+ .chat-submit {
291
+ position: absolute;
292
+ bottom: 3px;
293
+ right: 10px;
294
+ background: transparent;
295
+ box-shadow: none;
296
+ border: none;
297
+ border-radius: 50%;
298
+ color: #000;
299
+ width: 35px;
300
+ height: 35px;
301
+ }
302
+
303
+ .chat_logs {
304
+ padding: 15px;
305
+ height: 370px;
306
+ overflow-y: scroll;
307
+ margin-bottom: 48px;
308
+ }
309
+
310
+ .chat_logs::-webkit-scrollbar-track {
311
+ -webkit-box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.3);
312
+ background-color: #f5f5f5;
313
+ }
314
+
315
+ .chat_logs::-webkit-scrollbar {
316
+ width: 5px;
317
+ background-color: #f5f5f5;
318
+ }
319
+
320
+ .chat_logs::-webkit-scrollbar-thumb {
321
+ background-color: #000;
322
+ }
323
+
324
+ @media only screen and (max-width: 500px) {
325
+ .chat_logs {
326
+ height: 40vh;
327
+ }
328
+ }
329
+
330
+ .chat-msg.user > .msg-avatar img {
331
+ width: 45px;
332
+ height: 45px;
333
+ border-radius: 50%;
334
+ float: left;
335
+ width: 15%;
336
+ }
337
+
338
+ .chat-msg.self > .msg-avatar img {
339
+ width: 45px;
340
+ height: 45px;
341
+ border-radius: 50%;
342
+ float: right;
343
+ width: 15%;
344
+ }
345
+
346
+ .cm-msg-text {
347
+ z-index: 1999;
348
+ background: white;
349
+ padding: 10px 15px 10px 15px;
350
+ color: #666;
351
+ max-width: 75%;
352
+ float: left;
353
+ margin-left: 10px;
354
+ position: relative;
355
+ margin-bottom: 20px;
356
+ border-radius: 30px;
357
+ border-bottom-left-radius: 0px;
358
+ }
359
+
360
+ .svg-bot {
361
+ height: 24px;
362
+ width: 24px;
363
+ }
364
+
365
+ .chat-msg {
366
+ clear: both;
367
+ z-index: 1999;
368
+ }
369
+
370
+ .chat-msg.self > .cm-msg-text {
371
+ float: right;
372
+ margin-right: 10px;
373
+ border-radius: 30px;
374
+ border-bottom-right-radius: 0px;
375
+ background: #000;
376
+ color: white;
377
+ }
378
+
379
+ .cm-msg-button > ul > li {
380
+ list-style: none;
381
+ float: left;
382
+ width: 50%;
383
+ }
384
+
385
+ .cm-msg-button {
386
+ clear: both;
387
+ margin-bottom: 70px;
388
+ }
389
+
390
+ .chat-btn {
391
+ z-index: 1999;
392
+ }
393
+
394
+ .cancel {
395
+ display: none;
396
+ border: none;
397
+ border-radius: 5px;
398
+ background-color: #d6d6d6;
399
+ color: black;
400
+ z-index: 1999;
401
+ bottom: 3px;
402
+ position: absolute;
403
+ padding: 5px 5px;
404
+ margin: 0 172px;
405
+ }
406
+
407
+ [data-block^="list11-v4-1-1"] .vertical-list-item {
408
+ height: 100%;
409
+ overflow: hidden;
410
+ }
411
+
412
+ [data-block^="list11-v4-1-1"] .additional-elements-wrapper {
413
+ width: 100%;
414
+ }
415
+
416
+ [data-block^="list11-v4-1-1"] .label-wrapper.vertical {
417
+ flex-direction: column;
418
+ }
419
+
420
+ [data-block^="list11-v4-1-1"] .label-wrapper {
421
+ display: flex;
422
+ }
423
+
424
+ p,
425
+ h1,
426
+ h2,
427
+ h3,
428
+ h4,
429
+ h5,
430
+ small {
431
+ white-space: pre-line;
432
+ }
433
+
434
+ h1,
435
+ h2,
436
+ h3,
437
+ h4,
438
+ h5,
439
+ h6,
440
+ .h1,
441
+ .h2,
442
+ .h3,
443
+ .h4,
444
+ .h5,
445
+ .h6 {
446
+ margin-bottom: 0.25rem;
447
+ font-family: inherit;
448
+ font-weight: 400;
449
+ line-height: 1.1;
450
+ color: inherit;
451
+ }
452
+
453
+ [data-block^="list11-v4-1-1"] .list-container dl,
454
+ [data-block^="list11-v4-1-1"] .list-container h1,
455
+ [data-block^="list11-v4-1-1"] .list-container h2,
456
+ [data-block^="list11-v4-1-1"] .list-container h3,
457
+ [data-block^="list11-v4-1-1"] .list-container h4,
458
+ [data-block^="list11-v4-1-1"] .list-container h5,
459
+ [data-block^="list11-v4-1-1"] .list-container h6,
460
+ [data-block^="list11-v4-1-1"] .list-container ol,
461
+ [data-block^="list11-v4-1-1"] .list-container p,
462
+ [data-block^="list11-v4-1-1"] .list-container ul {
463
+ margin: 0;
464
+ padding: 0;
465
+ }
466
+
467
+ [data-block="list11-v4-1-1-b2"] .sw-text-align-center {
468
+ text-align: center !important;
469
+ }
470
+
471
+ [data-block="list11-v4-1-1-b2"] .sw-margin-top-none {
472
+ margin-top: 0rem !important;
473
+ }
474
+
475
+ [data-block="list11-v4-1-1-b2"] .sw-margin-bottom-none {
476
+ margin-bottom: 0rem !important;
477
+ }
478
+
479
+ [data-block="list11-v4-1-1-b2"] .sw-font-size-2xl {
480
+ font-size: 1.5rem !important;
481
+ }
482
+
483
+ [data-block="list11-v4-1-1-b2"] .sw-padding-bottom-5xs {
484
+ padding-bottom: 0.75rem !important;
485
+ }
486
+
487
+ [data-block="list11-v4-1-1-b2"] .sw-padding-top-none {
488
+ padding-top: 0rem !important;
489
+ }
490
+
491
+ [data-block="list11-v4-1-1-b2"] .sw-letter-spacing-normal {
492
+ letter-spacing: 0rem !important;
493
+ }
494
+
495
+ [data-block="list11-v4-1-1-b2"] .sw-text-color-0A0A0A {
496
+ color: #0a0a0a !important;
497
+ }
498
+
499
+ [data-block="list11-v4-1-1-b2"] .sw-padding-right-none {
500
+ padding-right: 0rem !important;
501
+ }
502
+
503
+ [data-block="list11-v4-1-1-b2"] .sw-padding-left-none {
504
+ padding-left: 0rem !important;
505
+ }
506
+
507
+ [data-block="list11-v4-1-1-b2"] .sw-font-weight-semibold {
508
+ font-weight: 600 !important;
509
+ }
510
+
511
+ h1.sw-text-color-default,
512
+ h2.sw-text-color-default,
513
+ h3.sw-font-family-default {
514
+ color: #000000;
515
+ }
516
+
517
+ h1.sw-font-weight-default,
518
+ h2.sw-font-weight-default,
519
+ h3.sw-font-family-default {
520
+ font-weight: 600;
521
+ }
522
+
523
+ h1.sw-font-family-default,
524
+ h2.sw-font-family-default,
525
+ h3.sw-font-family-default {
526
+ font-family: "IBM Plex Sans";
527
+ }
528
+
529
+ /* .bg-img {
530
+ background-image: url("./MU_LOGO_BLACK.jpg");
531
+ background-repeat: no-repeat;
532
+ position: relative;
533
+ background-position: center;
534
+ background-size: cover;
535
+ } */
536
+
537
+ .marwadi {
538
+ width: 100vw;
539
+ height: 100vh;
540
+ text-align: center;
541
+ margin: auto;
542
+ font-size: xx-large;
543
+ font-weight: bolder;
544
+ display: flex;
545
+ flex-direction: column;
546
+ justify-content: center;
547
+ align-items: center;
548
+ }
549
+
550
+ .bestie {
551
+ margin: 1rem;
552
+ display: flex;
553
+ justify-content: center;
554
+ align-items: center;
555
+ text-align: center;
556
+ width: 100vw;
557
+ }
558
+
559
+
560
+ .input-submit-button {
561
+ padding: 5px 10px;
562
+ background: gray;
563
+ color: white;
564
+ margin: 16px;
565
+ font-size: medium;
566
+ border-radius: 25px;
567
+ }
568
+ </style>
569
+
570
+ <div class="marwadi">
571
+ Welcome To AI Bestie
572
+ <div class="bestie">
573
+ <label>welcome back Rina </label>&nbsp;&nbsp;&nbsp;
574
+ <button class="input-submit-button" disabled id="submit-button">
575
+ Start
576
+ </button>
577
+ </div>
578
+ </div>
579
+ <div id="chat-circle" class="btn btn-raised" style="">
580
+ <div id="chat-overlay"></div>
581
+ AI
582
+ </div>
583
+
584
+ <div class="chat-box" style="display: none">
585
+ <div class="chat-box-header">
586
+ AI Bestie
587
+ <span class="chat-box-toggle"
588
+ ><i class="material-icons">close</i></span
589
+ >
590
+ </div>
591
+
592
+ <div class="chat-box-body">
593
+ <div class="chat-box-overlay"></div>
594
+ <div class="chat_logs" id="chat_logs"></div>
595
+ <!--chat-log -->
596
+ <button type="submit" class="cancel" id="cancel">
597
+ Stop Response
598
+ </button>
599
+ </div>
600
+ <div class="chat_input">
601
+ <form>
602
+ <input
603
+ type="text"
604
+ id="chat_input"
605
+ placeholder="Send a message..."
606
+ />
607
+ <button type="submit" class="chat-submit" id="submit">
608
+ <i class="material-icons">send</i>
609
+ </button>
610
+ </form>
611
+ </div>
612
+ </div>
613
+ </div>
614
+ <!-- Scripts -->
615
+ <link
616
+ rel="stylesheet"
617
+ href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
618
+ />
619
+ <link
620
+ rel="stylesheet"
621
+ href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/4.0.2/bootstrap-material-design.css"
622
+ />
623
+ <link
624
+ rel="stylesheet"
625
+ href="https://fonts.googleapis.com/icon?family=Material+Icons"
626
+ />
627
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
628
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/js/bootstrap.min.js"></script>
629
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"></script>
630
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-material-design/4.0.2/bootstrap-material-design.css"></script>
631
+ <script id="rendered-js">
632
+
633
+ function chatWidget(id, name, status) {
634
+ $.ajax({
635
+ url: "/chatwidget",
636
+ type: "POST",
637
+ data: JSON.stringify({
638
+ user_id: 'Rina',
639
+ status: status,
640
+ user_name: name,
641
+ }),
642
+ headers: {
643
+ "Content-Type": "application/json",
644
+ },
645
+ success: function (data) {
646
+ if (status == "end") {
647
+ return true;
648
+ } else {
649
+ generate_message(data.response, "user");
650
+ }
651
+ },
652
+ });
653
+ }
654
+ // chatWidget(
655
+ // window.logged_in_user.airtable_record_id,
656
+ // window.logged_in_user.Name,
657
+ // "end"
658
+ // );
659
+ // setTimeout(() => {
660
+ // chatWidget(
661
+ // window.logged_in_user.airtable_record_id,
662
+ // window.logged_in_user.Name,
663
+ // "start"
664
+ // );
665
+ // }, 300);
666
+ function generate_message(msg, type) {
667
+ var str = "";
668
+ str += "<div id='cm-msg" + "' class=\"chat-msg " + type + '">';
669
+ str += ' <div class="cm-msg-text">';
670
+ var lines = msg.includes("\n") ? msg.split("\n") : [msg];
671
+
672
+ lines.forEach((line) => {
673
+ // Check if the line contains a URL
674
+ var urlRegex = /(https?:\/\/[^\s]+)/g;
675
+ var messageWithLinks = line.replace(
676
+ urlRegex,
677
+ '<a href="$1" target="_blank">$1</a>'
678
+ );
679
+
680
+ // Append the line with links to the message string
681
+ str += messageWithLinks;
682
+
683
+ // Only add <br> if not last line
684
+ if (line !== lines[lines.length - 1]) {
685
+ str += "<br>";
686
+ }
687
+ });
688
+ str += " <\/div>";
689
+ str += " <\/div>";
690
+ $(".chat_logs").append(str);
691
+
692
+ // Adjust scroll position
693
+ var chatLogs = document.getElementById("chat_logs");
694
+ chatLogs.scrollTop = chatLogs.scrollHeight;
695
+ }
696
+
697
+ function error_message(msg, type) {
698
+ INDEX++;
699
+ var str = "";
700
+ str += "<div id='cm-msg" + "' class=\"chat-msg " + type + '">';
701
+ str += ' <div class="cm-msg-text">';
702
+ var lines = msg.includes("\n") ? msg.split("\n") : [msg];
703
+
704
+ lines.forEach((line) => {
705
+ str += line;
706
+
707
+ // Only add <br> if not last line
708
+ if (line !== lines[lines.length - 1]) {
709
+ str += "<br>";
710
+ }
711
+ });
712
+ str += " <\/div>";
713
+ str += " <\/div>";
714
+ $("#chat_logs").append(str);
715
+ if (type == "self") {
716
+ $("#chat_input").val("");
717
+ }
718
+ $("#chat_logs")
719
+ .stop()
720
+ .animate({ scrollTop: $("#chat_logs")[0].scrollHeight }, 1000);
721
+ }
722
+ $(function () {
723
+ var INDEX = 0;
724
+ var input = document.getElementById("chat_input");
725
+ var submitBtn = document.getElementById("submit");
726
+ var cancelRequest = document.getElementById("cancel");
727
+
728
+ $("#cancel").click(function (e) {
729
+ input.disabled = false;
730
+ e.preventDefault();
731
+ submitBtn.disabled = false;
732
+ input.style.opacity = 1;
733
+ cancelRequest.style.display = "none";
734
+ });
735
+
736
+ $("#submit").click(function (e) {
737
+ cancelRequest.style.display = "block";
738
+ input.disabled = true;
739
+ input.style.opacity = 0.5;
740
+ submitBtn.disabled = true;
741
+ e.preventDefault();
742
+ var msg = $("#chat_input").val();
743
+ if (msg.trim() == "") {
744
+ return false;
745
+ }
746
+ generate_message(msg, "self");
747
+ input.value = "";
748
+ $.ajax({
749
+ url: "/chatwidget",
750
+ type: "POST",
751
+ data: JSON.stringify({
752
+ query: msg,
753
+ user_id: 'Rina',
754
+ // message: `${msg} | ${window.logged_in_user.airtable_record_id}`,
755
+ }),
756
+ headers: {
757
+ "Content-Type": "application/json",
758
+ "Access-Control-Allow-Origin": "*",
759
+ "Access-Control-Allow-Headers": "Content-Type",
760
+ },
761
+
762
+ success: function (data) {
763
+ console.log(data);
764
+ /* data.map(item => generate_message(item.text, "user")) */
765
+ generate_message(data, "user");
766
+ /* generate_message(data.response, "user"); */
767
+ input.disabled = false;
768
+ submitBtn.disabled = false;
769
+ input.style.opacity = 1;
770
+ cancelRequest.style.display = "none";
771
+ },
772
+ error: function (data) {
773
+ error_message(
774
+ "We are sorry. we can't proceess Your Request Please Try again after some times.",
775
+ "user"
776
+ );
777
+ input.disabled = false;
778
+ submitBtn.disabled = false;
779
+ input.style.opacity = 1;
780
+ cancelRequest.style.display = "none";
781
+ },
782
+ });
783
+ });
784
+ $(document).delegate(".chat-btn", "click", function () {
785
+ var value = $(this).attr("chat-value");
786
+ var name = $(this).html();
787
+ $("#chat_input").attr("disabled", false);
788
+ generate_message(name);
789
+ });
790
+
791
+ $(".chat-box-toggle").click(function () {
792
+ $("#chat-circle").toggle("scale");
793
+ $(".chat-box").toggle("scale");
794
+ $("#sub-button").prop("disabled", false);
795
+ location.reload();
796
+ });
797
+ });
798
+
799
+ $("#submit-button").click(function () {
800
+ $("#chat-circle").toggle("scale");
801
+ $(".chat-box").toggle("scale");
802
+
803
+
804
+ var input = document.getElementById("chat_input");
805
+ var submitBtn = document.getElementById("submit");
806
+ var cancelRequest = document.getElementById("cancel");
807
+
808
+ var submit_button = document.getElementById("submit-button");
809
+ submit_button.style.display = 'none'
810
+
811
+ $("#sub-button").prop("disabled", true);
812
+ cancelRequest.style.display = "block";
813
+ input.disabled = true;
814
+ $.ajax({
815
+ url: "/start-session",
816
+ type: "POST",
817
+ data: JSON.stringify({
818
+ user_id: 'Rina',
819
+ // message: `${msg} | ${window.logged_in_user.airtable_record_id}`,
820
+ }),
821
+ headers: {
822
+ "Content-Type": "application/json",
823
+ },
824
+ success: function (data) {
825
+ $.ajax({
826
+ url: "/chatwidget",
827
+ type: "POST",
828
+ data: JSON.stringify({
829
+ query: "START",
830
+ user_id: 'Rina',
831
+ // message: `${msg} | ${window.logged_in_user.airtable_record_id}`,
832
+ }),
833
+ headers: {
834
+ "Content-Type": "application/json",
835
+ "Access-Control-Allow-Origin": "*",
836
+ "Access-Control-Allow-Headers": "Content-Type",
837
+ },
838
+
839
+ success: function (data) {
840
+ console.log(data);
841
+ /* data.map(item => generate_message(item.text, "user")) */
842
+ generate_message(data, "user");
843
+ /* generate_message(data.response, "user"); */
844
+ input.disabled = false;
845
+ submitBtn.disabled = false;
846
+ input.style.opacity = 1;
847
+ cancelRequest.style.display = "none";
848
+ },
849
+ error: function (data) {
850
+ error_message(
851
+ "We are sorry. we can't proceess Your Request Please Try again after some times.",
852
+ "user"
853
+ );
854
+ input.disabled = false;
855
+ submitBtn.disabled = false;
856
+ input.style.opacity = 1;
857
+ cancelRequest.style.display = "none";
858
+ },
859
+ });
860
+ if (status == "end") {
861
+ return true;
862
+ } else {
863
+ console.log(data.response, "session_id");
864
+ }
865
+ },
866
+ });
867
+ });
868
+ </script>
869
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
870
+ </body>
871
+ </html>