sbbs/load/control/echomail.js

83 lines
2.1 KiB
JavaScript
Raw Normal View History

/**
* This control renders echomail
*
* The system echomail prefix is *1, with echomail pages built from the following page number:
* zzzzEEpppp, where:
* + zzzz is the zone, zero padded, the zone identifies the message groups
* + EE is the echomail area, ie: the message areas
* + pppp is the message number, identified by the tag attached to the message header
*
* (Tags are added to the messages via an external process.)
*/
2023-12-27 11:24:20 +00:00
// All controls need a unique variable so that require() can know if the control has already been loaded
var CONTROL_ECHOMAIL = '1';
2023-12-27 11:24:20 +00:00
// Optional debug message so we can see that it is loaded
log(LOG_DEBUG,'+ Control ECHOMAIL loaded');
2023-12-27 11:24:20 +00:00
// A unique method name (same as the control name that is called as new method() on initialisation
function echomail(session,pagenum) {
2023-12-27 11:24:20 +00:00
log(LOG_DEBUG,' - Loading echomail page:'+pagenum);
// has this control completed
var complete = false;
2023-12-27 11:24:20 +00:00
var ready = false;
function init(session,pagenum) {
log(LOG_DEBUG,' - Echomail init('+pagenum+')');
2023-12-27 11:24:20 +00:00
ready = session.loadMessage(pagenum);
}
Object.defineProperty(this, 'getName', {
get: function () {
return 'ECHOMAIL';
}
});
Object.defineProperty(this, 'isComplete', {
get: function () {
return complete;
}
});
// Handle the keyboard responses as we receive them.
2023-12-27 11:24:20 +00:00
this.handle = function(read) {
log(LOG_DEBUG,'Control ECHOMAIL handle() start. ('+read+')');
switch(read) {
case KEY_DOWN:
2023-12-27 11:24:20 +00:00
session.page.scroll(0,1);
read = '';
break;
case KEY_UP:
2023-12-27 11:24:20 +00:00
session.page.scroll(0,-1);
read = '';
break;
}
session.render();
return read;
}
2023-12-27 11:24:20 +00:00
/**
* ready() is called after a control has been initialised, to determine if the control will take the input
* or if it is unable to do so
*
* If ready() returns:
* + false, the main programming will return ERR_ROUTE to the user,
* + true, the main programming will continue to load the frame, and then pass input to on the next loop handle()
*
* @returns {boolean}
*/
this.ready = function() {
log(LOG_DEBUG,'echomail:ready = '+JSON.stringify(ready));
2023-12-27 11:24:20 +00:00
return ready;
}
2023-12-27 11:24:20 +00:00
init.apply(this,arguments);
}