11function init ( ) {
2-
3- //--------------------------- Important Variables----------------------------
4- var inactiveMessage = "Server is down, Please contact the developer to activate it"
2+ var inactiveMessage = "Server is down"
53 chatPopup = document . querySelector ( ".chat-popup" )
6- chatBtn = document . querySelector ( ".chat-btn" )
74 chatSubmit = document . querySelector ( ".chat-submit" )
85 chatHeader = document . querySelector ( ".chat-header" )
96 chatArea = document . querySelector ( ".chat-area" )
107 chatInput = document . querySelector ( ".chat-input" )
11- expandWindow = document . querySelector ( ".expand-chat-window" )
128 root = document . documentElement ;
13- chatPopup . style . display = "none "
9+ chatPopup . style . display = "flex "
1410 var host = "http://localhost:8080"
1511
16-
17- //------------------------ ChatBot Toggler -------------------------
18-
19- chatBtn . addEventListener ( "click" , ( ) => {
20-
21- mobileDevice = ! detectMob ( )
22- if ( chatPopup . style . display == "none" && mobileDevice ) {
23- chatPopup . style . display = "flex"
24- chatInput . focus ( ) ;
25- chatBtn . innerHTML = `<i class='material-icons'>close</i>`
26- } else if ( mobileDevice ) {
27- chatPopup . style . display = "none"
28- chatBtn . innerHTML = `<i class='material-icons'>chat</i>`
29- } else {
30- mobileView ( )
31- }
32- } )
33-
3412 chatSubmit . addEventListener ( "click" , ( ) => {
3513 let userResponse = chatInput . value . trim ( ) ;
3614 if ( userResponse !== "" ) {
@@ -40,8 +18,6 @@ function init() {
4018 } )
4119}
4220
43- // end of init function
44-
4521function userResponseBtn ( e ) {
4622 send ( e . value ) ;
4723}
@@ -70,16 +46,10 @@ function setUserResponse() {
7046 scrollToBottomOfResults ( ) ;
7147}
7248
73-
74-
7549function scrollToBottomOfResults ( ) {
7650 chatArea . scrollTop = chatArea . scrollHeight ;
7751}
7852
79- /***************************************************************
80- Frontend Part Completed
81- ****************************************************************/
82-
8353function send ( message ) {
8454 chatInput . type = "text"
8555 passwordInput = false ;
@@ -95,33 +65,15 @@ function send(message) {
9565 chatInput . focus ( ) ;
9666}
9767
98- function mobileView ( ) {
99- $ ( '.chat-popup' ) . width ( $ ( window ) . width ( ) ) ;
100-
101- if ( chatPopup . style . display == "none" ) {
102- chatPopup . style . display = "flex"
103- // chatInput.focus();
104- chatBtn . style . display = "none"
105- chatPopup . style . bottom = "0"
106- chatPopup . style . right = "0"
107- // chatPopup.style.transition = "none"
108- expandWindow . innerHTML = `<i class='material-icons'>close</i>`
109- }
110- }
111-
112- function detectMob ( ) {
113- return ( ( window . innerHeight <= 800 ) && ( window . innerWidth <= 600 ) ) ;
114- }
115-
116- function createChatBot ( ) {
68+ function createChat ( ) {
11769
11870 host = "http://localhost:8080" ;
11971 init ( )
12072 const msg = document . querySelector ( ".msg" ) ;
121- msg . innerText = "Welcome to Enarx Chat!" ;
73+ msg . innerText = "Welcome to Enarx Chat! Send a message to an Enarx Keep below: " ;
12274
12375 const botTitle = document . querySelector ( ".bot-title" ) ;
12476 botTitle . innerText = "Enarx Chat" ;
12577}
12678
127- createChatBot ( ) ;
79+ createChat ( ) ;
0 commit comments