topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 4:59 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Fingers in the nose guide to build javascript plugins. Does that mean its easy ?  (Read 31759 times)

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
I wrote a short documentation on how to use the Javascript SDK. It is just a beautiful thing of litterature. It is packaged with a javascript plugin sample sample and appropriately named the_fingers_in_the_nose_guide_to_build_javascript_plugin_for_farr.txt
Start hacking at : http://e.craft.free....pt/FScriptSample.rar

M. 8)

Blog & Projects : Blog | Qatapult | SwiffOut | FScript
« Last Edit: January 12, 2008, 04:23 PM by ecaradec »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
file not found.

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Oups! Characters case issue. Fixed. Thank.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
Hi, I am working on "Character table" javascript plugin. I have several questions.
1)Could you please describe what UNKNOWN=0; FILE=1; FOLDER=2; ALIAS=3; URL=4; PLUGIN=5; CLIP=5; does? I am completely newbie concerning most of programming :)
2) Another question targeting to mouser: is there any way how to make all chars visible correctly? Now when I type "chars d" it displays completely mess (it should display those chars:"ð","đ","ď","dž","∂","δ"), I saved the text file as UTF-8 to have all the chars saved corectly :(
3) Is there any way how to display all result not only 9 of them? I now user can write "+sall" but I would prefer if for this plugin this would be set as default

Here is my code til now.. but still working on it:
// plugin script :
displayname="Character Table";
versionstring="1.00.01";
releasedatestring="Apr 1st, 2007";
author="Oldrich Svec<[email protected]>";
updateurl="";
homepageurl="";
shortdescription="Character Table";
longdescription="Character Table";
advconfigstring="Character Table";
readmestring="Character Table";
iconfilename="Delicious.ico";

aliasstr="chars";
regexstr="chars/.*";       // this is the farr regex
scriptregex=/chars\/(.*)/; // this is the plugin regexp (the group are not transfered to the onRegExSearchMatch currently )
regexfilterstr="$$1";
keywordstr="";
scorestr="300";
//autoreload=true;


// 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;

