-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
55 lines (51 loc) · 1.55 KB
/
script.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
let directory = "";
let file = "";
$('#terminal').terminal({
pwd: function(){
this.echo('/home/ \n You are currently on the home page. Next step: where to? HINT: command to list all files')
},
ls: function(){
this.echo('home page1 \npage2 page3 \nThese are the files you can go to. \nHINT: go to page 1' )
},
cd: function(destination){
if (destination == "page1") {
this.exec(window.location.href="/page1.html")
}
else if (destination == "home") {
this.exec(window.location.href="/main.html")
}
else{
this.echo("Sorry - for the purposes of this demo please type cd page1")
}
},
mkdir: function(name){
directory = name
if(directory){
this.echo("New directory " + file + " made!")
}
},
rmdir: function(remove){
if (remove == directory){
this.echo("You successfully removed the file!")
}
else{
this.echo("ERROR: No such file exists. Did you misspell the directory you wanted to delete?")
}
},
touch: function(name){
file = name
if(file){
this.echo("New file " + file + " made!")
}
},
rm: function(remove){
if (remove == file){
this.echo("You successfully removed the file!")
}
else{
this.echo("ERROR: No such file exists. Did you misspell the file you wanted to delete?")
}
}
}, {
greetings: 'Dive into the terminal!'
});