Skip to content

Instantly share code, notes, and snippets.

@satyr
Created July 23, 2009 18:58
Show Gist options
  • Save satyr/153420 to your computer and use it in GitHub Desktop.
Save satyr/153420 to your computer and use it in GitHub Desktop.
CmdUtils.CreateCommand({
name: 'toggle chat mode',
execute: function tcm_execute(){
var {gUbiquity} = context.chromeWindow;
var on = gUbiquity._tcmState ^= 1;
gUbiquity.msgPanel.removeEventListener('keypress',
gUbiquity._tcmListener,
true);
if(on){
gUbiquity.msgPanel.addEventListener('keypress', this._listener, true);
gUbiquity._tcmListener = this._listener;
}
gUbiquity[(on ? 'open' : 'close') + 'Window']();
displayMessage(on ? 'on' : 'off', this);
},
preview: function tcm_preview(pb){
pb.innerHTML = ((context.chromeWindow.gUbiquity._tcmState ? 'Dis' : 'En')
+ 'ables chat mode.');
},
_listener: function tcm_listener(ev){
var {gUbiquity} = Utils.currentChromeWindow;
if(ev.keyCode !== 13 || ev.target !== gUbiquity.textBox) return;
gUbiquity.cmdManager.execute(gUbiquity.__makeContext());
ev.stopPropagation();
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment