peddamat
5/8/2013 - 9:42 PM

index-handler.js

// Handle a command.
var handler = function(command) {
  if (command) {
    try {
      jqconsole.Write('==> ' + window.eval(command) + '\n');
    } catch (e) {
      jqconsole.Write('ERROR: ' + e.message + '\n');
    }
  }
  jqconsole.Prompt(true, handler, function(command) {
    // Continue line if can't compile the command.
    try {
      Function(command);
    } catch (e) {
      if (/[\[\{\(]$/.test(command)) {
        return 1;
      } else {
        return 0;
      }
    }
    return false;
  });
};

// Initiate the first prompt.
handler();