pgsh.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. function pgsh() {
  2. this.prompt = '$'
  3. this.responses = {
  4. 'about': function() {
  5. return 'This website belongs to Weiyi Lou ' + new Date().getFullYear()
  6. },
  7. 'version': function() {
  8. return 'Parsley Gardens Shell (pgsh) 1.0.0'
  9. },
  10. 'git': function() {
  11. return 'Self-Hosted Code repository at <a target="_blank" href="https://code.parsleygardens.net">code.parsleygardens.net</a>'
  12. },
  13. 'hello': function() {
  14. return 'Hello to you too'
  15. },
  16. 'magic': function() {
  17. return 'Animation and Illustration at <a target="_blank" href="http://slightlymagic.com.au">slightlymagic.com.au</a>'
  18. },
  19. 'su': function() {
  20. this.Parent.prompt = '%'
  21. return 'With Great Power comes Great'
  22. },
  23. 'exit': function() {
  24. if (this.Parent.prompt == '%') {
  25. this.Parent.prompt = '$'
  26. return ''
  27. }
  28. return 'Close browser window to exit'
  29. },
  30. 'help': function() {
  31. var functions = [];
  32. for(var name in this.Parent.responses) {
  33. if (name !== 'Parent') {
  34. functions.push(name);
  35. }
  36. }
  37. functions.sort();
  38. return 'Available commands:\n' + functions.join(' ')
  39. }
  40. }
  41. this.process = function(input) {
  42. var output = ''
  43. if (input in this.responses) {
  44. this.responses.Parent = this
  45. output += this.responses[input]()
  46. }
  47. return output
  48. }
  49. }
  50. var pgsh = new pgsh()