var string = new Array();
string[":"] = new Array("^_^","=^_^=","¬_¬");
string["$"] = new Array("¢","£","¤","¥","€","₣","₤","₧","₨","₠");
string["!"] = new Array("¡","¬");
string["?"] = new Array("¿");
string["^"] = new Array("¹","²","³","ⁿ");
string["/"] = new Array("÷","¼","½","¾","⅛","⅜","⅝","⅞");
string["+"] = new Array("±");
string["-"] = new Array("−","±");
string["*"] = new Array("×");
string["="] = new Array("≈","≠","≡","≤","≥");
string["."] = new Array("…");
string["a"] = new Array("á","à","ä","â","å","ā","ă","ą","ǎ","æ","ǟ","ǡ","ǣ","ǻ","ǽ","α");
string["A"] = new Array("Á","À","Ä","Â","Å","Ā","Ă","Ą","Ǎ","Æ","Ǟ","Ǡ","Ǣ","Ǻ","Ǽ","Α");
string["b"] = new Array("ß","β");
string["B"] = new Array("Β");
string["c"] = new Array("ç","č","ć","ċ","ĉ","©","χ");
string["C"] = new Array("Ç","Č","Ć","Ċ","Ĉ","©","Χ");
string["d"] = new Array("ð","đ","ď","dž","∂","δ");
string["D"] = new Array("Ð","Đ","Ď","DŽ","Dž","Δ");
string["e"] = new Array("é","è","ë","ê","ē","ĕ","ė","ę","ě","ǝ","℮","€","ε","η");
string["E"] = new Array("É","È","Ë","Ê","Ē","Ĕ","Ė","Ę","Ě","€","Ε");
string["f"] = new Array("φ");
string["F"] = new Array("₣","Φ");
string["g"] = new Array("ĝ","ğ","ġ","ģ","ǥ","ǧ","γ");
string["G"] = new Array("Ĝ","Ğ","Ġ","Ģ","Ǥ","Ǧ","Γ");
string["h"] = new Array("ĥ","ħ");
string["H"] = new Array("Ĥ","Ħ","Η");
string["i"] = new Array("í","ì","ï","î","ĩ","ī","ĭ","į","ı","ǐ","ij","∞","∫","η","ι");
string["I"] = new Array("Í","Ì","Ï","Î","Ĩ","Ī","Ĭ","İ","Į","Ǐ","IJ","Η","Ι");
string["j"] = new Array("ĵ","ij");
string["J"] = new Array("Ĵ","IJ");
string["k"] = new Array("ķ","ĸ","ǩ","κ","χ");
string["K"] = new Array("Ķ","Ǩ","Κ","Χ");
string["l"] = new Array("ĺ","ļ","ľ","ŀ","ł","lj","λ");
string["L"] = new Array("Ĺ","Ļ","Ľ","Ŀ","Ł","LJ","Lj","₤","Λ");
string["m"] = new Array("μ");
string["M"] = new Array("Μ");
string["n"] = new Array("ñ","ń","ņ","ň","ʼn","ŋ","nj","η","ν");
string["N"] = new Array("Ñ","Ń","Ņ","Ň","Ŋ","NJ","Nj","Η","Ν");
string["o"] = new Array("ø","ó","ò","ö","ô","õ","ō","ŏ","ő","ǒ","ǫ","ǭ","œ","°","ο","ω");
string["O"] = new Array("Ø","Ó","Ò","Ö","Ô","Õ","Ō","Ŏ","Ő","Ǒ","Ǫ","Ǭ","Œ","Ο","Ω");
string["p"] = new Array("þ","₧","π","ψ");
string["P"] = new Array("Þ","ß","Π","Ψ");
string["r"] = new Array("ŕ","ŗ","ř","ȑ","ȓ","®","√","ρ");
string["R"] = new Array("Ŕ","Ŗ","Ř","Ȑ","Ȓ","®","Ρ");
string["s"] = new Array("š","ś","ŝ","ş","ß","Σ","√","∫","σ","ς");
string["S"] = new Array("Š","Ś","Ŝ","Ş","Σ");
string["t"] = new Array("ţ","ť","ŧ","™","θ","τ");
string["T"] = new Array("Ţ","Ť","Ŧ","Θ","Τ");
string["u"] = new Array("ú","ù","ü","û","ũ","ū","ŭ","ů","ű","ų","ǔ","ǖ","ǘ","ǚ","ǜ","ȕ","ȗ","υ");
string["U"] = new Array("Ú","Ù","Ü","Û","Ũ","Ū","Ŭ","Ů","Ű","Ų","Ǔ","Ǖ","Ǘ","Ǚ","Ǜ","Ȕ","Ȗ","Υ");
string["w"] = new Array("ŵ");
string["W"] = new Array("Ŵ");
string["x"] = new Array("ξ","χ");
string["X"] = new Array("Ξ","Χ");
string["y"] = new Array("ý","ÿ","ŷ");
string["Y"] = new Array("Ý","Ÿ","Ŷ");
string["z"] = new Array("ź","ż","ž","ζ");
string["Z"] = new Array("Ź","Ż","Ž","Ζ");

function debug(msg) {
    if(typeof(WScript)!="undefined")
        WScript.StdOut.Write(msg+"\n");
}

function doQuery(query) {
     FARR.setState(1);
    if(query == ""){
      FARR.emitResult("Type a letter", "test", iconfilename,FILE,IMMEDIATE_DISPLAY,300);
    }else if(string[query] != undefined){
      for(var i=0; i<string[query].length; i++){
        FARR.emitResult(string[query][i], string[query][i], iconfilename,CLIP,IMMEDIATE_DISPLAY,300);
      }
    }else{
      FARR.emitResult("No match", "test", iconfilename,FILE,IMMEDIATE_DISPLAY,300);
    }
    FARR.setState(0);
}

function onSearchBegin(explicit, query, query_nokeyword) {
    if(!explicit) {
        if(aliasstr.indexOf(query)!=-1) {
            FARR.setState(1);
            FARR.emitResult(aliasstr, aliasstr, iconfilename,ALIAS,IMMEDIATE_DISPLAY,300);
            FARR.setState(0);
        }
        return;
    }

    doQuery(query_nokeyword);
}

