forked from craftyjs/Crafty
-
Notifications
You must be signed in to change notification settings - Fork 0
/
crafty-local.js
49 lines (46 loc) · 973 Bytes
/
crafty-local.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
(function (window) {
var include = [
'core',
'intro',
'HashMap',
'2D',
'collision',
'DOM',
'extensions',
'canvas',
'controls',
'animation',
'sprite',
'drawing',
'isometric',
'particles',
'sound',
'storage',
'html',
'math',
'text',
'loader',
'outro'
],
l = include.length, i, tr = new XMLHttpRequest(), output = '', url, base = '', scripts = document.getElementsByTagName('script');
for (i=0; i<scripts.length; i++) {
if (scripts[i].src.indexOf('crafty-local.js') != -1) {
base = scripts[i].src.replace('crafty-local.js', '')+'/src/';
break;
}
}
for (i=0; i<l; i++) {
url = base+include[i]+'.js';
tr.open("GET", url, false);
try {
tr.send(null);
}
catch (e) {
alert("Your security settings prevent access to the local file-system. \n\r Access to restricted URI denied code 1012");
break;
}
output += tr.responseText;
}
output += "\n//@ sourceURL=crafty.js";
eval(output);
})(window);