ifthen: support if/then/else/finally branch logic in Javascript callbacks