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