summaryrefslogtreecommitdiffstats
path: root/README
blob: 2a7e60ac70f7157182f3af9ab10842608456b148 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Envjs implementation for QtScript.

Envjs (http://www.envjs.com) is a simulated browser environment written in JavaScript.

The code in this repository only implements the Envjs parts that need platform support.
You'll also need a file called env.js (not included in this repository), which is the
main Envjs implementation. To create it:
1. Go to http://www.envjs.com/release/envjs-1.2 and download the full release.
2. Unpack.
3. Run ant from the base Envjs directory.
4. Presto, dist/env.js is ready for evaluation.

To use Envjs with QtScript, you'll need to
1. Evaluate env.js.
2. Call the function initializeEnvjsNatives() (in src/shared/envjsnatives.cpp).

To achieve that, there are two major options:

1. Fully embed Envjs in the application: Pass the contents of env.js to
QScriptEngine::evaluate(), and then call initializeEnvjsNatives(). You'll need
to add src/shared/envjsnatives.cpp to your application sources.

2. Build the envjsnatives plugin (src/plugin) and put it in e.g. $QTDIR/plugins/script.
Then QScriptEngine::importExtension("envjs") can be used to load the native implementation.
env.js still needs to be evaluated separately before the plugin is loaded, otherwise
the plugin will throw an error.

API-specific notes:
- In order for asynchronous XMLHttpRequest requests to work, you need to be running an
event loop.

Tested with Envjs version 1.2.

See also examples/README.