123456789101112131415161718192021222324252627282930 |
- if(MIDAS == undefined) {
- var MIDAS = {};
- }
- MIDAS.InputParser = function() {
- var self = this;
- this.parse = function(string, commands) {
- var words = string.split(" ");
- var command = words[0];
- if (!isValidCommand(command, commands)) {
- return {"error": true, "errorMessage":string};
- }
- var data = words.splice(1);
- var result = {
- "command":command
- ,"data":data
- };
- return result;
- };
- function isValidCommand(command, commands) {
- for(var i = 0; i < commands.length; i++) {
- if(command == commands[i]) {
- return true;
- }
- }
- return false;
- };
- };
|