plugins["GoogleSearch"] =
{
version: "1.0",
lastChange: new Date(fso.GetFile(currentDirectory+"\\fsubscript.js").DateLastModified).toDateString(),
displayName: "GoogleSearch",
directory: currentDirectory,
icon: currentDirectory + "\\favicon.ico",
aliasstr: "gs",
description: "Search using Google (usefull for online conversions)"
};
(function ()
{
var js = plugins["GoogleSearch"];
var loaded = false;
var match = false;
var match2 = false;
var loadurl = "";
js.search = function search(querykey, explicit, queryraw, querynokeyword,modifierstring,triggermethod)
{
if(!explicit) return;
idletime = 0;
// first : match when a space is at the end of the string
match = queryraw.match(new RegExp("^"+js.aliasstr+" (.+) $"));
// second : match when the user presses enter
match2= queryraw.match(new RegExp("^"+js.aliasstr+" (.+)$"));
if((match && match[1])||
(triggermethod && match2 && match2[1]))
{
loaded = true;
// formated HTML must be like this :
// http://www.google.ro/search?q=query string
// Example : http://www.google.ro/search?q=10$ in euro
if (match)
loadurl = "http://www.google.ro/search?q="+match[1];
else if (match2)
loadurl = "http://www.google.ro/search?q="+match2[1];
else
loadurl = "";
htmlViewURL(loadurl);
showPleaseWait("Loading..");
}
else
{
showHTML("<b>GoogleSearch</b>\
<br>Search using the power of the Google Search service\
<br><br>\
<br>Syntax : <b>"+js.aliasstr+" search string</b>\
<br>(either press ENTER or twice SPACE at the end of the search string)\
<br><br>You can use the special search options of google\
<br><br>Example: <b><br>"+js.aliasstr+" 10$ in euro</b>\
<br>this will show you how much 10$ are in euros\
<br><br>\
<br>For a complete set of supported values look at\
<br><a href=http://www.google.com/insidesearch/tipstricks/all.html>http://www.google.com/insidesearch/tipstricks/all.html</a>\
");
}
};
js.setStrValue = function onSetStrValue(varname,value)
{
if(varname == "EmbeddedWb.DocumentComplete")
{
var pl = pluginInCharge();
if(pl == "GoogleSearch" && loaded)
{
loaded = false;
// hide the "Chrome browser" advertisment
execSafeJS("\
// document.getElementById('gt-bbar').style.display='none';\n\
");
hidePleaseWait();
}
}
}
}());