-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
240 lines (208 loc) · 8.87 KB
/
index.html
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
<html>
<head>
<title>InovIT</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href="https://fonts.googleapis.com/css?family=Turret+Road&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat&display=swap" rel="stylesheet">
<script src="script.js"></script>
</head>
<body>
<img class="logo" src="pictures/InovIT.png">
<ul class="nav">
<li class="nav"><a href= "index.html"> Home </a> </li>
<li class="nav"><a href= "tutorial.html"> Tutorial </a> </li>
<li class="nav"><a href= "specification.html"> Specification </a> </li>
</ul>
<div class="animate-fading">
<center>
<a href="index.html"><img class="mySlides" src="pictures/slide3.png" style="width:100%"></a>
<a href="tutorial.html"><img class="mySlides" src="pictures/slide2.png" style="width:100%"></a>
<a href="specification.html"><img class="mySlides" src="pictures/slide1.png" style="width:100%"></a>
</center>
<button class="button black display-left" onclick="plusDivs(-1)">❮</button>
<button class="button black display-right" onclick="plusDivs(1)">❯</button>
</div>
<script>
//slideshow
var slideIndex = 1;
showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length}
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
</script>
<button onclick="myFunction()" class="chatopen animate-right"><img width="60px" height="60px" src="pictures/chat.png"></button>
<div class="ui-titlebar animate-right animation hide" id="chatty">
<div id='bodybox'>
<div id='chatborder'>
<p id="chatlog7" class="chatlog"> </p>
<p id="chatlog6" class="chatlog"> </p>
<p id="chatlog5" class="chatlog"> </p>
<p id="chatlog4" class="chatlog"> </p>
<p id="chatlog3" class="chatlog"> </p>
<p id="chatlog2" class="chatlog"> </p>
<p id="chatlog1" class="chatlog"> </p>
<input type="text" name="chat" id="chatbox" placeholder="Type here to talk to me." onfocus="placeHolder()">
</div></div>
<!--<div class="ui-titleicon"></div>-->
<div class="ui-titletext">Chatbot</div>
<div class="ui-titlecontrols">
<button class="ui-btn minimize">
<svg x="0px" y="0px" viewBox="0 0 10.2 1"><rect x="0" y="50%" width="10.2" height="1" /></svg>
</button><button class="ui-btn maximize">
<svg viewBox="0 0 10 10"><path d="M0,0v10h10V0H0z M9,9H1V1h8V9z" /></svg>
</button><button class="ui-btn close">
<svg viewBox="0 0 10 10"><polygon points="10.2,0.7 9.5,0 5.1,4.4 0.7,0 0,0.7 4.4,5.1 0,9.5 0.7,10.2 5.1,5.8 9.5,10.2 10.2,9.5 5.8,5.1" /></svg>
</button>
</div>
</div>
<!--
Unmaximize/restore
<svg viewBox="0 0 10.2 10.1"><path d="M2.1,0v2H0v8.1h8.2v-2h2V0H2.1z M7.2,9.2H1.1V3h6.1V9.2z M9.2,7.1h-1V2H3.1V1h6.1V7.1z" /></svg>
-->
<script>
//CHATBOT
//links
//http://eloquentjavascript.net/09_regexp.html
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
var messages = [], //array that hold the record of each string in chat
lastUserMessage = "", //keeps track of the most recent input string from the user
botMessage = "", //var keeps track of what the chatbot is going to say
botName = 'Ivex', //name of the chatbot
talking = true; //when false the speach function doesn't work
//
//
//****************************************************************
//****************************************************************
//****************************************************************
//****************************************************************
//****************************************************************
//****************************************************************
//****************************************************************
//edit this function to change what the chatbot says
function chatbotResponse() {
talking = true;
botMessage = "I'm confused, type 'help'."; //the default message
if (lastUserMessage === 'help') {
var str = "commands, just scroll to 'Functionality'.";
botMessage = 'Here is a list of ' + str.link("specification.html");
}
if (lastUserMessage === 'hi' || lastUserMessage =='hello'|| lastUserMessage =='howdy') {
const hi = ['hi','howdy','hello']
botMessage = hi[Math.floor(Math.random()*(hi.length))];;
}
if (lastUserMessage === 'name') {
botMessage = 'My name is ' + botName;
}
if (lastUserMessage === 'tutorial' || lastUserMessage =='photoshop'|| lastUserMessage == 'video') {
var str = "Digital Image Retouching!";
botMessage = 'Here is a tutorial by InovIT, ' + str.link("tutorial.html");
}
if (lastUserMessage === 'specification' || lastUserMessage =='about'|| lastUserMessage == 'details') {
var str = "specification!";
botMessage = "Here is an overview of our website's " + str.link("specification.html");
}
if (lastUserMessage === 'steps' || lastUserMessage =='step') {
var str = "steps in retouching an image.";
botMessage = "Here are the " + str.link("specification.html");
}
var n = lastUserMessage.search(/\b(home|house|front)\b/i);
if (n !== -1) {
botMessage = "You're home!";
}
var n = lastUserMessage.search(/\b(dogs|dog|canines|puppy|puppies)\b/i);
if (n !== -1) {
botMessage = "I love dogs!";
}
var n = lastUserMessage.search(/\b(husky|samoyed|pomeranian)\b/i);
if (n !== -1) {
botMessage = "They are my favorite type of dogs!";
}
var n = lastUserMessage.search(/\b(origins|origin|created|creator)\b/i);
if (n !== -1) {
botMessage = "I was brought to life by Amanda!";
}
}
//****************************************************************
//****************************************************************
//****************************************************************
//****************************************************************
//****************************************************************
//****************************************************************
//****************************************************************
//
//
//
//this runs each time enter is pressed.
//It controls the overall input and output
function newEntry() {
//if the message from the user isn't empty then run
if (document.getElementById("chatbox").value != "") {
//pulls the value from the chatbox ands sets it to lastUserMessage
lastUserMessage = document.getElementById("chatbox").value;
//sets the chat box to be clear
document.getElementById("chatbox").value = "";
//adds the value of the chatbox to the array messages
messages.push(lastUserMessage);
//Speech(lastUserMessage); //says what the user typed outloud
//sets the variable botMessage in response to lastUserMessage
chatbotResponse();
//add the chatbot's name and message to the array messages
messages.push("<b>" + botName + ":</b> " + botMessage);
// says the message using the text to speech function written below
Speech(botMessage);
//outputs the last few array elements of messages to html
for (var i = 1; i < 8; i++) {
if (messages[messages.length - i])
document.getElementById("chatlog" + i).innerHTML = messages[messages.length - i];
}
}
}
//text to Speech
//https://developers.google.com/web/updates/2014/01/Web-apps-that-talk-Introduction-to-the-Speech-Synthesis-API
function Speech(say) {
if ('speechSynthesis' in window && talking) {
var utterance = new SpeechSynthesisUtterance(say);
//msg.voice = voices[10]; // Note: some voices don't support altering params
//msg.voiceURI = 'native';
//utterance.volume = 1; // 0 to 1
//utterance.rate = 0.1; // 0.1 to 10
//utterance.pitch = 1; //0 to 2
//utterance.text = 'Hello World';
//utterance.lang = 'en-US';
speechSynthesis.speak(utterance);
}
}
//runs the keypress() function when a key is pressed
document.onkeypress = keyPress;
//if the key pressed is 'enter' runs the function newEntry()
function keyPress(e) {
var x = e || window.event;
var key = (x.keyCode || x.which);
if (key == 13 || key == 3) {
//runs this function when enter is pressed
newEntry();
}
if (key == 38) {
console.log('hi')
//document.getElementById("chatbox").value = lastUserMessage;
}
}
//clears the placeholder text ion the chatbox
//this function is set to run when the users brings focus to the chatbox, by clicking on it
function placeHolder() {
document.getElementById("chatbox").placeholder = "";
}
</script>
<div class="footer">InovIT | Created by Amanda Viray | © 2019</div>
</body>
</html>