mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-07-23 19:20:41 +02:00
* MCI keys no longer consider view IDs as this implied order
* Converted all MCI keys in menu.json/etc., e.g. BN1ET2 -> BN1ET2 * Fix regression with prompt loading * 'age' property -> 'birthdate' * MaskEditView.getData() returns data with literals in place * Other minor changes
This commit is contained in:
parent
81e684cdcc
commit
735b572f9f
14 changed files with 93 additions and 32 deletions
|
@ -21,6 +21,12 @@ exports.MaskEditTextView = MaskEditTextView;
|
|||
// styleSGR2: Literals (focused)
|
||||
// styleSGR3: fillChar
|
||||
|
||||
//
|
||||
// :TODO:
|
||||
// * Hint, e.g. YYYY/MM/DD
|
||||
// * Return values with literals in place
|
||||
//
|
||||
|
||||
function MaskEditTextView(options) {
|
||||
options.acceptsFocus = miscUtil.valueWithDefault(options.acceptsFocus, true);
|
||||
options.acceptsInput = miscUtil.valueWithDefault(options.acceptsInput, true);
|
||||
|
@ -168,4 +174,22 @@ MaskEditTextView.prototype.setPropertyValue = function(propName, value) {
|
|||
}
|
||||
|
||||
MaskEditTextView.super_.prototype.setPropertyValue.call(this, propName, value);
|
||||
};
|
||||
};
|
||||
|
||||
MaskEditTextView.prototype.getData = function() {
|
||||
var rawData = MaskEditTextView.super_.prototype.getData.call(this);
|
||||
var data = '';
|
||||
|
||||
assert(rawData.length <= this.patternArray.length);
|
||||
|
||||
var p = 0;
|
||||
for(var i = 0; i < this.patternArray.length; ++i) {
|
||||
if(_.isRegExp(this.patternArray[i])) {
|
||||
data += rawData[p++];
|
||||
} else {
|
||||
data += this.patternArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
};
|
||||
|
|
|
@ -28,7 +28,6 @@ function MCIViewFactory(client) {
|
|||
}
|
||||
|
||||
MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
||||
|
||||
return {
|
||||
BN : Config.general.boardName,
|
||||
VL : 'ENiGMA½ v' + packageJson.version,
|
||||
|
@ -39,7 +38,8 @@ MCIViewFactory.prototype.getPredefinedViewLabel = function(code) {
|
|||
UG : _.values(this.client.user.groups).join(', '),
|
||||
UR : this.client.user.properties.real_name,
|
||||
LO : this.client.user.properties.location,
|
||||
UA : this.client.user.properties.age,
|
||||
UA : this.client.user.getAge().toString(),
|
||||
UB : this.client.user.getFormattedBirthDate('medium'),
|
||||
US : this.client.user.properties.sex,
|
||||
UE : this.client.user.properties.email_address,
|
||||
UW : this.client.user.properties.web_address,
|
||||
|
|
|
@ -102,8 +102,8 @@ function MenuModule(options) {
|
|||
// Prompts *must* have art. If it's missing it's an error
|
||||
// :TODO: allow inline prompts in the future, e.g. @inline:memberName -> { "memberName" : { "text" : "stuff", ... } }
|
||||
var promptConfig = self.menuConfig.promptConfig;
|
||||
self.displayArtAsset(promptConfig.art, function displayed(err, mciMap) {
|
||||
mciData.prompt = mciMap;
|
||||
self.displayArtAsset(promptConfig.art, function displayed(err, artData) {
|
||||
mciData.prompt = artData.mciMap;
|
||||
callback(err);
|
||||
});
|
||||
} else {
|
||||
|
|
|
@ -53,7 +53,7 @@ function getMenuConfig(name, cb) {
|
|||
function locatePromptConfig(promptJson, callback) {
|
||||
if(promptJson) {
|
||||
if(_.has(promptJson, [ 'prompts', menuConfig.prompt ])) {
|
||||
menuConfig.promptConfig = promptJson[menuConfig.prompt];
|
||||
menuConfig.promptConfig = promptJson.prompts[menuConfig.prompt];
|
||||
} else {
|
||||
callback(new Error('No prompt entry for \'' + menuConfig.prompt + '\''));
|
||||
return;
|
||||
|
@ -138,9 +138,10 @@ function getFormConfigByIDAndMap(menuConfig, formId, mciMap, cb) {
|
|||
}
|
||||
|
||||
var formForId = menuConfig.form[formId];
|
||||
var mciReqKey = _.pluck(_.sortBy(mciMap, 'code'), 'code').join('');
|
||||
|
||||
var mciReqKey = _.sortBy(Object.keys(mciMap), String).join('');
|
||||
Log.trace( { mciKey : mciReqKey }, 'Looking for MCI configuration key');
|
||||
|
||||
if(_.isObject(formForId[mciReqKey])) {
|
||||
cb(null, formForId[mciReqKey]);
|
||||
return;
|
||||
|
@ -151,7 +152,7 @@ function getFormConfigByIDAndMap(menuConfig, formId, mciMap, cb) {
|
|||
return;
|
||||
}
|
||||
|
||||
cb(new Error('No matching form configuration found'));
|
||||
cb(new Error('No matching form configuration found for key \'' + mciReqKey + '\''));
|
||||
}
|
||||
|
||||
function handleAction(client, formData, conf) {
|
||||
|
|
|
@ -1037,7 +1037,7 @@ MultiLineEditTextView.prototype.setFocus = function(focused) {
|
|||
};
|
||||
|
||||
MultiLineEditTextView.prototype.setText = function(text) {
|
||||
text = require('fs').readFileSync('/home/bashby/Downloads/test_text.txt', { encoding : 'utf-8'});
|
||||
//text = require('fs').readFileSync('/home/nuskooler/Downloads/test_text.txt', { encoding : 'utf-8'});
|
||||
|
||||
this.insertRawText(text);
|
||||
this.cursorEndOfDocument();
|
||||
|
|
|
@ -404,7 +404,7 @@ function parseCommand(bufs, i, event) {
|
|||
//return COMMAND_IMPLS[command](bufs, i + 1, event);
|
||||
return handler(bufs, i + 1, event);
|
||||
} else {
|
||||
assert(2 == bufs.length); // IAC + COMMAND
|
||||
assert(2 == bufs.length, 'Expected bufs length of 2, got ' + bufs.length); // IAC + COMMAND
|
||||
event.buf = bufs.splice(0, 2).toBuffer();
|
||||
return event;
|
||||
}
|
||||
|
|
|
@ -152,4 +152,4 @@ TextView.prototype.setPropertyValue = function(propName, value) {
|
|||
}
|
||||
|
||||
TextView.super_.prototype.setPropertyValue.call(this, propName, value);
|
||||
};
|
||||
};
|
||||
|
|
27
core/user.js
27
core/user.js
|
@ -319,6 +319,33 @@ User.prototype.persistProperties = function(cb) {
|
|||
});
|
||||
};
|
||||
|
||||
// :TODO: A general purpose date/time formatting class or lib would be better here....
|
||||
User.prototype.getFormattedBirthDate = function(style) {
|
||||
style = style || 'medium';
|
||||
|
||||
switch(style) {
|
||||
|
||||
case 'medium' :
|
||||
return _.has(this.properties, 'birthdate') ?
|
||||
new Date(Date.parse(this.properties.birthdate)).toJSON().slice(0, 10) :
|
||||
null;
|
||||
}
|
||||
};
|
||||
|
||||
User.prototype.getAge = function() {
|
||||
var birthDate = new Date(Date.parse(this.properties.birthdate));
|
||||
if(!isNaN(birthDate)) {
|
||||
var today = new Date();
|
||||
var age = today.getFullYear() - birthDate.getFullYear();
|
||||
var m = today.getMonth() - birthDate.getMonth();
|
||||
if(m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {
|
||||
age--;
|
||||
}
|
||||
|
||||
return age;
|
||||
}
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Exported methods
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -628,7 +628,7 @@ ViewController.prototype.getFormData = function() {
|
|||
}
|
||||
}
|
||||
} catch(e) {
|
||||
self.client.log.error(e); // :TODO: Log better ;)
|
||||
this.client.log.error(e); // :TODO: Log better ;)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue