* New string util method: format()
* Minor work on area list -- WIP!
This commit is contained in:
parent
aa820ac0b5
commit
aaac4e884b
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -287,8 +287,17 @@
|
|||
"mci" : {
|
||||
"LV1" : {
|
||||
"widht" : 30,
|
||||
"height" : 10
|
||||
"height" : 10,
|
||||
"focus" : true
|
||||
}
|
||||
},
|
||||
"submit" : {
|
||||
"*" : [
|
||||
{
|
||||
"value" : null,
|
||||
"action" : "@method:changeArea"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue