Merge pull request #67 from apamment/master
Msg area next/prev updated to use findIndex
This commit is contained in:
commit
34b72d5040
|
@ -80,33 +80,43 @@ function nextMenu(callingMenu) {
|
||||||
|
|
||||||
function prevConf(callingMenu) {
|
function prevConf(callingMenu) {
|
||||||
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||||
let prev_tag = confs[confs.length - 1].confTag;
|
|
||||||
for (var i=0;i<confs.length;i++) {
|
let curr_idx = confs.findIndex((e) => {
|
||||||
if (confs[i].confTag === callingMenu.client.user.properties.message_conf_tag) {
|
if (e.confTag === callingMenu.client.user.properties.message_conf_tag) {
|
||||||
messageArea.changeMessageConference(callingMenu.client, prev_tag, err => {
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (curr_idx === 0) {
|
||||||
|
curr_idx = confs.length;
|
||||||
|
}
|
||||||
|
messageArea.changeMessageConference(callingMenu.client, confs[curr_idx - 1].confTag, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
let prevMenu = callingMenu.client.menuStack.pop();
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
prevMenu.instance.leave();
|
prevMenu.instance.leave();
|
||||||
callingMenu.client.menuStack.goto(prevMenu.name);
|
callingMenu.client.menuStack.goto(prevMenu.name);
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
prev_tag = confs[i].confTag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextConf(callingMenu) {
|
function nextConf(callingMenu) {
|
||||||
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
const confs = messageArea.getSortedAvailMessageConferences(callingMenu.client);
|
||||||
let prev_tag = confs[0].confTag;
|
|
||||||
|
|
||||||
if (confs.length > 1) {
|
let curr_idx = confs.findIndex((e) => {
|
||||||
for (var i=1;i<confs.length;i++) {
|
if (e.confTag === callingMenu.client.user.properties.message_conf_tag) {
|
||||||
if (prev_tag === callingMenu.client.user.properties.message_conf_tag) {
|
return true;
|
||||||
messageArea.changeMessageConference(callingMenu.client, confs[i].confTag, err => {
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (curr_idx === confs.length - 1) {
|
||||||
|
curr_idx = -1;
|
||||||
|
}
|
||||||
|
messageArea.changeMessageConference(callingMenu.client, confs[curr_idx + 1].confTag, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
|
@ -115,73 +125,54 @@ function nextConf(callingMenu) {
|
||||||
let prevMenu = callingMenu.client.menuStack.pop();
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
prevMenu.instance.leave();
|
prevMenu.instance.leave();
|
||||||
callingMenu.client.menuStack.goto(prevMenu.name);
|
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) {
|
function prevArea(callingMenu) {
|
||||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
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++) {
|
let curr_idx = areas.findIndex((e) => {
|
||||||
if (areas[i].areaTag === callingMenu.client.user.properties.message_area_tag) {
|
if (e.areaTag === callingMenu.client.user.properties.message_area_tag) {
|
||||||
messageArea.changeMessageArea(callingMenu.client, prev_tag, err => {
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (curr_idx === 0) {
|
||||||
|
curr_idx = areas.length;
|
||||||
|
}
|
||||||
|
messageArea.changeMessageArea(callingMenu.client, areas[curr_idx - 1].areaTag, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
let prevMenu = callingMenu.client.menuStack.pop();
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
prevMenu.instance.leave();
|
prevMenu.instance.leave();
|
||||||
callingMenu.client.menuStack.goto(prevMenu.name);
|
callingMenu.client.menuStack.goto(prevMenu.name);
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
prev_tag = areas[i].areaTag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextArea(callingMenu) {
|
function nextArea(callingMenu) {
|
||||||
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
const areas = messageArea.getSortedAvailMessageAreasByConfTag(callingMenu.client.user.properties.message_conf_tag);
|
||||||
let prev_tag = areas[0].areaTag;
|
|
||||||
|
|
||||||
if (areas.length > 1) {
|
let curr_idx = areas.findIndex((e) => {
|
||||||
for (var i=1;i<areas.length;i++) {
|
if (e.areaTag === callingMenu.client.user.properties.message_area_tag) {
|
||||||
if (prev_tag === callingMenu.client.user.properties.message_area_tag) {
|
return true;
|
||||||
messageArea.changeMessageArea(callingMenu.client, areas[i].areaTag, err => {
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (curr_idx === areas.length - 1) {
|
||||||
|
curr_idx = -1;
|
||||||
|
}
|
||||||
|
messageArea.changeMessageArea(callingMenu.client, areas[curr_idx + 1].areaTag, err => {
|
||||||
if (err) {
|
if (err) {
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
let prevMenu = callingMenu.client.menuStack.pop();
|
let prevMenu = callingMenu.client.menuStack.pop();
|
||||||
prevMenu.instance.leave();
|
prevMenu.instance.leave();
|
||||||
callingMenu.client.menuStack.goto(prevMenu.name);
|
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