function onRegexSearchMatch(query) {
    var query_nokeyword=query.match(scriptregex)[1]

    doQuery(query_nokeyword);
}

// There is no debugging when the script is executed in FARR
// Run the script with "cscript fscript.js" to debug it while developpement
if(typeof(FARR)=="undefined") {
    FARR={
        emitResult:function(title, path, icon, type, postproc,score) {
            WScript.StdOut.Write("title:"+title+"\n");
            WScript.StdOut.Write("path:"+path+"\n");
            WScript.StdOut.Write("icon:"+icon+"\n");
            WScript.StdOut.Write("type:"+type+"\n");
            WScript.StdOut.Write("postproc:"+postproc+"\n");
            WScript.StdOut.Write("score:"+score+"\n");
        },
        setState:function(s) {
            WScript.StdOut.Write(s+"\n");
        }
    }
    //onSearchBegin(true, "deli","test");
    onRegexSearchMatch("deli/joke")
    WScript.Sleep(1000);
}
My open-source online piano game: https://github.com/musicope/game
« Last Edit: January 25, 2008, 02:04 PM by czechboy »

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
hi czechboy, let me try to help a little, and sorry for the delay in responding.

ok as for #1, these are different kinds of results that can be returned by plugins which help FARR know how to handle the results.  FILE type is most common when results are files.  most of the others are for internal use -- in your case you should probably use UNKNOWN, basically meaning that FARR shouldnt assume that the result is a file to launch.  Then you will handle the triggering of it.

#2 - i think what we have here is a problem with unicode text display or font character set, and FARR is not unicode compatible.  i'm thinking though that maybe the best solution for plugins that want to do unicode stuff is to add an ability for FARR to be told to display a special unicode display mode.. i'll have to look into that when i have a little more time -- i'm still in the middle of a job that takes up most of my time at the moment so it will have to wait a month or so :(  but i will find a way to do it so don't let this stop you from working on this nice plugin.

#3 - yes you can call the function to set a farr variable and pass the keyword: setshowallmode
that will trigger FARR to display all resutls not just a few.

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
Thank you for your response.
I have one more question:
How can I easily check if the plugin is working? now I have to go settings/click to eximine and configure plugins/find and reload all plugins to see the changes I have made which is quite time consuming. Is there any alias for reloading all plugins? Something like that is I guess in Launchy ;)

as for 1) You wrote: "Then you will handle the triggering of it." Is it this function "onProcessTrigger(title,path)" which handles it?

as for 2) Ok I will pospone development of this plugin to later time and will focus on other ideas I have (dictionary etc.)

as for 3) Could you be more specific where exactly I am supose to write setshowallmode? Is it somewhere here in this function FARR.emitResult?
My open-source online piano game: https://github.com/musicope/game

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
typing "rplugins" will reload all plugins.
1) yes, although i've not coded for the javascript api yet, onProcessTrigger(title,path) i think is the callback that FARR will call to let you decide what to do when user trigers it so your plugin can handle it.
2) sounds good and feel free to email me ([email protected]) if i lag behind.
3) ecaradec can give better help on using the jd api but what you should call is:
   // do some special FARR action like setting statusbar, richedit (see farr plugin action documentation )
   FARR.setStrValue("setshowallmode","");
like that, before you start returning any results (call it once each time a new search is conducted).

ps. it's great to see people already using ecaradec's amazing javascript api work! make sure to send me your mailing address after you release your first plugin with it so i can send you a special Cody Plugin Writer Coffee Mug.

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
ok ok:) Where can I find "farr plugin action documentation"? I have found readme.txt in FarrPluginSDK but it is only general help, so I can not find there for example options of setStrValue (how to use richedit etc)

another thing is. I have found in readme.txt: "(Note FARR already has builtin funcionts to copy stuff to clipboard or to the last window open before FARR was triggered)". Are those functions accesible from javascript?

Sory for all my questions but as I said before, I am coding beginner ;)
My open-source online piano game: https://github.com/musicope/game

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
I have found in readme.txt: "(Note FARR already has builtin funcionts to copy stuff to clipboard or to the last window open before FARR was triggered)". Are those functions accesible from javascript?

yes:
just call that same setStrValue function with the keyword "PasteClipboardToLastActiveWindow"
so for example:
FARR.setStrValue("PasteClipboardToLastActiveWindow","Hello!");

will paste the text "Hello!" into the program that was active before FARR was triggered.



Sory for all my questions but as I said before, I am coding beginner


no need to apologize -- these questions would be same questions an expert coder would ask, because the reality is that the plugin documentation doesnt really exist, it's still in a state of evolution and mostly people are just figuring it out from the sample code until i get my act together and write a full set of docs.

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
unfortunately such thing does not seem to work:
function onProcessTrigger(title,path){
  FARR.setStrValue("PasteClipboardToLastActiveWindow",title);
}
what do I do wrong?
My open-source online piano game: https://github.com/musicope/game

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 40,896
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Can you narrow down the problem.. is your OnProcessTrigger function being called? Is the clipboard being set but not copied to active window?

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
I do not know.. unfortunately I did not manage to start some kind of debugging with javascript.. so I do not know how to know if the function is called or not... :/ I like the simplicity of javascript (you have a few functions needed and that is all). Is there any other programming (free) language as simple (in case of farr plugins) as javascript is which is more easy to debug? I have tried to read devcpp SDK of FARR (since it is free) but it seams to me to complex to understand its structure and where to code what.. :/
My open-source online piano game: https://github.com/musicope/game

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
Hi, so I tried further to learn javascript SDK and the only thing I was not able to get working is FARR.setStrValue(x, y);
I have tried many of those combinations:
/// Possible options:
   ///
   ///launch, LAUNCHFILENAME
   ///statusbar, TEXTTOSETONSTATUSBAR
   ///setsearch, TEXTTOSETINSEARCHEDIT
   ///setsearchnogo, TEXTTOSETINSEARCHEDIT
   ///stopsearch
   ///window.hide
   ///window.show
   ///window.toggle
   ///window.richeditmode, TEXTOPUTINRICHEDITWINDOW
   ///window.richeditheight, HEIGHTOFWINDOW
   ///window.richeditwidth, WIDTHOFWINDOW
   ///setshowallmode
   ///exit
   ///reporterror, ERRORTEXTTOREPORTINPLUGINLOG
   ///clipboard
   ///PasteClipboardToLastActiveWindow,[TEXTTOSET] - paste the current clipboard text to the last active program (if value passed is not "" then clipboard will first be set to value.
   ///
but with no luck.
Could you please, ecaradec post here some sample code where you use it?
My open-source online piano game: https://github.com/musicope/game

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
Thank you very much for support mouser :).
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
I do not know.. unfortunately I did not manage to start some kind of debugging with javascript...
Here is how I enabled javascript debugging on my desktop :
1. install the javascript debugger : http://www.microsoft...9&displaylang=en
2. set the registry key HKEY_CURRENT_USER\Software\Microsoft\Windows Script\Settings\JITDebug=1 [DWORD]. I join a registry file that does that.
3. restart FARR (I may have forgotten that in the documentation )
Did some people achieved to enable the javascript debugger ? It make plugin developpement much easier.
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
ok I have done all the steps to enable debugging... and what now? when I type in xplorer2 this:
"$ cscript fscript.js" a window appears and this is there:
Microsoft (R) Windows Script Host verze 5.6
Copyright (C) Microsoft Corporation 1996-2001. Všechna práva vyhrazena.

Vstupní chyba: Pro příponu .js není k dispozici žádný skriptovací stroj.

Which says something like for .js there is no scripting machine

EDIT: wow I see, it is directly in farr... that is just great!!!! thanks a lot ;)

EDIT2: Unfortunately the debugging often crashes both FARR and the debugger itself. For example I start some script in FARR and open debugger and set some break.. so it stops on the break and in the meantime FARR starts to object that the script takes to long and if I want to stop it.. I say continue and both debugger and FARR are crashed... :(

EDIT 3: So I have tried Microsoft Script Editor and it is faaaaaaaaaaaaar better than microsoft debugger. So everybody who has got MS Office 2003/XP/2000 or Frontpage 2003 etc. I recommend you to use MSE7 ;)
My open-source online piano game: https://github.com/musicope/game
« Last Edit: January 29, 2008, 08:38 AM by czechboy »

ecaradec

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 410
    • View Profile
    • Blog & Projects
    • Read more about this member.
    • Donate to Member
For example I start some script in FARR and open debugger and set some break.. so it stops on the break and in the meantime FARR starts to object that the script takes to long and if I want to stop it.. I say continue and both debugger and FARR are crashed...

I upload a new version of the FScript.dll that fix the timeout. I don't update the delicious plugin because there is no need to, but if you are working with the javascript SDK and the timeout is bugging you, the new FScript.dll fix the problem :

http://e.craft.free....pt/FScriptSample.rar

czechboy, I'm waiting for your plugins...
Blog & Projects : Blog | Qatapult | SwiffOut | FScript

czb

  • Honorary Member
  • Joined in 2007
  • **
  • Posts: 336
    • View Profile
    • My open-source online piano game
    • Donate to Member
:) I am workin on it. But it is goining slowly since with coding I learn javascript so I make a lot of mistakes and most of the time I spend searching them. For example now I can not make FARR.emitResult.... work (I guess I have setState wrong positioned). And I also should start my bachalor project.. but I am working on it and learning it :)
My open-source online piano game: https://github.com/musicope/game

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
I hope this is an appropriate thread for the following...

I've been reading the guide while testing out some code and am puzzled by something (well, I'll start w/ one thing anyway...).  I encountered the following text in a version of the guide I downloaded:

querynokeyword is the query without alias

I tried taking a look at values for this parameter via a debugger and I didn't get the feeling that what I was seeing corresponded to "query without the alias".  In fact, I found the content quite odd -- looking at a portion of some of the source code for fscript I got from github I got the sense that querynokeyword is related to searchstring_lc_nokeywords.  Stranger still, I didn't get the feeling that what I saw corresponded to the search string without keywords either.

Any comments on what querynokeyword and/or searchstring_lc_nokeywords actually are (as well as perhaps what they are supposed to be...)?

For reference, in a plugin I'm working on now, for onRegexSearchMatch at one point when queryraw was:

webgrab http://www.weather.com/weather/local/11020 \"Feels Like<BR> +(\d+)\" \"Weather in your town is %1 degrees\"\n

I got [1] the following for querynokeyword:

webgrab http://www.weather.com/weather/local/11020 \"feels like<br> \"weather in your town is %1 degrees\"\n +(\d+)\"

I think this is with FScript 1.8.

Help would be appreciated :)


[1] I hope I've recreated the values here appropriately -- Microsoft Script Debugger doesn't seem to make this easy...

phitsc

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 1,198
    • View Profile
    • Donate to Member
I noticed this as well recently but didn't bother to report it as I needed to use the queryraw string anyway for what I was doing. It's definitely not an FScript problem. I think it's a FARR bug that must have come in quite recently only.

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Thanks for the comment of confirmation :)

I hope that if it's broken it gets fixed and if it's not broken, I hope my understanding can get fixed...

phitsc

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 1,198
    • View Profile
    • Donate to Member
Or just fix the comment, i.e. instead of (what it is now):

// Normally the string you care about is searchstring_lc_nokeywords, thats the search string with all special +modifier keywords removed, and
//  the alias keyword for this plugin removed, so all thats left is the string that should effect the results of the search.


change it to this:

// searchstring_lc_nokeywords usually contains the same as searchstring_raw


ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Hmmm...no smily?

"usually" is a bit too flexible and all-encompassing for my taste in this context  ;)

phitsc

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 1,198
    • View Profile
    • Donate to Member
You're right of course. I think I really have to learn how to properly use smilies now. Didn't know which smiley to use for a joke to be honest so I just hoped my suggestion would look silly enough. ;) (is that appropriate now?)

ewemoa

  • Honorary Member
  • Joined in 2008
  • **
  • Posts: 2,922
    • View Profile
    • Donate to Member
Much better thanks!

Now if we can get mouser, ecaradec and/or czechboy [1] to comment on the actual content  ;)


[1] Or any other relevant entity!