Merge pull request #66 from apamment/master
Message Areas/Conference Next / Prev
This commit is contained in:
commit
e7e6f1ea54
|
@ -5,6 +5,7 @@
|
||||||
const Config = require('./config.js').config;
|
const Config = require('./config.js').config;
|
||||||
const Log = require('./logger.js').log;
|
const Log = require('./logger.js').log;
|
||||||
const getMessageAreaByTag = require('./message_area.js').getMessageAreaByTag;
|
const getMessageAreaByTag = require('./message_area.js').getMessageAreaByTag;
|
||||||
|
const getMessageConferenceByTag = require('./message_area.js').getMessageConferenceByTag;
|
||||||
const clientConnections = require('./client_connections.js');
|
const clientConnections = require('./client_connections.js');
|
||||||
const sysProp = require('./system_property.js');
|
const sysProp = require('./system_property.js');
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ function getPredefinedMCIValue(client, code) {
|
||||||
|
|
||||||
// :TODO: SysOp username
|
// :TODO: SysOp username
|
||||||
// :TODO: SysOp real name
|
// :TODO: SysOp real name
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Current user / session
|
// Current user / session
|
||||||
|
@ -59,16 +60,20 @@ function getPredefinedMCIValue(client, code) {
|
||||||
|
|
||||||
MS : function accountCreated() { return moment(client.user.properties.account_created).format(client.currentTheme.helpers.getDateFormat()); },
|
MS : function accountCreated() { return moment(client.user.properties.account_created).format(client.currentTheme.helpers.getDateFormat()); },
|
||||||
CS : function currentStatus() { return client.currentStatus; },
|
CS : function currentStatus() { return client.currentStatus; },
|
||||||
|
|
||||||
MD : function currentMenuDescription() {
|
MD : function currentMenuDescription() {
|
||||||
return _.has(client, 'currentMenuModule.menuConfig.desc') ? client.currentMenuModule.menuConfig.desc : '';
|
return _.has(client, 'currentMenuModule.menuConfig.desc') ? client.currentMenuModule.menuConfig.desc : '';
|
||||||
},
|
},
|
||||||
|
|
||||||
MA : function messageAreaName() {
|
MA : function messageAreaName() {
|
||||||
const area = getMessageAreaByTag(client.user.properties.message_area_tag);
|
const area = getMessageAreaByTag(client.user.properties.message_area_tag);
|
||||||
return area ? area.name : '';
|
return area ? area.name : '';
|
||||||
},
|
},
|
||||||
|
MC : function messageConfName() {
|
||||||
|
const conf = getMessageConferenceByTag(client.user.properties.message_conf_tag);
|
||||||
|
return conf ? conf.name : '';
|
||||||
|
},
|
||||||
|
|
||||||
ML : function messageAreaDescription() {
|
ML : function messageAreaDescription() {
|
||||||
const area = getMessageAreaByTag(client.user.properties.message_area_tag);
|
const area = getMessageAreaByTag(client.user.properties.message_area_tag);
|
||||||
return area ? area.desc : '';
|
return area ? area.desc : '';
|
||||||
|
@ -119,7 +124,7 @@ function getPredefinedMCIValue(client, code) {
|
||||||
// Special handling for XY
|
// Special handling for XY
|
||||||
//
|
//
|
||||||
XY : function xyHack() { return; /* nothing */ },
|
XY : function xyHack() { return; /* nothing */ },
|
||||||
|
|
||||||
}[code](); // :TODO: Just call toString() here and remove above - DRY
|
}[code](); // :TODO: Just call toString() here and remove above - DRY
|
||||||
|
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
const removeClient = require('./client_connections.js').removeClient;
|
const removeClient = require('./client_connections.js').removeClient;
|
||||||
const ansiNormal = require('./ansi_term.js').normal;
|
const ansiNormal = require('./ansi_term.js').normal;
|
||||||
const userLogin = require('./user_login.js').userLogin;
|
const userLogin = require('./user_login.js').userLogin;
|
||||||
|
const messageArea = require('./message_area.js');
|
||||||
|
|
||||||
// deps
|
// deps
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
|
@ -14,6 +15,10 @@ exports.login = login;
|
||||||
exports.logoff = logoff;
|
exports.logoff = logoff;
|
||||||
exports.prevMenu = prevMenu;
|
exports.prevMenu = prevMenu;
|
||||||
exports.nextMenu = nextMenu;
|
exports.nextMenu = nextMenu;
|
||||||
|
exports.prevConf = prevConf;
|
||||||
|
exports.nextConf = nextConf;
|
||||||
|
exports.prevArea = prevArea;
|
||||||
|
exports.nextArea = nextArea;
|
||||||
|
|
||||||
function login(callingMenu, formData) {
|
function login(callingMenu, formData) {
|
||||||
|
|
||||||
|
@ -47,7 +52,7 @@ function logoff(callingMenu) {
|
||||||
//
|
//
|
||||||
client.term.write(
|
client.term.write(
|
||||||
ansiNormal() + '\n' +
|
ansiNormal() + '\n' +
|
||||||
iconv.decode(require('crypto').randomBytes(Math.floor(Math.random() * 65) + 20), client.term.outputEncoding) +
|
iconv.decode(require('crypto').randomBytes(Math.floor(Math.random() * 65) + 20), client.term.outputEncoding) +
|
||||||
'NO CARRIER', null, () => {
|
'NO CARRIER', null, () => {
|
||||||
|
|
||||||
// after data is written, disconnect & remove the client
|
// after data is written, disconnect & remove the client
|
||||||
|
@ -72,3 +77,111 @@ function nextMenu(callingMenu) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function prevConf(callingMenu) {
|
||||||
|
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||||
|
let prev_tag = confs[confs.length - 1].confTag;
|
||||||
|
for (var i=0;i<confs.length;i++) {
|
||||||
|
if (confs[i].confTag === callingMenu.client.user.properties.message_conf_tag) {
|
||||||
|
messageArea.changeMessageConference(callingMenu.client, prev_tag, err => {
|
||||||
|
if (err) {
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
|
prevMenu.instance.leave();
|
||||||
|
callingMenu.client.menuStack.goto(prevMenu.name);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
prev_tag = confs[i].confTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextConf(callingMenu) {
|
||||||
|
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||||
|
let prev_tag = confs[0].confTag;
|
||||||
|
|
||||||
|
if (confs.length > 1) {
|
||||||
|
for (var i=1;i<confs.length;i++) {
|
||||||
|
if (prev_tag === callingMenu.client.user.properties.message_conf_tag) {
|
||||||
|
messageArea.changeMessageConference(callingMenu.client, confs[i].confTag, err => {
|
||||||
|
if (err) {
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
|
prevMenu.instance.leave();
|
||||||
|
callingMenu.client.menuStack.goto(prevMenu.name);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
prev_tag = confs[i].confTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messageArea.changeMessageConference(callingMenu.client, confs[0].confTag, err => {
|
||||||
|
if (err) {
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
|
prevMenu.instance.leave();
|
||||||
|
callingMenu.client.menuStack.goto(prevMenu.name);
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function prevArea(callingMenu) {
|
||||||
|
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||||
|
let prev_tag = areas[areas.length - 1].areaTag;
|
||||||
|
for (var i=0;i<areas.length;i++) {
|
||||||
|
if (areas[i].areaTag === callingMenu.client.user.properties.message_area_tag) {
|
||||||
|
messageArea.changeMessageArea(callingMenu.client, prev_tag, err => {
|
||||||
|
if (err) {
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
|
prevMenu.instance.leave();
|
||||||
|
callingMenu.client.menuStack.goto(prevMenu.name);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
prev_tag = areas[i].areaTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function nextArea(callingMenu) {
|
||||||
|
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||||
|
let prev_tag = areas[0].areaTag;
|
||||||
|
|
||||||
|
if (areas.length > 1) {
|
||||||
|
for (var i=1;i<areas.length;i++) {
|
||||||
|
if (prev_tag === callingMenu.client.user.properties.message_area_tag) {
|
||||||
|
messageArea.changeMessageArea(callingMenu.client, areas[i].areaTag, err => {
|
||||||
|
if (err) {
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
|
prevMenu.instance.leave();
|
||||||
|
callingMenu.client.menuStack.goto(prevMenu.name);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
prev_tag = areas[i].areaTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
messageArea.changeMessageArea(callingMenu.client, areas[0].areaTag, err => {
|
||||||
|
if (err) {
|
||||||
|
//...
|
||||||
|
}
|
||||||
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
|
prevMenu.instance.leave();
|
||||||
|
callingMenu.client.menuStack.goto(prevMenu.name);
|
||||||
|
return;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue