├── style.css ├── index.html ├── modules ├── intercomTestSuite.js └── demo.js ├── intercom-min.js ├── README.markdown ├── intercom.js └── jquery.js /style.css: -------------------------------------------------------------------------------- 1 | @CHARSET "UTF-8"; 2 | 3 | body { 4 | color: #FAFAFA; 5 | background-color: #000000; 6 | } 7 | 8 | input:focus { 9 | outline: none; 10 | } 11 | 12 | #output { 13 | font-family: "Courier New"; 14 | font-size: 12px; 15 | } 16 | 17 | input { 18 | font-family: "Courier New"; 19 | font-size: 12px; 20 | background-color: #000000; 21 | color: #FAFAFA 22 | } 23 | 24 | /* Styles */ 25 | 26 | .error { 27 | font-weight: bold; 28 | color: #920000 29 | } 30 | 31 | .success { 32 | font-weight: bold; 33 | color: #006200; 34 | } 35 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Intercom Development 5 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 19 | 20 | 21 | 22 | 23 | 28 | 29 |
30 |
31 | »  33 |
34 | 35 | 36 | -------------------------------------------------------------------------------- /modules/intercomTestSuite.js: -------------------------------------------------------------------------------- 1 | identifyPlugin("test"); 2 | addParser(test_hook); 3 | test_version = "1.0.0.0"; 4 | 5 | // Generate helptext with the HelpText object 6 | test_helpText = new HelpText(); 7 | 8 | // Flags 9 | test_helpText.addFlag("c", "Command line intercom Parser"); 10 | 11 | // Commands 12 | test_helpText.addCommand("dump", "Dump debug information"); 13 | 14 | // Information 15 | test_helpText.setIntro("This module is a standard tool designed to help test " + 16 | "and debug Intercom modules.
Version: " + test_version); 17 | 18 | function test_hook(input) { 19 | 20 | // Check for main hook 21 | if (checkCommand(input, "test")) { 22 | test_args = extractArguments(input); 23 | test_flags = extractFlags(input); 24 | 25 | // Command line flag 26 | if (hasFlag(test_flags, "c")) { 27 | setInputStream(test_commands); 28 | output("Entering command line execution. Enter 'quit' to exit."); 29 | } else if (test_args[1] == "dump") { 30 | debug(); 31 | } else { 32 | output(test_helpText); 33 | } 34 | 35 | quitParse(); 36 | } 37 | 38 | } 39 | 40 | function test_commands(input) { 41 | if (input == "quit") { 42 | output(input); 43 | resetInputStream(); 44 | output("Quitting command line execution and resetting input stream."); 45 | } else { 46 | output(input, "", true); 47 | try { 48 | eval(input); 49 | } catch(err) { 50 | output("Error: " + err.message); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /modules/demo.js: -------------------------------------------------------------------------------- 1 | // First, we identify our plugin with identifyPlugin() 2 | identifyPlugin("demo"); 3 | 4 | // This allows intercom to list our plugin when the user executes 'help' 5 | // Then, we add our 'hook' parser to the parser list, which lets intercom run 6 | // user input by our function when entered. This way, we can parse user input 7 | // when it is meant for our module. 8 | addParser(demo_hook); 9 | 10 | // Here we declare a simple helptext variable which we will use later. It is 11 | // useful to have a helptext for a program which requires argumenrs or flags. 12 | demo_helpText = "Welcome to the intercom demo.
" + 13 | "To run the demo parser, use 'demo run'"; 14 | 15 | // Other random variables 16 | demo_step = 0; 17 | 18 | // This is our hook function. This will be run whenever a user enters input. 19 | // This function should look for initiating calls and act accordingly. 20 | // Here, we have our hook print the helptext when there are no arguments, 21 | // or enter the parser for the demo if the argument 'run' is included. 22 | function demo_hook(input) { 23 | 24 | // Check the command. The command is what comes before the first space in a 25 | // input string. We check to see if it equals "demo". 26 | if (checkCommand(input, "demo")) { 27 | 28 | // quitParse() ends intercom's standard parse. 29 | quitParse(); 30 | 31 | // Save the arguments and flags to variables 32 | demo_arguments = extractArguments(input); 33 | demo_flags = extractFlags(input); 34 | 35 | // No arguments -- display help 36 | if (demo_arguments.length == 1) { 37 | output(demo_helpText); 38 | } 39 | 40 | // Check for other args, if it equals "run" it will enter the demo_parser 41 | // input stream. 42 | else if (demo_arguments[1] == "run") { 43 | setInputStream(demo_parser); 44 | output("The Demo parser is now active! To quit, use the forcequit"+ 45 | " command.
" + 46 | "So now, try setting a flag! Type 'demo -f'"); 47 | } 48 | } 49 | } 50 | 51 | // This is our custom input stream. It has to take a single paramater which 52 | // intercom will use to send all user input directly to the input stream 53 | // once set. 54 | function demo_parser(input) { 55 | output(input); 56 | demo_arguments = extractArguments(input); 57 | demo_flags = extractFlags(input); 58 | 59 | // Last demo step 60 | if (demo_step == 2) { 61 | output("Your two arguments were:"); 62 | output(demo_arguments[1]); 63 | output(demo_arguments[2]); 64 | output("That's the end of this quick demo, but there's so much more you" + 65 | " can do!
With the right mix of JS, JSON and Ajax, intercom plugins"+ 66 | " have endless possibilities."); 67 | output("Quitting the demo..."); 68 | resetInputStream(); 69 | } 70 | 71 | // Demo step 2 72 | if (demo_step == 1) { 73 | if (hasFlag(demo_flags, "f") && flagValue(demo_flags, "f") == "hello") { 74 | demo_step = 2; 75 | output("Awesome! Flags can be used to set options for a command.
" + 76 | "You can also check for other arguments. Fill in the blanks:
" + 77 | "'demo _____ _____'"); 78 | } else { 79 | output("Sorta...type 'demo -f=hello'"); 80 | } 81 | } 82 | 83 | // Demo step 1 84 | if (demo_step == 0) { 85 | if (hasFlag(demo_flags, "f")) { 86 | demo_step = 1; 87 | output("Great! You can also set flag values. Type 'demo -f=hello'"); 88 | } else { 89 | output("Sorta...type 'demo -f'"); 90 | } 91 | } 92 | 93 | 94 | 95 | 96 | } 97 | -------------------------------------------------------------------------------- /intercom-min.js: -------------------------------------------------------------------------------- 1 | 2 | var VERSION="1.0.2.0";var inputStream=parseInput;var quitNow=false;var plugin_text="";var commands=Array();var showCommand=0;var tempUrl="";var parsers=[];var plugins=[];$(document).ready(function(){$('#input').focus();output("Welcome to Intercom v."+VERSION);for(i=0;i";}});function checkKey(e){if(e.keyCode==13){var input=$('#input').val();$('#input').val('');if(input=="forcequit"){outputWithCarrot(input);output("Focequitting back to main input stream.");inputStream=parseInput;}else{commands.push(input);showCommand=commands.length;inputStream(input);}}else if(e.keyCode==38){showCommand--;if(showCommand<=0){showCommand=0;} 3 | $('#input').val(commands[showCommand]);}else if(e.keyCode==40){showCommand++;if(showCommand>=commands.length){$('#input').val('');showCommand=commands.length;}else{$('#input').val(commands[showCommand]);}}else{}} 4 | function parseInput(input){output("» "+input);for(i=0;iIntercom is a JavaScript-based web console built for "+"plugins. Each instance of Intercom may have as many or as few "+"plugins as desired.");output("Intercom is currently in development stages, please check "+"http://i.amMichael.com for information on release.");output("For the list of basic commands, type 'help -commands'");output("
--------------------------
");output("This Intercom has the following plugins installed:
"+ 12 | plugin_text);} 13 | function outputHelpCommands(){output("Intercom basic commands");output("-----------------------");output("help - display help message");output("clear - clears the content of the screen");output("open [URL] - opens the given URL in the console");} 14 | function openPage(url,ignorehttp,fix){if(fix){if(url.substring(0,3)=="www"){output("Notice: requested address WAS "+url+", adding 'http://' "+"in front. Use open -nofix to stop this.");url="http://"+url;} 15 | if(!ignorehttp&&url.substring(0,4)!="http"){tempUrl=url;output("The requested URL to open is not a valid http request. "+"Open anyway?");output("y/n/(a)dd http:// in front");setInputStream(openPageCheckUrl);return;}} 16 | output("