Use sane switch style :)
This commit is contained in:
parent
f024527db1
commit
33f0553ea9
72
core/fse.js
72
core/fse.js
|
@ -550,26 +550,26 @@ function FullScreenEditorModule(options) {
|
|||
function setInitialData(callback) {
|
||||
|
||||
switch(self.editorMode) {
|
||||
case 'view' :
|
||||
if(self.message) {
|
||||
self.initHeaderViewMode();
|
||||
self.initFooterViewMode();
|
||||
case 'view' :
|
||||
if(self.message) {
|
||||
self.initHeaderViewMode();
|
||||
self.initFooterViewMode();
|
||||
|
||||
var bodyMessageView = self.viewControllers.body.getView(1);
|
||||
if(bodyMessageView && _.has(self, 'message.message')) {
|
||||
//self.setBodyMessageViewText();
|
||||
bodyMessageView.setText(cleanControlCodes(self.message.message));
|
||||
var bodyMessageView = self.viewControllers.body.getView(1);
|
||||
if(bodyMessageView && _.has(self, 'message.message')) {
|
||||
//self.setBodyMessageViewText();
|
||||
bodyMessageView.setText(cleanControlCodes(self.message.message));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'edit' :
|
||||
self.viewControllers.header.getView(1).setText(self.client.user.username); // from
|
||||
case 'edit' :
|
||||
self.viewControllers.header.getView(1).setText(self.client.user.username); // from
|
||||
|
||||
if(self.replyToMessage) {
|
||||
self.initHeaderReplyEditMode();
|
||||
}
|
||||
break;
|
||||
if(self.replyToMessage) {
|
||||
self.initHeaderReplyEditMode();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
callback(null);
|
||||
|
@ -577,14 +577,14 @@ function FullScreenEditorModule(options) {
|
|||
function setInitialFocus(callback) {
|
||||
|
||||
switch(self.editorMode) {
|
||||
case 'edit' :
|
||||
self.switchToHeader();
|
||||
break;
|
||||
case 'edit' :
|
||||
self.switchToHeader();
|
||||
break;
|
||||
|
||||
case 'view' :
|
||||
self.switchToFooter();
|
||||
//self.observeViewPosition();
|
||||
break;
|
||||
case 'view' :
|
||||
self.switchToFooter();
|
||||
//self.observeViewPosition();
|
||||
break;
|
||||
}
|
||||
|
||||
callback(null);
|
||||
|
@ -885,21 +885,21 @@ function FullScreenEditorModule(options) {
|
|||
console.log(err)
|
||||
} else {
|
||||
switch(self.footerMode) {
|
||||
case 'editor' :
|
||||
if(!_.isUndefined(self.viewControllers.footerEditorMenu)) {
|
||||
//self.viewControllers.footerEditorMenu.setFocus(false);
|
||||
self.viewControllers.footerEditorMenu.detachClientEvents();
|
||||
}
|
||||
self.viewControllers.body.switchFocus(1);
|
||||
self.observeEditorEvents();
|
||||
break;
|
||||
case 'editor' :
|
||||
if(!_.isUndefined(self.viewControllers.footerEditorMenu)) {
|
||||
//self.viewControllers.footerEditorMenu.setFocus(false);
|
||||
self.viewControllers.footerEditorMenu.detachClientEvents();
|
||||
}
|
||||
self.viewControllers.body.switchFocus(1);
|
||||
self.observeEditorEvents();
|
||||
break;
|
||||
|
||||
case 'editorMenu' :
|
||||
self.viewControllers.body.setFocus(false);
|
||||
self.viewControllers.footerEditorMenu.switchFocus(1);
|
||||
break;
|
||||
case 'editorMenu' :
|
||||
self.viewControllers.body.setFocus(false);
|
||||
self.viewControllers.footerEditorMenu.switchFocus(1);
|
||||
break;
|
||||
|
||||
default : throw new Error('Unexpected mode');
|
||||
default : throw new Error('Unexpected mode');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -43,17 +43,17 @@ module.exports = class KeyEntryView extends View {
|
|||
|
||||
setPropertyValue(propName, propValue) {
|
||||
switch(propName) {
|
||||
case 'eatTabKey' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
this.eatTabKey = propValue;
|
||||
}
|
||||
break;
|
||||
case 'eatTabKey' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
this.eatTabKey = propValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'caseInsensitive' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
this.caseInsensitive = propValue;
|
||||
}
|
||||
break;
|
||||
case 'caseInsensitive' :
|
||||
if(_.isBoolean(propValue)) {
|
||||
this.caseInsensitive = propValue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
super.setPropertyValue(propName, propValue);
|
||||
|
|
|
@ -175,40 +175,40 @@ function handleAction(client, formData, conf, cb) {
|
|||
assert(_.isObject(actionAsset));
|
||||
|
||||
switch(actionAsset.type) {
|
||||
case 'method' :
|
||||
case 'systemMethod' :
|
||||
if(_.isString(actionAsset.location)) {
|
||||
return callModuleMenuMethod(
|
||||
client,
|
||||
actionAsset,
|
||||
paths.join(Config.paths.mods, actionAsset.location),
|
||||
formData,
|
||||
conf.extraArgs,
|
||||
cb);
|
||||
} else if('systemMethod' === actionAsset.type) {
|
||||
// :TODO: Need to pass optional args here -- conf.extraArgs and args between e.g. ()
|
||||
// :TODO: Probably better as system_method.js
|
||||
return callModuleMenuMethod(
|
||||
client,
|
||||
actionAsset,
|
||||
paths.join(__dirname, 'system_menu_method.js'),
|
||||
formData,
|
||||
conf.extraArgs,
|
||||
cb);
|
||||
} else {
|
||||
// local to current module
|
||||
const currentModule = client.currentMenuModule;
|
||||
if(_.isFunction(currentModule.menuMethods[actionAsset.asset])) {
|
||||
return currentModule.menuMethods[actionAsset.asset](formData, conf.extraArgs, cb);
|
||||
case 'method' :
|
||||
case 'systemMethod' :
|
||||
if(_.isString(actionAsset.location)) {
|
||||
return callModuleMenuMethod(
|
||||
client,
|
||||
actionAsset,
|
||||
paths.join(Config.paths.mods, actionAsset.location),
|
||||
formData,
|
||||
conf.extraArgs,
|
||||
cb);
|
||||
} else if('systemMethod' === actionAsset.type) {
|
||||
// :TODO: Need to pass optional args here -- conf.extraArgs and args between e.g. ()
|
||||
// :TODO: Probably better as system_method.js
|
||||
return callModuleMenuMethod(
|
||||
client,
|
||||
actionAsset,
|
||||
paths.join(__dirname, 'system_menu_method.js'),
|
||||
formData,
|
||||
conf.extraArgs,
|
||||
cb);
|
||||
} else {
|
||||
// local to current module
|
||||
const currentModule = client.currentMenuModule;
|
||||
if(_.isFunction(currentModule.menuMethods[actionAsset.asset])) {
|
||||
return currentModule.menuMethods[actionAsset.asset](formData, conf.extraArgs, cb);
|
||||
}
|
||||
|
||||
const err = new Error('Method does not exist');
|
||||
client.log.warn( { method : actionAsset.asset }, err.message);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
const err = new Error('Method does not exist');
|
||||
client.log.warn( { method : actionAsset.asset }, err.message);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
case 'menu' :
|
||||
return client.currentMenuModule.gotoMenu(actionAsset.asset, { formData : formData, extraArgs : conf.extraArgs }, cb );
|
||||
case 'menu' :
|
||||
return client.currentMenuModule.gotoMenu(actionAsset.asset, { formData : formData, extraArgs : conf.extraArgs }, cb );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,28 +227,28 @@ function handleNext(client, nextSpec, conf, cb) {
|
|||
|
||||
// :TODO: DRY this with handleAction()
|
||||
switch(nextAsset.type) {
|
||||
case 'method' :
|
||||
case 'systemMethod' :
|
||||
if(_.isString(nextAsset.location)) {
|
||||
return callModuleMenuMethod(client, nextAsset, paths.join(Config.paths.mods, nextAsset.location), {}, extraArgs, cb);
|
||||
} else if('systemMethod' === nextAsset.type) {
|
||||
// :TODO: see other notes about system_menu_method.js here
|
||||
return callModuleMenuMethod(client, nextAsset, paths.join(__dirname, 'system_menu_method.js'), {}, extraArgs, cb);
|
||||
} else {
|
||||
// local to current module
|
||||
const currentModule = client.currentMenuModule;
|
||||
if(_.isFunction(currentModule.menuMethods[nextAsset.asset])) {
|
||||
const formData = {}; // we don't have any
|
||||
return currentModule.menuMethods[nextAsset.asset]( formData, extraArgs, cb );
|
||||
case 'method' :
|
||||
case 'systemMethod' :
|
||||
if(_.isString(nextAsset.location)) {
|
||||
return callModuleMenuMethod(client, nextAsset, paths.join(Config.paths.mods, nextAsset.location), {}, extraArgs, cb);
|
||||
} else if('systemMethod' === nextAsset.type) {
|
||||
// :TODO: see other notes about system_menu_method.js here
|
||||
return callModuleMenuMethod(client, nextAsset, paths.join(__dirname, 'system_menu_method.js'), {}, extraArgs, cb);
|
||||
} else {
|
||||
// local to current module
|
||||
const currentModule = client.currentMenuModule;
|
||||
if(_.isFunction(currentModule.menuMethods[nextAsset.asset])) {
|
||||
const formData = {}; // we don't have any
|
||||
return currentModule.menuMethods[nextAsset.asset]( formData, extraArgs, cb );
|
||||
}
|
||||
|
||||
const err = new Error('Method does not exist');
|
||||
client.log.warn( { method : nextAsset.asset }, err.message);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
const err = new Error('Method does not exist');
|
||||
client.log.warn( { method : nextAsset.asset }, err.message);
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
case 'menu' :
|
||||
return client.currentMenuModule.gotoMenu(nextAsset.asset, { extraArgs : extraArgs }, cb );
|
||||
case 'menu' :
|
||||
return client.currentMenuModule.gotoMenu(nextAsset.asset, { extraArgs : extraArgs }, cb );
|
||||
}
|
||||
|
||||
const err = new Error('Invalid asset type for "next"');
|
||||
|
|
|
@ -128,11 +128,12 @@ MenuView.prototype.setItemSpacing = function(itemSpacing) {
|
|||
|
||||
MenuView.prototype.setPropertyValue = function(propName, value) {
|
||||
switch(propName) {
|
||||
case 'itemSpacing' : this.setItemSpacing(value); break;
|
||||
case 'items' : this.setItems(value); break;
|
||||
case 'focusItems' : this.setFocusItems(value); break;
|
||||
case 'hotKeys' : this.setHotKeys(value); break;
|
||||
case 'hotKeySubmit' : this.hotKeySubmit = value; break;
|
||||
case 'itemSpacing' : this.setItemSpacing(value); break;
|
||||
case 'items' : this.setItems(value); break;
|
||||
case 'focusItems' : this.setFocusItems(value); break;
|
||||
case 'hotKeys' : this.setHotKeys(value); break;
|
||||
case 'hotKeySubmit' : this.hotKeySubmit = value; break;
|
||||
case 'justify' : this.justify = value; break;
|
||||
}
|
||||
|
||||
MenuView.super_.prototype.setPropertyValue.call(this, propName, value);
|
||||
|
|
|
@ -1024,8 +1024,8 @@ MultiLineEditTextView.prototype.getData = function() {
|
|||
|
||||
MultiLineEditTextView.prototype.setPropertyValue = function(propName, value) {
|
||||
switch(propName) {
|
||||
case 'mode' : this.mode = value; break;
|
||||
case 'autoScroll' : this.autoScroll = value; break;
|
||||
case 'mode' : this.mode = value; break;
|
||||
case 'autoScroll' : this.autoScroll = value; break;
|
||||
}
|
||||
|
||||
MultiLineEditTextView.super_.prototype.setPropertyValue.call(this, propName, value);
|
||||
|
|
|
@ -35,86 +35,86 @@ function stylizeString(s, style) {
|
|||
var stylized = '';
|
||||
|
||||
switch(style) {
|
||||
// None/normal
|
||||
case 'normal' :
|
||||
case 'N' :
|
||||
return s;
|
||||
// None/normal
|
||||
case 'normal' :
|
||||
case 'N' :
|
||||
return s;
|
||||
|
||||
// UPPERCASE
|
||||
case 'upper' :
|
||||
case 'U' :
|
||||
return s.toUpperCase();
|
||||
// UPPERCASE
|
||||
case 'upper' :
|
||||
case 'U' :
|
||||
return s.toUpperCase();
|
||||
|
||||
// lowercase
|
||||
case 'lower' :
|
||||
case 'l' :
|
||||
return s.toLowerCase();
|
||||
// lowercase
|
||||
case 'lower' :
|
||||
case 'l' :
|
||||
return s.toLowerCase();
|
||||
|
||||
// Title Case
|
||||
case 'title' :
|
||||
case 'T' :
|
||||
return s.replace(/\w\S*/g, function onProperCaseChar(t) {
|
||||
return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase();
|
||||
});
|
||||
// Title Case
|
||||
case 'title' :
|
||||
case 'T' :
|
||||
return s.replace(/\w\S*/g, function onProperCaseChar(t) {
|
||||
return t.charAt(0).toUpperCase() + t.substr(1).toLowerCase();
|
||||
});
|
||||
|
||||
// fIRST lOWER
|
||||
case 'first lower' :
|
||||
case 'f' :
|
||||
return s.replace(/\w\S*/g, function onFirstLowerChar(t) {
|
||||
return t.charAt(0).toLowerCase() + t.substr(1).toUpperCase();
|
||||
});
|
||||
// fIRST lOWER
|
||||
case 'first lower' :
|
||||
case 'f' :
|
||||
return s.replace(/\w\S*/g, function onFirstLowerChar(t) {
|
||||
return t.charAt(0).toLowerCase() + t.substr(1).toUpperCase();
|
||||
});
|
||||
|
||||
// SMaLL VoWeLS
|
||||
case 'small vowels' :
|
||||
case 'v' :
|
||||
for(i = 0; i < len; ++i) {
|
||||
c = s[i];
|
||||
if(-1 !== VOWELS.indexOf(c)) {
|
||||
stylized += c.toLowerCase();
|
||||
} else {
|
||||
stylized += c.toUpperCase();
|
||||
// SMaLL VoWeLS
|
||||
case 'small vowels' :
|
||||
case 'v' :
|
||||
for(i = 0; i < len; ++i) {
|
||||
c = s[i];
|
||||
if(-1 !== VOWELS.indexOf(c)) {
|
||||
stylized += c.toLowerCase();
|
||||
} else {
|
||||
stylized += c.toUpperCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
return stylized;
|
||||
return stylized;
|
||||
|
||||
// bIg vOwELS
|
||||
case 'big vowels' :
|
||||
case 'V' :
|
||||
for(i = 0; i < len; ++i) {
|
||||
c = s[i];
|
||||
if(-1 !== VOWELS.indexOf(c)) {
|
||||
stylized += c.toUpperCase();
|
||||
} else {
|
||||
stylized += c.toLowerCase();
|
||||
// bIg vOwELS
|
||||
case 'big vowels' :
|
||||
case 'V' :
|
||||
for(i = 0; i < len; ++i) {
|
||||
c = s[i];
|
||||
if(-1 !== VOWELS.indexOf(c)) {
|
||||
stylized += c.toUpperCase();
|
||||
} else {
|
||||
stylized += c.toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
return stylized;
|
||||
return stylized;
|
||||
|
||||
// Small i's: DEMENTiA
|
||||
case 'small i' :
|
||||
case 'i' :
|
||||
return s.toUpperCase().replace(/I/g, 'i');
|
||||
// Small i's: DEMENTiA
|
||||
case 'small i' :
|
||||
case 'i' :
|
||||
return s.toUpperCase().replace(/I/g, 'i');
|
||||
|
||||
// mIxeD CaSE (random upper/lower)
|
||||
case 'mixed' :
|
||||
case 'M' :
|
||||
for(i = 0; i < len; i++) {
|
||||
if(Math.random() < 0.5) {
|
||||
stylized += s[i].toUpperCase();
|
||||
} else {
|
||||
stylized += s[i].toLowerCase();
|
||||
// mIxeD CaSE (random upper/lower)
|
||||
case 'mixed' :
|
||||
case 'M' :
|
||||
for(i = 0; i < len; i++) {
|
||||
if(Math.random() < 0.5) {
|
||||
stylized += s[i].toUpperCase();
|
||||
} else {
|
||||
stylized += s[i].toLowerCase();
|
||||
}
|
||||
}
|
||||
}
|
||||
return stylized;
|
||||
return stylized;
|
||||
|
||||
// l337 5p34k
|
||||
case 'l33t' :
|
||||
case '3' :
|
||||
for(i = 0; i < len; ++i) {
|
||||
c = SIMPLE_ELITE_MAP[s[i].toLowerCase()];
|
||||
stylized += c || s[i];
|
||||
}
|
||||
return stylized;
|
||||
// l337 5p34k
|
||||
case 'l33t' :
|
||||
case '3' :
|
||||
for(i = 0; i < len; ++i) {
|
||||
c = SIMPLE_ELITE_MAP[s[i].toLowerCase()];
|
||||
stylized += c || s[i];
|
||||
}
|
||||
return stylized;
|
||||
}
|
||||
|
||||
return s;
|
||||
|
@ -134,27 +134,27 @@ function pad(s, len, padChar, dir, stringSGR, padSGR, useRenderLen) {
|
|||
const padlen = len >= renderLen ? len - renderLen : 0;
|
||||
|
||||
switch(dir) {
|
||||
case 'L' :
|
||||
case 'left' :
|
||||
s = padSGR + new Array(padlen).join(padChar) + stringSGR + s;
|
||||
break;
|
||||
case 'L' :
|
||||
case 'left' :
|
||||
s = padSGR + new Array(padlen).join(padChar) + stringSGR + s;
|
||||
break;
|
||||
|
||||
case 'C' :
|
||||
case 'center' :
|
||||
case 'both' :
|
||||
{
|
||||
const right = Math.ceil(padlen / 2);
|
||||
const left = padlen - right;
|
||||
s = padSGR + new Array(left + 1).join(padChar) + stringSGR + s + padSGR + new Array(right + 1).join(padChar);
|
||||
}
|
||||
break;
|
||||
case 'C' :
|
||||
case 'center' :
|
||||
case 'both' :
|
||||
{
|
||||
const right = Math.ceil(padlen / 2);
|
||||
const left = padlen - right;
|
||||
s = padSGR + new Array(left + 1).join(padChar) + stringSGR + s + padSGR + new Array(right + 1).join(padChar);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'R' :
|
||||
case 'right' :
|
||||
s = stringSGR + s + padSGR + new Array(padlen).join(padChar);
|
||||
break;
|
||||
case 'R' :
|
||||
case 'right' :
|
||||
s = stringSGR + s + padSGR + new Array(padlen).join(padChar);
|
||||
break;
|
||||
|
||||
default : break;
|
||||
default : break;
|
||||
}
|
||||
|
||||
return stringSGR + s;
|
||||
|
|
|
@ -238,14 +238,14 @@ TextView.prototype.clearText = function() {
|
|||
|
||||
TextView.prototype.setPropertyValue = function(propName, value) {
|
||||
switch(propName) {
|
||||
case 'textMaskChar' : this.textMaskChar = value.substr(0, 1); break;
|
||||
case 'textOverflow' : this.textOverflow = value; break;
|
||||
case 'maxLength' : this.maxLength = parseInt(value, 10); break;
|
||||
case 'password' :
|
||||
if(true === value) {
|
||||
this.textMaskChar = this.client.currentTheme.helpers.getPasswordChar();
|
||||
}
|
||||
break;
|
||||
case 'textMaskChar' : this.textMaskChar = value.substr(0, 1); break;
|
||||
case 'textOverflow' : this.textOverflow = value; break;
|
||||
case 'maxLength' : this.maxLength = parseInt(value, 10); break;
|
||||
case 'password' :
|
||||
if(true === value) {
|
||||
this.textMaskChar = this.client.currentTheme.helpers.getPasswordChar();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -599,23 +599,23 @@ function displayThemedAsset(assetSpec, client, options, cb) {
|
|||
};
|
||||
|
||||
switch(artAsset.type) {
|
||||
case 'art' :
|
||||
displayThemeArt(dispOpts, function displayed(err, artData) {
|
||||
return cb(err, err ? null : { mciMap : artData.mciMap, height : artData.extraInfo.height } );
|
||||
});
|
||||
break;
|
||||
case 'art' :
|
||||
displayThemeArt(dispOpts, function displayed(err, artData) {
|
||||
return cb(err, err ? null : { mciMap : artData.mciMap, height : artData.extraInfo.height } );
|
||||
});
|
||||
break;
|
||||
|
||||
case 'method' :
|
||||
// :TODO: fetch & render via method
|
||||
break;
|
||||
case 'method' :
|
||||
// :TODO: fetch & render via method
|
||||
break;
|
||||
|
||||
case 'inline ' :
|
||||
// :TODO: think about this more in relation to themes, etc. How can this come
|
||||
// from a theme (with override from menu.json) ???
|
||||
// look @ client.currentTheme.inlineArt[name] -> menu/prompt[name]
|
||||
break;
|
||||
case 'inline ' :
|
||||
// :TODO: think about this more in relation to themes, etc. How can this come
|
||||
// from a theme (with override from menu.json) ???
|
||||
// look @ client.currentTheme.inlineArt[name] -> menu/prompt[name]
|
||||
break;
|
||||
|
||||
default :
|
||||
return cb(new Error('Unsupported art asset type: ' + artAsset.type));
|
||||
default :
|
||||
return cb(new Error('Unsupported art asset type: ' + artAsset.type));
|
||||
}
|
||||
}
|
|
@ -205,7 +205,7 @@ function wordWrapText(text, options) {
|
|||
switch(m[0].charAt(0)) {
|
||||
case ' ' :
|
||||
word += m[0];
|
||||
break;
|
||||
break;
|
||||
|
||||
case '\t' :
|
||||
//
|
||||
|
@ -218,7 +218,7 @@ function wordWrapText(text, options) {
|
|||
} else {
|
||||
word += m[0];
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
addWord();
|
||||
|
|
|
@ -58,10 +58,10 @@ function AreaViewFSEModule(options) {
|
|||
|
||||
// :TODO: Create methods for up/down vs using keyPressXXXXX
|
||||
switch(formData.key.name) {
|
||||
case 'down arrow' : bodyView.scrollDocumentUp(); break;
|
||||
case 'up arrow' : bodyView.scrollDocumentDown(); break;
|
||||
case 'page up' : bodyView.keyPressPageUp(); break;
|
||||
case 'page down' : bodyView.keyPressPageDown(); break;
|
||||
case 'down arrow' : bodyView.scrollDocumentUp(); break;
|
||||
case 'up arrow' : bodyView.scrollDocumentDown(); break;
|
||||
case 'page up' : bodyView.keyPressPageUp(); break;
|
||||
case 'page down' : bodyView.keyPressPageDown(); break;
|
||||
}
|
||||
|
||||
// :TODO: need to stop down/page down if doing so would push the last
|
||||
|
|
Loading…
Reference in New Issue