-
Notifications
You must be signed in to change notification settings - Fork 3
/
include.js
84 lines (77 loc) · 2.31 KB
/
include.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
(function() {
var __core__=XJSX.__XJSXCORE__();
var FUNCTION = 0xD;
/** include**/
__core__.createModule([
{
keyword: "include",
callback: function (url) {
var url;
try {
if (!(url = this.eval("[" + url + "][0]"))) {
throw "'" + url + "'" + " is not a valid argument";
}
var self = this;
/*XRequest(url,function() {
self.putChild(__core__.XJSXCompiler(__core__.domParser(arguments[0]),self.eval).childNodes)
},true)*/
var http = new XMLHttpRequest();
self.global.http = http;
http.addEventListener("load", function () {
if (!self.isVisible()) {
this.removeEventListener(arguments[0].type, arguments.callee);
this.abort();
return;
}
/*if (!http.response) {
__core__.dispatcher(http,"error")
console.error(url+"\npath could not be included"+"\nmake sure the provided url is a valid html file")
return
}
*/
self.putChild(
__core__.XJSXCompiler(
__core__.domParser(http.response, http.abort()),
self.eval
).childNodes
);
});
http.open("get", url);
http.send();
} catch (e) {
console.error("include:", url, e);
}
},
type: FUNCTION,
},
{
keyword: "catch",
onload: function () {
this.killProcess();
},
onprogress: function () {
this.disable();
},
callback: function () {
var self = this;
var doc = document.createDocumentFragment();
this.appendAllTo(doc);
if (!self.global.http) {
self.putChild(__core__.XJSXCompiler(doc, self.eval));
console.error(self.parentParams.join(":"), "uncaught error");
return;
}
self.global.http.addEventListener("error", function () {
if (!self.isVisible()) {
this.removeEventListener(arguments[0].type, arguments.callee);
this.abort();
return;
}
self.putChild(__core__.XJSXCompiler(doc, self.eval));
this.abort();
delete self.global.http;
});
},
},
]);
})()