Menu functions:
Javascript code:
function OnGetScriptMenu(nLocation){
var oMenu = new ScriptMenu();
with (oMenu) {
AddSubMenu('My Menu'));
AddItem('/mycommand1', 'My Command without parameter');
AddItem('/mycommand1 5', 'My command with parameter');
AddSeperator();
AddItem('', 'Disabled item', false);
CloseSubMenu();
}
return oMenu.ExportMenu();
}
function OnEvent_MenuClicked(sMenuId, nLocation, oChatWnd){
OnEvent_ChatWndSendMessage(oChatWnd, sMenuId);
}
Command functions:
Javascript code:
function OnGetScriptCommands(){
var oCommand = new Commands();
with (oCommand) {
AddCommand('mycommand1', 'My command without parameter');
AddCommand('mycommand1', 'My command with parameter', 5);
}
return oCommand.ExportCommands();
}
function OnEvent_ChatWndSendMessage(oChatWnd, sMessage) {
if (/^\/([^\s\/]+)\s*([\s\S]*)$/.exec(sMenuId) !== null) {
var _command = RegExp.$1.toLowerCase();
var _param = RegExp.$2;
switch (_command) {
case 'mycommand':
if ( _param !== '' ) {
/*
Do stuff here
*/
} else {
/*
Do stuff here
*/
}
break;
}
}
}