It flips the status, or at least it did until I did something to it that stops it working.
Javascript code:
var Activity = "Disabled";
var Messenger = 14;
var Mode = "All Values";
var Refresh = 1000; // will add a method of changing this later
var OldStatus;
MsgPlus.AddTimer("FlipStatus", Refresh);
function OnGetScriptMenu (nLocation)
{
Menu = '<ScriptMenu>';
if (Activity == "Enabled")
{
Menu += '<MenuEntry Id=\"Activity\">Disable Flip Status...</MenuEntry>';
}
else
{
Menu += '<MenuEntry Id=\"Activity\">Enable Flip Status...</MenuEntry>';
}
Menu += '<Separator/>';
if (Activity == "Enabled" || Mode == "On/Off Only")
{
Menu += '<MenuEntry Id=\"Messenger\" Enabled=\"false\">Messenger: ' + Messenger + '</MenuEntry>';
}
else
{
Menu += '<MenuEntry Id=\"Messenger\">Messenger: ' + Messenger + '</MenuEntry>';
}
if (Activity == "Enabled")
{
Menu += '<MenuEntry Id=\"Mode\" Enabled=\"false\">Mode: ' + Mode + '</MenuEntry>';
Menu += '<MenuEntry Id=\"Refresh\" Enabled=\"false\">Refresh: ' + Refresh + 'ms</MenuEntry>';
}
else
{
Menu += '<MenuEntry Id=\"Mode\">Mode: ' + Mode + '</MenuEntry>';
Menu += '<MenuEntry Id=\"Refresh\">Refresh: ' + Refresh + 'ms</MenuEntry>';
}
Menu += '</ScriptMenu>';
return Menu;
}
function OnEvent_MenuClicked (sMenuId, nLocation, iOriginWnd)
{
if (sMenuId == "Activity")
{
if (Activity == "Enabled")
{
Activity = "Disabled";
Messenger.MyStatus = OldStatus;
}
else if (Activity == "Disabled")
{
OldStatus = Messenger.MyStatus;
Activity = "Enabled";
}
}
if (sMenuId == "Messenger")
{
if (Messenger == 9)
{
Messenger = 14;
}
else if (Messenger == 14)
{
Messenger = 9;
}
}
if (sMenuId == "Mode")
{
if (Mode == "All Values")
{
Mode = "On/Off Only";
}
else if (Mode == "On/Off Only")
{
Mode = "All Values";
}
}
}
function OnEvent_Timer(TimerId)
{
if (TimerId == "FlipStatus")
{
if (Activity == "Enabled")
{
if (Mode == "All Values")
{
if (Messenger == 9)
{
switch (Messenger.MyStatus)
{
case 3:
Messenger.MyStatus = 4;
break;
case 4:
Messenger.MyStatus = 5;
break;
case 5:
Messenger.MyStatus = 7;
break;
case 7:
Messenger.MyStatus = 8;
break;
case 8:
Messenger.MyStatus = 9;
break;
case 9:
Messenger.MyStatus = 3;
break;
default:
Messenger.MyStatus = 3;
break;
}
}
else if (Messenger == 14)
{
switch (Messenger.MyStatus)
{
case 3:
Messenger.MyStatus = 4;
break;
case 4:
Messenger.MyStatus = 7;
break;
case 7:
Messenger.MyStatus = 3;
break;
default:
Messenger.MyStatus = 3;
break;
}
}
}
else if (Mode == "On/Off Only")
{
switch (Messenger.MyStatus)
{
case 2:
Messenger.MyStatus = 3;
break;
case 3:
Messenger.MyStatus = 2;
break;
default:
Messenger.MyStatus = 3;
break;
}
}
}
MsgPlus.AddTimer("FlipStatus", Refresh);
}
}
It's probably something really obvious, but I've been looking at it for 20 minutes and I don't see what's up with it. If it helps, I found out (using the script debugger) that it always reaches the "switch (Messenger.MyStatus)" bit, but it just doesn't match the number with the status, even though it did before. Can anyone explain what I must have missed?