js code:
function OnWndBrowserEvent_CtrlClicked(objWnd, strControlId)
{
switch(strControlId)
{
case "BtnGo": // click of the "Go" button
if (CmdMode) // if first character of address bar is a "!"
{
Wnd.setControlText("EdtAddress", URL);
var Command;
var Message = objWnd.GetControlText("EdtAddress");
var Parameter = new Array();
var SiteM;
var SArray = new Array();
SArray = Message.split(" ");
Message = "";
for (SiteM in SArray)
{
switch(SiteM)
{
case "0":
Command = SArray[SiteM].toLowerCase();
break;
default:
Parameter[SiteM] = SArray[SiteM].toLowerCase();
Message += " " + SArray[SiteM];
break;
}
}
if (Command == "!search") // message = !search ...
{
Debug.Trace("> Command: !search");
if (Parameter[2] == "") // message = !search ????? <blank>
{
MsgPlus.CreateWnd("Windows.xml", "WndParameter", 0); // invalid parameter alert
}
else
{
if (Parameter[1] == "google") // message = !search google ...
{
Search = Message.substr(Parameter[1].length + 1);
URL = "http://www.google.com/search?q=" + Search;
Browser.Navigate2(URL);
Debug.Trace("> Now searching for query \"" + Search + "\" (Google).");
URL = "";
Search = "";
}
else if (Parameter[1] == "yahoo") // message = !search yahoo...
{
Search = Message.substr(Parameter[1].length + 1);
URL = "http://search.yahoo.com/search?p=" + Search;
Browser.Navigate2(URL);
Debug.Trace("> Now searching for query \"" + Search + "\" (Yahoo).");
URL = "";
Search = "";
}
else
{
MsgPlus.CreateWnd("Windows.xml", "WndParameter", 0); // parameter alert
}
}
}
else
{
MsgPlus.CreateWnd("Windows.xml", "WndParameter", 0); // parameter alert
}
}
else // not a "!", suggests web address
{
Address = objWnd.GetControlText("EdtAddress");
Wnd.setControlText("EdtAddress", URL);
URL = Address;
Browser.Navigate2(URL);
Debug.Trace("> Now loading page \"" + URL + "\".");
}
break;
Enter a web address, and it's fine. Works perfect. Enter a command, and... nothing happens. I used multiple debug messages to work out that it stops working at the following bit:
js code:
if (Command == "!search")
Why?