diff --git a/core/string_util.js b/core/string_util.js index 0a70d680..6fb8f7a7 100644 --- a/core/string_util.js +++ b/core/string_util.js @@ -9,6 +9,7 @@ exports.pad = pad; exports.replaceAt = replaceAt; exports.isPrintable = isPrintable; exports.debugEscapedString = debugEscapedString; +exports.format = format; // :TODO: create Unicode verison of this var VOWELS = [ 'a', 'e', 'i', 'o', 'u' ]; @@ -174,4 +175,19 @@ function stringLength(s) { function debugEscapedString(s) { return JSON.stringify(s).slice(1, -1); -} \ No newline at end of file +} + +function format(fmt) { + if (!arguments.length) { + return fmt; + } + + var args = typeof arguments[1]; + args = (("string" === args || "number" === args) ? arguments : arguments[1]); + + for(var arg in args) { + fmt = fmt.replace(RegExp("\\{" + arg + "\\}", "gi"), args[arg]); + } + + return fmt; +} diff --git a/mods/last_callers.js b/mods/last_callers.js index 5daa62eb..c6f99b16 100644 --- a/mods/last_callers.js +++ b/mods/last_callers.js @@ -33,7 +33,7 @@ function LastCallersModule(options) { this.rows = 10; - if(this.menuConfig.config) { + if(_.isObject(this.menuConfig.config)) { if(_.isNumber(this.menuConfig.config.rows)) { this.rows = Math.max(1, this.menuConfig.config.rows); } diff --git a/mods/menu.json b/mods/menu.json index 90176865..1c1ad3ad 100644 --- a/mods/menu.json +++ b/mods/menu.json @@ -287,8 +287,17 @@ "mci" : { "LV1" : { "widht" : 30, - "height" : 10 + "height" : 10, + "focus" : true } + }, + "submit" : { + "*" : [ + { + "value" : null, + "action" : "@method:changeArea" + } + ] } } } diff --git a/mods/msg_area_list.js b/mods/msg_area_list.js index 01f11ec4..cdf5dfd0 100644 --- a/mods/msg_area_list.js +++ b/mods/msg_area_list.js @@ -4,6 +4,7 @@ var MenuModule = require('../core/menu_module.js').MenuModule; var ViewController = require('../core/view_controller.js').ViewController; var messageArea = require('../core/message_area.js'); +var strUtil = require('../core/string_util.js'); //var msgDb = require('./database.js').dbs.message; var async = require('async'); @@ -23,6 +24,20 @@ function MessageAreaListModule(options) { var self = this; + if(_.isObject(this.menuConfig.config)) { + if(_.isString(this.menuConfig.config.entryFormat)) { + this.entryFormat = this.menuConfig.config.entryFormat; + } + } + + this.entryFormat = this.entryFormat || '( {areaId} ) - {name}'; + + this.menuMethods = { + changeArea : function(formData, extraArgs) { + console.log(formData) + } + }; + } require('util').inherits(MessageAreaListModule, MenuModule); @@ -62,8 +77,7 @@ MessageAreaListModule.prototype.mciReady = function(mciData, cb) { var areaList = []; messageAreas.forEach(function entry(msgArea) { - // :TODO: make this formattable/themable - areaList.push(msgArea.areaId + ' - ' + msgArea.name); + areaList.push(strUtil.format(self.entryFormat, msgArea)); }); console.log(areaList)