-
Notifications
You must be signed in to change notification settings - Fork 0
/
chat.js
75 lines (60 loc) · 2.9 KB
/
chat.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
(function () {
// Select the div with the class 'vondy-embed'
var container = document.querySelector('.vondy-embed');
container.style.zIndex = 999999999999;
// Create the chat bubble container
var chatBubbleContainer = document.createElement('div');
chatBubbleContainer.style.position = 'fixed';
chatBubbleContainer.style.bottom = '30px';
chatBubbleContainer.style.right = '24px';
chatBubbleContainer.style.width = '64px';
chatBubbleContainer.style.height = '64px';
chatBubbleContainer.style.backgroundColor = '#3c72f0';
chatBubbleContainer.style.cursor = 'pointer';
chatBubbleContainer.style.display = 'flex';
chatBubbleContainer.style.borderRadius = '40px';
chatBubbleContainer.style.display = 'blue';
var chatText = document.createElement('p')
chatText.textContent = '💬'
chatText.style.margin = 'auto';
chatText.style.fontSize = '26px';
chatText.style.color = 'white';
chatBubbleContainer.appendChild(chatText)
// var chatBubble = document.createElement('iframe');
// chatBubble.src = 'http://localhost:3000/bot'; // Set the source to your chatbot URL
// chatBubble.style.width = '100%';
// chatBubble.style.height = '100%';
// chatBubble.style.border = 'none';
// // Append the chat bubble iframe to the chat bubble container
// chatBubbleContainer.appendChild(chatBubble);
// Create the chat display container
var chatDisplayContainer = document.createElement('div');
chatDisplayContainer.style.position = 'fixed';
chatDisplayContainer.style.bottom = '84px';
chatDisplayContainer.style.right = '10px';
chatDisplayContainer.style.width = '380px';
chatDisplayContainer.style.height = '0px';
// Create the chat display iframe
var chatDisplay = document.createElement('iframe');
chatDisplay.src = 'https://vondy.bio/bot'; // Set the source to your chatbot URL
chatDisplay.style.width = '100%';
chatDisplay.style.height = '100%';
chatDisplay.style.border = 'none';
// Append the chat display iframe to the chat display container
chatDisplayContainer.appendChild(chatDisplay);
// Append the chat bubble and display containers to the main container
container.appendChild(chatBubbleContainer);
container.appendChild(chatDisplayContainer);
// Add event listener for chat bubble click
chatBubbleContainer.addEventListener('click', function () {
console.log('hi', chatDisplayContainer.style.height)
// Toggle the display of the chat display container
if (chatDisplayContainer.style.height === '800px') {
chatDisplayContainer.style.height = '0px';
chatText.innerText = '💬'
} else {
chatDisplayContainer.style.height = '800px';
chatText.innerText = '↓'
}
});
})()