czechboy,
I've now testdriven the plugin some more. The searches are not always incredibly fast, despite what definr.com claim. Pretty often they take several seconds.
I found a similarly clean site,
http://ninjawords.com/ , that seems faster (at least from my location). We're only talking slightly faster, but still. So I tried to learn from your fscript.js to grab definitions from ninjawords.com instead. The resulting code follows below. Do you spot any errors? It at least seems to run ok but I don't really know javascript or the FARR javascript SDK so there might be errors. The many replace functions look very messy but I'm not sure how to simplify them.
Also, a general question (maybe mouser or someone else can answer this too): is it possible to make some phrases in the grabbed text into hyperlinks when displayed in FARR?
edit: I tweaked it some more so that it now supports multiple lookups at once. Just type "nw word1,word2 " (see
http://ninjawords.com/info/about/ for more on that)
// plugin script :
displayname="ninjawords.com";
versionstring="1.0.0";
releasedatestring="21.2.2008";
author="nod5 (based on Definr plugin by Oldrich Svec)";
updateurl="";
homepageurl="";
shortdescription="ninjawords.com";
longdescription="defines words through http://ninjawords.com";
advconfigstring="ninjawords.com";
readmestring="ninjawords.com";
iconfilename="";
aliasstr="nw";
regexstr="^nw (.*?) $";
scriptregex=/^nw (.*?) $/;
regexfilterstr="";
keywordstr="";
scorestr="300";
// type
UNKNOWN=0; FILE=1; FOLDER=2; ALIAS=3; URL=4; PLUGIN=5; CLIP=5;
// Postprocessing
IMMEDIATE_DISPLAY=0; ADDSCORE=1; MATCH_AGAINST_SEARCH=2;
// search state
STOPPED=0; SEARCHING=1;
var pre_string = "{\\rtf1\\ansi\\ansicpg1250\\deff0\\deftab709{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}}{\\colortbl ;\\red255\\green0\\blue0;}{\\*\\generator Msftedit 5.41.15.1507;}\\viewkind4\\uc1\\pard\\lang2057\\f0\\fs18 ";
var post_string = "\\par\n}";
function doQuery(querykey,querynokeyword){
var url = "http://ninjawords.com/"+querynokeyword;
var xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
xmlhttp.onreadystatechange = function(){
if (xmlhttp.readyState == 4) {
var string = xmlhttp.responseText;
string = string.replace(/\n/g,'\\par');
var splitString = string.split('<dt class="title-word">');
var string ="";
for ( var i=1, len=splitString.length; i<len; ++i ){
if (i > 1) {
string +="\\par -----------------------------\\par ";
}
splitString[i] = splitString[i].replace(/<\/dl>.*?$/,"");
splitString[i] = splitString[i].replace(/<dd.*?>/g,'\\doublepar ');
splitString[i] = splitString[i].replace(/ :<\/span>/g,": ");
splitString[i] = splitString[i].replace(/more»/g,'');
splitString[i] = splitString[i].replace(/—/g,'-');
splitString[i] = splitString[i].replace(/<.*?>/g,"");
splitString[i] = splitString[i].replace(/\t/g,'');
splitString[i] = splitString[i].replace(/\\par\s*?(\S)/g,'\\par$1');
splitString[i] = splitString[i].replace(/\\par/g,'');
splitString[i] = splitString[i].replace(/\\doublepar/g,'\\par\\par');
string += splitString[i];
}
FARR.setStrValue("statusbar","Define");
FARR.setStrValue("window.richeditmode",pre_string+string+post_string);
}
}
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function onSearchBegin(querykey, explicit, queryraw, querynokeyword) {
if(!explicit) {
if(aliasstr.indexOf(querynokeyword)!=-1) {
FARR.setState(querykey,1);
FARR.emitResult(querykey,aliasstr, aliasstr, iconfilename,ALIAS,IMMEDIATE_DISPLAY,300);
FARR.setState(querykey,0);
}
return;
}
FARR.setStrValue("statusbar","Define");
FARR.setStrValue("window.richeditmode",pre_string+"Type what you want to search and hit Space"+post_string);
}
function onRegexSearchMatch(querykey,querynokeyword) {
FARR.setStrValue("statusbar","Define");
FARR.setStrValue("window.richeditmode",pre_string+"Please wait..."+post_string);
var match_reg = querynokeyword.match(scriptregex);
doQuery(querykey,match_reg[1]);
}