diff --git a/core/ansi_escape_parser.js b/core/ansi_escape_parser.js index b8c62342..f1398820 100644 --- a/core/ansi_escape_parser.js +++ b/core/ansi_escape_parser.js @@ -75,6 +75,7 @@ function ANSIEscapeParser(options) { //self.bgColor = 0; self.fgColor = 39; self.bgColor = 49; + self.flags = 0; }; self.rowUpdated = function() { @@ -298,8 +299,10 @@ function ANSIEscapeParser(options) { self.bgColor = arg; } else { self.flags |= arg; + if(0 === arg) { self.resetColor(); + //self.flags = 0; } } } diff --git a/core/button_view.js b/core/button_view.js index 6c81496b..80557525 100644 --- a/core/button_view.js +++ b/core/button_view.js @@ -9,7 +9,6 @@ var assert = require('assert'); exports.ButtonView = ButtonView; function ButtonView(client, options) { - console.log(options); options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true); options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true); options.justify = miscUtil.valueWithDefault(options.justify, 'center'); @@ -27,4 +26,8 @@ ButtonView.prototype.onKeyPress = function(key, isSpecial) { if(' ' === key) { this.emit('action', 'accept'); } -}; \ No newline at end of file +}; + +ButtonView.prototype.getViewData = function() { + return null; +}; diff --git a/core/menu_module.js b/core/menu_module.js index 4890ac87..7fa0502a 100644 --- a/core/menu_module.js +++ b/core/menu_module.js @@ -63,7 +63,6 @@ MenuModule.prototype.enter = function(client) { }; MenuModule.prototype.leave = function() { - var count = this.viewControllers.length; for(var i = 0; i < count; ++i) { this.viewControllers[i].detachClientEvents(); @@ -79,9 +78,7 @@ MenuModule.prototype.beforeArt = function() { }; MenuModule.prototype.mciReady = function(mciMap) { - console.log('mciReady') }; MenuModule.prototype.finishedLoading = function() { - console.log('finishedLoading') }; \ No newline at end of file diff --git a/core/text_view.js b/core/text_view.js index 4cf531ec..9e375d3d 100644 --- a/core/text_view.js +++ b/core/text_view.js @@ -70,6 +70,10 @@ TextView.prototype.setFocus = function(focused) { this.client.term.write(this.getANSIColor(this.getFocusColor())); }; +TextView.prototype.getViewData = function() { + return this.text; +}; + TextView.prototype.setText = function(text) { this.text = text; diff --git a/core/view_controller.js b/core/view_controller.js index e5a1f216..4193d9de 100644 --- a/core/view_controller.js +++ b/core/view_controller.js @@ -49,7 +49,7 @@ function ViewController(client, formId) { case 'accept' : // :TODO: consider naming this 'done' // :TODO: check if id is submit, etc. - if(self.focusedView && self.focusedView.submit) { + if(self.focusedView && self.focusedView.submit) { self.submitForm(); } else { self.nextFocus(); @@ -245,21 +245,26 @@ ViewController.prototype.loadFromMCIMapAndConfig = function(options, cb) { if(formConfig) { async.each(Object.keys(formConfig.mci), function onMciConf(mci, eachCb) { var viewId = parseInt(mci[2]); // :TODO: what about auto-generated ID's? Do they simply not apply to menu configs? + var view = self.getView(viewId); var mciConf = formConfig.mci[mci]; // :TODO: Break all of this up ... and/or better way of doing it if(mciConf.items) { - self.getView(viewId).setItems(mciConf.items); + view.setItems(mciConf.items); } if(mciConf.submit) { - self.getView(viewId).submit = true; // :TODO: should really be actual value + view.submit = true; // :TODO: should really be actual value } if(mciConf.focus) { self.switchFocus(viewId); } + if(mciConf.text) { + view.setText(mciConf.text); + } + eachCb(null); }, @@ -280,14 +285,21 @@ ViewController.prototype.loadFromMCIMapAndConfig = function(options, cb) { self.on('submit', function onSubmit(formData) { Log.debug( { formData : formData }, 'Submit form'); + var submitCompare = function(value, other) { + console.log(value); + console.log(other); + return false; + }; + for(var c = 0; c < formConfig.submit.length; ++c) { - console.log(formConfig.submit[c]); + //console.log(formConfig.submit[c]); if(ld.isEqual(formData.value, formConfig.submit[c].value)) { self.client.gotoMenuModule(formConfig.submit[c].menu); break; } + var equal = ld.isEqual(formData.value, formConfig.submit[c].value, submitCompare); // :TODO: Match various wildcards, etc. } }); diff --git a/mods/art/LOGIN1.ANS b/mods/art/LOGIN1.ANS index 8264bc48..c29ab7d0 100644 Binary files a/mods/art/LOGIN1.ANS and b/mods/art/LOGIN1.ANS differ diff --git a/mods/menu.json b/mods/menu.json index 61793136..c740dc19 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -21,7 +21,7 @@ VerticalMenu: { id: 0, submitId: 1, value: { '1': 1 } } Another concept: - + "menu" : "@helper.js/logoff" -> calls helper.js::logoff(...) */ @@ -44,7 +44,31 @@ }, "login" : { "art" : "login", - "module" : "login" + "module" : "login", + "form" : [ + { + "mciReq" : [ "ET1", "ET2", "BN3", "BN4" ], + "mci" :{ + "ET1" : { + "focus" : true + }, + "BN3" : { + "submit" : true, + "text" : "Login" + }, + "BN4" : { + "submit" : true, + "text" : "Cancel" + } + }, + "submit" : [ + { + "value" : { "3" : null }, + "menu" : "pickles" + } + ] + } + ] }, "logoff" : { "art" : "logoff",