| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- function pgsh() {
- this.prompt = '<span style="color:purple">pgs </span><span style="color:green">$ </span>'
- this.welcome = ''
- 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 <a target="_blank" href="https://code.parsleygardens.net">code.parsleygardens.net</a>'
- },
- 'hello': function() {
- return 'Hello to you too'
- },
- 'magic': function() {
- return 'Animation and Illustration at <a target="_blank" href="http://slightlymagic.com.au">slightlymagic.com.au</a>'
- },
- 'su': function() {
- var output = ''
- if (!this.Parent.su) {
- this.Parent.oldprompt = this.Parent.prompt
- this.Parent.prompt = '<span style="color:purple">root </span><span style="color:red">% </span>'
- 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()
|