-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
60 lines (51 loc) · 1.47 KB
/
index.js
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
if(typeof window === 'undefined')
window = {};
if(window.global != global) {
window.global = window;
global = window;
}
var lithp = require('lithp');
window.Lithp = lithp;
var util = require('util');
window.util = util; // expose to HTML pages
var files;
try {
files = require('./files');
} catch (e) {
console.error("Please run genfiles.sh");
return;
}
//window.Lithp.set_debug_flag(true);
var instance = new lithp.Lithp();
window.lithpInstance = instance;
var code = files["webide/webide.ast"];
if(code === undefined)
console.log("Error: webide not found");
if(global._lithp === undefined)
global._lithp = {};
global._lithp.browserify = true;
global._lithp.fileCache = files;
var ideParsed = lithp.Parser(code, {ast: true, finalize: true});
instance.setupDefinitions(ideParsed, "webide.ast")
instance.Define(ideParsed, "__AST__", lithp.Types.Atom('true'));
instance.Define(ideParsed, "RUNTIME", "browser");
instance.run(ideParsed);
window.onload = function() {
if(instance.Defined(ideParsed, "HTML_TOOLKIT") == lithp.Types.Atom('true')) {
console.log("Invoking onReady behaviour");
try {
instance.Invoke(ideParsed, "onReady/1", [document]);
} catch (e) {
console.log(e.stack);
}
}
if(window.jQuery && instance.Defined(ideParsed, "JQUERY_TOOLKIT") == lithp.Types.Atom('true')) {
console.log("Invoking jQuery behaviour");
window.jQuery.noConflict();
try {
instance.Invoke(ideParsed, "onJQuery/1", [window.jQuery])
} catch (e) {
console.log(e.stack);
}
}
};