function pgsh() {
this.prompt = '$'
this.responses = {
'about': function() {
return 'This website belongs to Weiyi Lou ' + new Date().getFullYear()
},
'version': function() {
return 'Parsley Gardens Shell (pgsh) 1.0.0'
},
'git': function() {
return 'Self-Hosted Code repository at code.parsleygardens.net'
},
'hello': function() {
return 'Hello to you too'
},
'magic': function() {
return 'Animation and Illustration at slightlymagic.com.au'
},
'su': function() {
this.Parent.prompt = '%'
return 'With Great Power comes Great'
},
'exit': function() {
if (this.Parent.prompt == '%') {
this.Parent.prompt = '$'
return ''
}
return 'Close browser window to exit'
},
'help': function() {
var functions = [];
for(var name in this.Parent.responses) {
if (name !== 'Parent') {
functions.push(name);
}
}
functions.sort();
return 'Available commands:\n' + functions.join(' ')
}
}
this.process = function(input) {
var output = ''
if (input in this.responses) {
this.responses.Parent = this
output += this.responses[input]()
}
return output
}
}
var pgsh = new pgsh()