-
Notifications
You must be signed in to change notification settings - Fork 0
/
readURL_3.js
44 lines (44 loc) · 1011 Bytes
/
readURL_3.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
<!DOCTYPE html>
<html>
<body>
var userInput = //string input from simon
userInput.toLowerCase();
var openBTab = ["open tab", "open new tab"];
var openTab = ["open ","go to"];
var closeTab= ["close", "end"];
if (userInput.substr(0,5)=="simon"){
userIput=userInput.substr(6,userInput.length-6);
while(userInput.length >0){
//open blank tab
for(i=0;i<openBTab.length;i++){
if(userInput==openBTab[i]){
window.open(target="_blank");
}
}
//open tab w/ specific url given by user
for(i=0;i<openTab.length;i++){
if(userInput.substr(0,5)==openTab[i]){
arr unserInputArr=userInput.split(" ");
window.open(href=userInputArr[1] target="_blank");
}
}
//close tab
for(i=0;i<closeTab.length;i++){
if(userInput.indexOf(closeTab[i])>=0){
window.close();
}
}
//refresh tab
if(userInput=="refresh"){
window.refresh();
}
//previous page
if(userInput=="previous page"){
history.back();
}
//next page
if(userInput=="next page"){
history.forward;
}
}
}