function pgsh() {
this.prompt = 'pgs $ '
this.welcome = ''
this.responses = {
'about': function() {
return 'Site by Weiyi Lou ' + new Date().getFullYear()
},
'version': function() {
return 'Parsley Gardens Shell (pgsh) 1.0.0. Built with Riot.js'
},
'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() {
var output = ''
if (!this.Parent.su) {
this.Parent.oldprompt = this.Parent.prompt
this.Parent.prompt = 'root % '
this.Parent.su = true
output = 'With Great Power comes Great'
}
return output
},
'exit': function() {
var output = 'Close browser window to exit'
if (this.Parent.su) {
this.Parent.prompt = this.Parent.oldprompt
this.Parent.su = false
output = ''
}
return output
},
'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()