ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > FARR Plugins and Aliases

Definr.com plugin - closed

<< < (4/5) > >>

Nod5:
I just tried your version of the Ninjawords script. It did not run here. After entering the search string I get "please wait..." and then nothing happens. Not sure why. Does it work for you? I updated my version some more based on your code (simplified the replace steps, made each search phrase bold). Feel free to use it.

--- ---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|\t/g,'');
var splitString = string.split('<dt class="title-word">');
       
        var string ="";

for (var i=1;i<splitString.length; ++i){

    if (i > 1) {
               string +="\\par -----------------------------\\par ";
               }
splitString[i] = "\\b " + splitString[i]
        splitString[i] = splitString[i].replace(/<\/dl>.*?$/,"");
splitString[i] = splitString[i].replace(/<dd.*?>/g,'\\b0 \\par\\par ');
        splitString[i] = splitString[i].replace(/ :<\/span>/g,": ");
splitString[i] = splitString[i].replace(/more&raquo;/g,'');
splitString[i] = splitString[i].replace(/&mdash;/g,'-');
        splitString[i] = splitString[i].replace(/<.*?>/g,"");
string += splitString[i];
}
         
        FARR.setStrValue("statusbar","Define");
        FARR.setStrValue("window.richeditmode",pre_string+string+post_string);
      }
    }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}
I forgot to mention one more advantage with Ninjawords: if you spell a word wrong it automatically guesses the word and shows the definition - try "nw footbaall ". Definr on the other hand shows a list of terms and forces the users to choose one.

As for that XML thing I think I understand what you mean. Promising. I can already think of several websites that I'd want FARR to grab specific content from and display to me in an instant. But I'm not sure if people will prefer that over site specific plugins. And I don't know how to write XML so I can't help much I'm afraid.

edit: I now saw that you created a new thread ( https://www.donationcoder.com/forum/index.php?topic=12421.0 ). The ninjawords version on your page does return definitions. But I think there is some error in the parsing code. Try "nw test,gone " and "nw gone,test ". In the first case, the bold "gone" is missing. In the second case, both "gone" and it's definition is missing. I'm not sure what the cause of that is.

czb:
Ok I have updated to your version :Thmbsup: Thanks for pointing out ;)

btw: ninjawords really seams promising :)

EDIT: If you wanted to make it even faster you can try this url:
http://ninjawords.com/definitions/getdef/test
instead. It is what ninjawords.com uses to send ajax reguest ;)

Nod5:
Great. I'll try it now.  edit: works fine"  :Thmbsup:

Two more things:
- the ninjawords plugin page says "nw - to start Definr plug-in" when you really mean "nw - to start Ninjawords plug-in".
- note that: "nw school, wall " is not needed for multiple lookups. "nw school,wall " is enough. That way the plugin accesses the Ninjawords site only once compared to twice.

Using http://ninjawords.com/definitions/getdef/test from the beginning would probably have been best, but I'm not sure if its needed now.
How many milliseconds do you think we'll save by using it? ;D

czb:
You are right :-[
All suggestions corrected (hopefully) :)

Nod5:
I gave the alternative page for grabbing the definitions ( http://ninjawords.com/definitions/getdef/test ) a go after all. Do you notice any difference in speed? Also, since the definitions are grabbed blazingly fast, maybe it's best to remove the "Please wait..." text completely? It just causes FARR to flicker a very brief moment but is almost not readable.

edit: this cuts off some words it seems, will troubleshoot that later. edit2: works now, I earlier forgot to escape \ at one place

--- ---function doQuery(querykey,querynokeyword){
  var url = "http://ninjawords.com/definitions/getdef/"+querynokeyword;
  var xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
  xmlhttp.onreadystatechange = function(){
    if (xmlhttp.readyState == 4) {
      var string = xmlhttp.responseText;
      string = string.replace(/\\n|\\t/g,'');
      var splitString = string.split('\\074dt class=\\"title-word\\"\\076');
      var string ="";
      for (var i=1;i<splitString.length; ++i){
        if (i > 1) {
          string +="\\par -----------------------------\\par ";
        }
        splitString[i] = "\\b " + splitString[i];
        splitString[i] = splitString[i].replace(/", query: ".*?$/,"");
        splitString[i] = splitString[i].replace(/\\074dd.*?\\076/g,'\\b0 \\par\\par ');
        splitString[i] = splitString[i].replace(/ :\\074\/span\\076/g,": ");
        splitString[i] = splitString[i].replace(/\\074div class=\\"examples\\"\\076/g,"\. ");
        splitString[i] = splitString[i].replace(/\\074.*?\\076/g,"");
        splitString[i] = splitString[i].replace(/\\u2014/g,"-");
        splitString[i] = splitString[i].replace(/\\u2019/g,"'");
        splitString[i] = splitString[i].replace(/&mdash/g,"-");
        splitString[i] = splitString[i].replace(/more&raquo;\,/g,"");
        string += splitString[i];
      }
      FARR.setStrValue("statusbar","Define");
      FARR.setStrValue("window.richeditmode",pre_string+string+post_string);
      }
    }
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version