Skip to content

Commit 23681f1

Browse files
committed
minor changes
1 parent f772a5d commit 23681f1

File tree

7 files changed

+63
-28
lines changed

7 files changed

+63
-28
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ const sendAnswer = async (req, res) => {
166166
}
167167
}
168168
}
169-
} else if (/(?:my name is|I'm|I am) (.{1,30})/gmi.test(humanInput)) {
169+
} else if (/(?:my name is|I'm|I am) (?!fine|good)(.{1,30})/gmi.test(humanInput)) {
170170
const humanName = /(?:my name is|I'm|I am) (.{1,30})/gmi.exec(humanInput);
171171
responseText = `Nice to meet you ${humanName[1]}.`;
172172
rating = 1;

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"scripts": {
1919
"dev": "nodemon",
2020
"start": "node index.js",
21+
"less": "lessc public/src/styles/styles.less public/src/styles/compiled.min.css -x --source-map",
2122
"fix": "eslint . --ext .js --fix",
2223
"lint": "semistandard --fix \"**/*.js\""
2324
},

public/index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
1212

1313
<link rel="stylesheet" href="./src/styles/normalize.min.css" />
14-
<link rel="stylesheet/less" type="text/css" href="./src/styles/styles.less" />
15-
<script src="./src/javascript/less.js"></script>
16-
14+
<link rel="stylesheet" href="./src/styles/compiled.min.css" />
1715
</head>
1816

1917
<body>
@@ -22,8 +20,8 @@
2220
<h2>JavaScript ChatBot</h2>
2321
<p class="typing">bot is typing. . .</p>
2422
</div>
25-
<div id="toogle-chat" >
26-
<img src="./src/images/chat_icon.png" class="suggest-chat" >
23+
<div id="toogle-chat">
24+
<img src="./src/images/chat_icon.png" class="suggest-chat">
2725
</div>
2826
</header>
2927

public/src/javascript/app.js

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable no-unused-vars */
21
// submit form
32
const submitForm = () => {
43
const chatInput = $(".chat-input").val();
@@ -25,9 +24,11 @@ const submitForm = () => {
2524
</div>
2625
</div>
2726
`);
28-
$([document.documentElement, document.body]).animate({
29-
scrollTop: $(".chat-msg-box.bot:last-child").offset().top,
30-
}, { duration: 500 });
27+
if ($(".chat-msg-box").length >= 10) {
28+
$([document.documentElement, document.body]).animate({
29+
scrollTop: $(".chat-msg-box.bot:last-child").offset().top,
30+
}, { duration: 500 });
31+
}
3132
},
3233
success: (data) => {
3334
const response = (data.responseText).replace(/\n/gm, "</br>");
@@ -58,9 +59,6 @@ window.onload = () => {
5859
</div>
5960
</div>
6061
`);
61-
$([document.documentElement, document.body]).animate({
62-
scrollTop: $(".chat-msg-box.bot:last-child").offset().top,
63-
}, { duration: 500 });
6462
},
6563
success: (data) => {
6664
const response = (data.responseText).replace(/\n/gm, "</br>");
@@ -77,7 +75,7 @@ window.onload = () => {
7775
}, 3000);
7876

7977
$.ajax({
80-
url: "http://javascript-chatbot.vercel.app/api/allquestions",
78+
url: "./api/allquestions",
8179
success: (data) => {
8280
data.forEach((qus) => {
8381
$(".questions.container").append(`
@@ -90,33 +88,63 @@ window.onload = () => {
9088
});
9189
};
9290

93-
window.onresize = () => {
94-
if (window.innerHeight < 580) {
95-
$("header").css("top", "-4em");
96-
} else {
97-
$("header").css("top", "0vh");
98-
}
99-
};
100-
101-
const toogleShowQuestions = () => {
91+
const toogleShowSuggestions = () => {
10292
if ($("main").css("display") == "none") {
103-
$(".questions.container").hide();
93+
$(".all-questions").hide();
10494
$("header img").attr("src", "./src/images/chat_icon.png");
10595
$("main").show();
10696
$("footer").show();
10797
} else {
108-
$(".questions.container").css("display", "flex");
98+
$(".all-questions").show();
10999
$("header img").attr("src", "./src/images/close.png");
110100
$("main").hide();
111101
$("footer").hide();
112102
}
113103
};
114104

115105
$("#toogle-chat").on("click", () => {
116-
toogleShowQuestions();
106+
toogleShowSuggestions();
117107
});
118108

109+
window.onresize = () => {
110+
if (window.innerHeight < 580) {
111+
$("header").css("top", "-4em");
112+
} else {
113+
$("header").css("top", "0vh");
114+
}
115+
};
116+
119117
$("#chat-form").submit((e) => {
120118
e.preventDefault();
121119
submitForm();
122120
});
121+
122+
const typed = new Typed(".chat-input", {
123+
strings: [
124+
"how many mm in 1 cm",
125+
"change 10 l into ml",
126+
"what is computer",
127+
"what is JavaScript",
128+
"what is HTML",
129+
"tell me about ChatBot",
130+
"who is Mahatma Gandhi",
131+
"who is Nelson Mandela",
132+
"When do you have birthday?",
133+
"Tell me about your personality.",
134+
"I want a funny joke.",
135+
"Can you tell me a joke please?",
136+
"Can you tell me something about your creators?",
137+
"Are you just a bot?",
138+
"Date of your birthday.",
139+
"How are you today?",
140+
],
141+
typeSpeed: 60,
142+
backSpeed: 30,
143+
backDelay: 1500,
144+
showCursor: true,
145+
cursorChar: "|",
146+
attr: "placeholder",
147+
loop: true,
148+
bindInputFocusEvents: true,
149+
shuffle: true,
150+
});
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/src/styles/compiled.min.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/src/styles/styles.less

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,16 @@ main {
139139
}
140140
}
141141

142+
.all-questions{
143+
display: none;
144+
}
145+
142146
.questions.container {
143147
display: flex;
144148
flex-direction: column;
145149
flex-wrap: nowrap;
146150
align-content: center;
147151
justify-content: space-around;
148-
display: none;
149152

150153
h2 {
151154
padding-top: 3.7em;
@@ -198,6 +201,10 @@ footer {
198201
padding-left: 0.5em;
199202
color: @color_5;
200203

204+
&::placeholder {
205+
color: #9f9f9f;
206+
}
207+
201208
&:focus {
202209
outline: none;
203210
border-color: @border_color_1;

0 commit comments

Comments
 (0)