Skip to content

Commit 509ef0e

Browse files
committed
Had duplicated 'util' object; moved and fixed en route to #164
1 parent 25c9e93 commit 509ef0e

1 file changed

Lines changed: 74 additions & 81 deletions

File tree

load/dmbase.js

Lines changed: 74 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -27,87 +27,6 @@ msg_base = {
2727
* signify that it was at this menu
2828
*/
2929
log_header : "dDOC Read menu command: ",
30-
/*
31-
* summary:
32-
* Sub-object for various utility methods whose needs are becoming
33-
* apparent at this later date for message functionality
34-
*/
35-
util : {
36-
/*
37-
* summary:
38-
* Method remaps message start through finish for a room/sub-board
39-
* into an array that skips deleted message slots and gives us a
40-
* set of indices that are more easily utilized at base 1
41-
* mBase:
42-
* Base that we are currently working with
43-
* return:
44-
* Array of valid messages
45-
*
46-
* NOTE: We might have to configure this to pass back a valid new
47-
* 'current' index since we're remapping the whole lot of 'em
48-
*/
49-
remap_message_indices : function(mBase) {
50-
var msgMap = new Array(), curHdr = new Object();
51-
var curPtr = 0;
52-
53-
if (!mBase.is_open()) {
54-
if (userSettings.debug.message_scan) {
55-
console.putmsg(cyan + "Opening " + mBase.cfg.name + " for" +
56-
" message mapping. . .\n");
57-
}
58-
try {
59-
mBase.open();
60-
} catch (e) {
61-
throw new docIface.dDocException("remap_message_indices" +
62-
"() Exception", e.message, 1);
63-
}
64-
}
65-
66-
if (userSettings.debug.message_scan) {
67-
console.putmsg(yellow + "Remapping:\n");
68-
}
69-
for (var ndx = mBase.first_msg; ndx <= mBase.last_msg; ndx++) {
70-
if (userSettings.debug.message_scan) {
71-
console.clearline();
72-
}
73-
74-
try {
75-
curHdr = mBase.get_msg_header(ndx);
76-
} catch (e) {
77-
console.putmsg("Exception getting header: " + e.message +
78-
"\n");
79-
mBase.close();
80-
throw new docIface.dDocException("remap_message_indices" +
81-
"() Exception", e.message, 2);
82-
}
83-
84-
if ((curHdr == null) || (curHdr.attr&MSG_DELETED)) {
85-
continue; //skip this shit, we don't want this indexed
86-
} else {
87-
if (userSettings.debug.message_scan) {
88-
console.putmsg(yellow + high_intensity + ndx + " to " +
89-
curPtr);
90-
}
91-
msgMap[curPtr++] = ndx;
92-
}
93-
}
94-
95-
if (msgMap.length == 0) {
96-
console.putmsg(red + "No messages found for mapping\n");
97-
throw new docIface.dDocException("remap_message_indices()" +
98-
" Exception", "No messages in " + mBase.cfg.name +
99-
" for mapping!", 3);
100-
}
101-
102-
if (userSettings.debug.message_scan) {
103-
console.putmsg(green + "Returning message mapping: " + msgMap +
104-
"\nFor base: " + mBase.cfg.name + "\n");
105-
}
106-
107-
mBase.close();
108-
return msgMap;
109-
}
110-
},
11130
/*
11231
* summary:
11332
* Sub-object representing the message read command menu
@@ -309,6 +228,80 @@ msg_base = {
309228
* messages
310229
*/
311230
util : {
231+
/*
232+
* summary:
233+
* Method remaps message start through finish for a room/sub-board
234+
* into an array that skips deleted message slots and gives us a
235+
* set of indices that are more easily utilized at base 1
236+
* mBase:
237+
* Base that we are currently working with
238+
* return:
239+
* Array of valid messages
240+
*
241+
* NOTE: We might have to configure this to pass back a valid new
242+
* 'current' index since we're remapping the whole lot of 'em
243+
*/
244+
remap_message_indices : function(mBase) {
245+
var msgMap = new Array(), curHdr = new Object();
246+
var curPtr = 0;
247+
248+
if (!mBase.is_open()) {
249+
if (userSettings.debug.message_scan) {
250+
console.putmsg(cyan + "Opening " + mBase.cfg.name + " for" +
251+
" message mapping. . .\n");
252+
}
253+
try {
254+
mBase.open();
255+
} catch (e) {
256+
throw new docIface.dDocException("remap_message_indices" +
257+
"() Exception", e.message, 1);
258+
}
259+
}
260+
261+
if (userSettings.debug.message_scan) {
262+
console.putmsg(yellow + "Remapping:\n");
263+
}
264+
for (var ndx = mBase.first_msg; ndx <= mBase.last_msg; ndx++) {
265+
if (userSettings.debug.message_scan) {
266+
console.clearline();
267+
}
268+
269+
try {
270+
curHdr = mBase.get_msg_header(ndx);
271+
} catch (e) {
272+
console.putmsg("Exception getting header: " + e.message +
273+
"\n");
274+
mBase.close();
275+
throw new docIface.dDocException("remap_message_indices" +
276+
"() Exception", e.message, 2);
277+
}
278+
279+
if ((curHdr == null) || (curHdr.attr&MSG_DELETED)) {
280+
continue; //skip this shit, we don't want this indexed
281+
} else {
282+
if (userSettings.debug.message_scan) {
283+
console.putmsg(yellow + high_intensity + ndx + " to " +
284+
curPtr);
285+
}
286+
msgMap[curPtr++] = ndx;
287+
}
288+
}
289+
290+
if (msgMap.length == 0) {
291+
console.putmsg(red + "No messages found for mapping\n");
292+
throw new docIface.dDocException("remap_message_indices()" +
293+
" Exception", "No messages in " + mBase.cfg.name +
294+
" for mapping!", 3);
295+
}
296+
297+
if (userSettings.debug.message_scan) {
298+
console.putmsg(green + "Returning message mapping: " + msgMap +
299+
"\nFor base: " + mBase.cfg.name + "\n");
300+
}
301+
302+
mBase.close();
303+
return msgMap;
304+
},
312305
/*
313306
* summary:
314307
* Deletes the message (if appropriate permissions) at the current

0 commit comments

Comments
 (0)