Advertisement
Guest User

sysop.js

a guest
Jan 27th, 2015
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //sysop command line stuffs, using Deuce's str_cmds.js with a lightbar menu
  2. //-megaloyeti
  3.  
  4. load("frame.js");
  5. load("tree.js");
  6. load("str_cmds.js"); //contains the string command functions
  7.  
  8. var window = new Frame(1,1,80,24,BG_BLACK|WHITE);
  9.  
  10. var info_frame = new Frame(36,7,26,10,BG_BLACK|YELLOW,window);
  11.  
  12. var menu_frame = new Frame(18,7,17,10,BG_GREEN|YELLOW,window);
  13.  
  14. var menu = new Tree(menu_frame, "TREE");
  15. menu.colors = {fg:WHITE,bg:BG_BLUE,lfg:LIGHTGREEN,lbg:BG_BLACK,cfg:LIGHTGREEN,cbg:BG_BLACK,dfg:DARKGRAY,kfg:YELLOW,tfg:CYAN,hfg:GREEN,hbg:BG_BLACK,xfg:LIGHTGREEN};
  16. menu.addItem("Error Log",error_log);
  17. menu.addItem("Guru Log", guru_log);
  18. menu.addItem("Change User",chuser);
  19. //menu.addItem("ANSI Capture",anscap);
  20. menu.addItem("List File",list);
  21. menu.addItem("Edit File", edit);
  22. menu.addItem("Log Today",tlog);
  23. menu.addItem("Log Yesterday",ylog);
  24. menu.addItem("System Stats",sys_stat);
  25. //menu.addItem("Node Stats", node_stat);    //needs prompt for node #
  26. menu.addItem("Execute", exec);
  27. //menu.addItem("Execute Binary", nexec);    //error opening C, dunno what this is/does/means
  28. menu.addItem("User Editor",uedit);
  29.  
  30.  
  31. var a;      // temp var, boolean for runIt main loop
  32. var b;      // temp var, boolean for exit to menu
  33. var cmd;    // var for user command record
  34. var key;    // var for keystroke record
  35. var help;   // var for help string
  36. var title;  // var for highlighted menu item text
  37.  
  38. run_me();
  39.  
  40. function run_me() {
  41.     a = true;
  42.    
  43.     window.open(); 
  44.     window.putmsg("Press 'Q' to Quit")
  45.  
  46.     menu.open();
  47.  
  48.     info_frame.top();
  49.     info_frame.word_wrap = true;
  50.    
  51.     menu_frame.top();
  52.    
  53.     while(a) {
  54.         info_frame.clear();
  55.         info_frame.gotoxy(1,1);
  56.         info_frame.putmsg(get_Help());
  57.    
  58.         window.cycle();
  59.  
  60.         cmd = console.inkey(K_NOECHO,5);   
  61.  
  62.         switch(cmd){
  63.             case "q":
  64.             case "Q":
  65.                 a = false;
  66.                 break;
  67.             default:
  68.             key = menu.getcmd(cmd);            
  69.             if(key === undefined) break;
  70.             break;
  71.         }
  72.         console.gotoxy(80,24);
  73.     }
  74. }
  75.  
  76. function get_Help(){
  77.     title = menu.currentItem.text;
  78.     switch(title){
  79.         case "System Stats":
  80.             help = title + ":\r\nDisplays current system stats";
  81.             break;
  82.         case "Error Log":
  83.             help = title + ":\r\nDisplay current error log and optionally delete it as well as optionally clearing all nodes error counters.";
  84.             break;
  85.         case "Guru Log":
  86.             help = title + ":\r\nDisplay and optionally clear current guru log.";
  87.             break;
  88.         case "Change User":
  89.             help = title + ":\r\nBecome a different user.";
  90.             break;
  91.         case "ANSI capture":
  92.             help = title + ":\r\nToggles ANSI capture.";
  93.             break;
  94.         case "List File":
  95.             help = title + ":\r\nDisplays a specified file.";
  96.             break;
  97.         case "Edit File":
  98.             help = title + ":\r\nEdits a specified file using your message editor.";
  99.             break;
  100.         case "Log Today":
  101.             help = title + ":\r\nDisplays today's activity log.";
  102.             break;
  103.         case "Log Yesterday":
  104.             help = title + ":\r\nDisplays yesterday's activity log.";
  105.             break;
  106.         case "Node Stats":
  107.             help = title + ":\r\nDisplays the current node stats for node #.";
  108.             break;
  109.         case "Execute":
  110.             help = title + ":\r\nExecutes command with I/O redirected.";
  111.             break;
  112.         case "Execute Binary":
  113.             help = title + ":\r\nExecutres command with I/O redirected and assuming it's a native binary.";
  114.             break;
  115.         case "User Editor":
  116.             help = title + ":\r\nEdit user profiles.";
  117.             break;
  118.         default:
  119.             help = title + ":";
  120.         break;
  121.     }
  122.     return help;
  123. };
  124.  
  125. function sys_stat(){
  126.     console.clear();
  127.     console.home();
  128.     bbs.sys_stats();
  129.     console.crlf();
  130.     console.write("Press 'X' to Exit");
  131.     //generic exit loop//
  132.     b = true;
  133.     while(b) { 
  134.         cmd = console.inkey(K_NOECHO,5);   
  135.         switch(cmd){
  136.             case "x":
  137.             case "X":
  138.                 b = false;
  139.             break;
  140.            
  141.             default:
  142.             break;
  143.         }
  144.     }
  145.     window.invalidate();
  146. }
  147.  
  148. function error_log(){
  149.     console.clear();
  150.     console.home();
  151.     console.attributes=BG_BLACK|WHITE;
  152.     str_cmds("ERR");
  153.     //generic exit loop//
  154.     console.write("Press 'X' to Exit");
  155.     b = true;
  156.     while(b) { 
  157.         cmd = console.inkey(K_NOECHO,5);   
  158.         switch(cmd){
  159.             case "x":
  160.             case "X":
  161.                 b = false;
  162.             break;
  163.            
  164.             default:
  165.             break;
  166.         }
  167.     }
  168.     console.clear();
  169.     window.invalidate();
  170. };
  171.  
  172. function guru_log(){
  173.     console.clear();
  174.     console.home();
  175.     console.attributes=BG_BLACK|WHITE;
  176.     str_cmds("GURU");
  177.     //generic exit loop//
  178.     console.write("Press 'X' to Exit");
  179.     b = true;
  180.     while(b) { 
  181.         cmd = console.inkey(K_NOECHO,5);   
  182.         switch(cmd){
  183.             case "x":
  184.             case "X":
  185.                 b = false;
  186.             break;
  187.            
  188.             default:
  189.             break;
  190.         }
  191.     }
  192.     console.clear();
  193.     window.invalidate();
  194. };
  195.  
  196. function chuser(){
  197.     console.clear();
  198.     console.home();
  199.     console.attributes=BG_BLACK|WHITE;
  200.     str_cmds("CHUSER");
  201.     window.invalidate();
  202. };
  203.  
  204. function anscap(){
  205.     console.clear();
  206.     console.home();
  207.     console.attributes=BG_BLACK|WHITE;
  208.     str_cmds("ANSCAP");
  209.     window.invalidate();
  210. };
  211.  
  212. function list(){
  213.     console.clear();
  214.     console.home();
  215.     console.attributes=BG_BLACK|WHITE;
  216.     str_cmds("LIST");
  217.     window.invalidate();
  218. };
  219.  
  220. function edit(){
  221.     console.clear();
  222.     console.home();
  223.     console.attributes=BG_BLACK|WHITE;
  224.     str_cmds("EDIT");
  225.     window.invalidate();
  226. };
  227.  
  228. function tlog(){
  229.     console.clear();
  230.     console.home();
  231.     console.attributes=BG_BLACK|WHITE;
  232.     str_cmds("LOG");
  233.     //generic exit loop//
  234.     console.write("Press 'X' to Exit");
  235.     b = true;
  236.     while(b) { 
  237.         cmd = console.inkey(K_NOECHO,5);   
  238.         switch(cmd){
  239.             case "x":
  240.             case "X":
  241.                 b = false;
  242.             break;
  243.            
  244.             default:
  245.             break;
  246.         }
  247.     }
  248.     console.clear();
  249.     window.invalidate();
  250. };
  251.  
  252. function ylog(){
  253.     console.clear();
  254.     console.home();
  255.     console.attributes=BG_BLACK|WHITE;
  256.     str_cmds("YLOG");
  257.     //generic exit loop//
  258.     console.write("Press 'X' to Exit");
  259.     b = true;
  260.     while(b) { 
  261.         cmd = console.inkey(K_NOECHO,5);   
  262.         switch(cmd){
  263.             case "x":
  264.             case "X":
  265.                 b = false;
  266.             break;
  267.            
  268.             default:
  269.             break;
  270.         }
  271.     }
  272.     console.clear();
  273.     window.invalidate();
  274. };
  275.  
  276. function node_stat(){
  277.     console.clear();
  278.     console.home();
  279.     console.attributes=BG_BLACK|WHITE;
  280.     str_cmds("NS");
  281.     window.invalidate();
  282. };
  283.  
  284. function exec(){
  285.     console.clear();
  286.     console.home();
  287.     console.attributes=BG_BLACK|WHITE;
  288.     str_cmds("EXEC");
  289.     window.invalidate();
  290. };
  291.  
  292. function nexec(){
  293.     console.clear();
  294.     console.home();
  295.     console.attributes=BG_BLACK|WHITE;
  296.     str_cmds("NEXEC");
  297.     window.invalidate();
  298. };
  299.  
  300. function uedit(){
  301.     console.clear();
  302.     console.home();
  303.     console.attributes=BG_BLACK|WHITE;
  304.     str_cmds("UEDIT");
  305.     window.invalidate();
  306. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement