Closed GoogleCodeExporter closed 9 years ago
NO, jquery needs a browser implementation
Original comment by n.ame...@gmail.com
on 18 Dec 2012 at 12:29
NO! Its possible with this http://www.envjs.com/
Please test...
Original comment by david.lo...@gmail.com
on 18 Dec 2012 at 12:55
If you implement browser functionality that is needed from jquery
yes...otherwise the way it is NO
Original comment by n.ame...@gmail.com
on 18 Dec 2012 at 12:56
Well how to do it? Please make an example how to do it :)
Original comment by david.lo...@gmail.com
on 18 Dec 2012 at 12:58
This is not a simple example....you need to expose from your code ALL API used
from browsers in javascript....in other words almost impossible ..
Original comment by n.ame...@gmail.com
on 18 Dec 2012 at 12:59
See the following url
http://powerman.name/doc/jquery_in_spidermonkey.html#_run
download env.js and then write some code like, then u should be able running
jquery
FJSEngine := TJSEngine.Create;
FJSEngine.registerGlobalFunctions(TJSGlobalFunctions);
FJSEngine.EvaluateFile('env.js');
// print([expression ...])
FJSEngine.Evaluate('Envjs.log=print;');
type
TJSGlobalFunctions = class
class procedure print(s: string); static;
end;
class procedure TJSGlobalFunctions.print(s: string);
begin
writeln(s);
end;
Original comment by n.ame...@gmail.com
on 18 Dec 2012 at 1:28
So it is possible in theory?
Original comment by david.lo...@gmail.com
on 18 Dec 2012 at 1:52
Yes...but you are on your own ... :-)
Bellow full console sample
program js;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
js15decl in '..\js15decl.pas',
jsDbgServer in '..\jsDbgServer.pas',
jsintf in '..\jsintf.pas',
NamedPipesImpl in '..\NamedPipesImpl.pas';
Type
TJSGlobalFunctions = class
class procedure print(s: string); static;
end;
var
Engine: TJSEngine;
{ TJSGlobalFunctions }
class procedure TJSGlobalFunctions.print(s: string);
begin
writeln(s);
end;
begin
try
{ TODO -oUser -cConsole Main : Insert code here }
Engine := TJSEngine.Create;
Engine.registerGlobalFunctions(TJSGlobalFunctions);
Engine.EvaluateFile('env.js');
Engine.Evaluate('Envjs.log=print;');
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Original comment by n.ame...@gmail.com
on 18 Dec 2012 at 1:59
Amazing! :)
I knew it is possible now i test, thanks! :)
Original comment by david.lo...@gmail.com
on 18 Dec 2012 at 2:04
Note that you will still need ti implement Envjs.XXXXXXX functions like the
one i assign to print Envjs.log, look @ the begining of env.js and see
functions like
Envjs.eval = function(context, source, name){};
Such function need to be defined in your delphi code.
Original comment by n.ame...@gmail.com
on 18 Dec 2012 at 2:45
How will this work.. If i extract <script> from a given website and run it
inside the TJSEngine? For example a script from Google.com or other website.
Just an example.
Do i need to implement my functions aswell?
Original comment by david.lo...@gmail.com
on 20 Dec 2012 at 2:31
Original issue reported on code.google.com by
david.lo...@gmail.com
on 18 Dec 2012 at 11:38