I for the life of me can't see what I'm doing wrong.
For now all I'm attempting to do is get an alert box. Once I get that working then I'll progress onto actually asking for a password. The problem is that I get nothing from this code...
PHP:
function init() {
$this->include_script('decrypt.js');
...
$this->add_hook('message_part_before', array($this, 'decryption_pw'));
...
}
function decryption_pw($args) {
$rcmail = rcmail::get_instance();
$rcmail->output->command('plugin.decrypt_password', array('test'=>"TEST"));
}
JavaScript:
if(window.rcmail) {
rcmail.addEventListener('init', function(evt) {
rcmail.addEventListener('plugin.decrypt_password', get_password);
});
}
function get_password(data) {
alert("I am a box!");
}
Any help would be appreciated...
YSM
hi, looks like you are getting commands and event listeners confused. try this in the JS instead of of the addeventlistener line:
rcmail.register_command('plugin.decrypt_password', get_password, true);
the "true" at the end is to enable the command.
Thanks for your response, but unfortunatly that didn't fix my problem.
I tried having both the register and event listener in, with no success.
I even tried adding in
rcmail.enable_command('plugin.decrypt_password', true);
with no success. From what it looks like that is the same as the third field in register_command, but I wanted to test it all the same.
I know the JS is getting hit, because if I move the alert into the init I get an actual alert every time there is an action.
So again I'm at a loss as to what I'm doing wrong. More than likely its something dumb I'm not doing...
Anyways thanks for your help.
~Brock
It should be:
rcmail.register_command('plugin.decrypt_password', function(d) { get_password(d); }, true);