summaryrefslogtreecommitdiff
path: root/lib/dojo/_base/_loader/hostenv_rhino.js
blob: 9cd88271384aec74de4d49159e2ff67255f39cbe (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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
	Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


if(dojo.config["baseUrl"]){
dojo.baseUrl=dojo.config["baseUrl"];
}else{
dojo.baseUrl="./";
}
dojo.locale=dojo.locale||String(java.util.Locale.getDefault().toString().replace("_","-").toLowerCase());
dojo._name="rhino";
dojo.isRhino=true;
if(typeof print=="function"){
console.debug=print;
}
if(!("byId" in dojo)){
dojo.byId=function(id,_1){
if(id&&(typeof id=="string"||id instanceof String)){
if(!_1){
_1=document;
}
return _1.getElementById(id);
}
return id;
};
}
dojo._isLocalUrl=function(_2){
var _3=(new java.io.File(_2)).exists();
if(!_3){
var _4;
try{
_4=(new java.net.URL(_2)).openStream();
_4.close();
}
finally{
if(_4&&_4.close){
_4.close();
}
}
}
return _3;
};
dojo._loadUri=function(_5,cb){
try{
var _6;
try{
_6=dojo._isLocalUrl(_5);
}
catch(e){
return false;
}
if(cb){
var _7=(_6?readText:readUri)(_5,"UTF-8");
if(!eval("'‏'").length){
_7=String(_7).replace(/[\u200E\u200F\u202A-\u202E]/g,function(_8){
return "\\u"+_8.charCodeAt(0).toString(16);
});
}
cb(eval("("+_7+")"));
}else{
load(_5);
}
return true;
}
catch(e){
return false;
}
};
dojo.exit=function(_9){
quit(_9);
};
function readText(_a,_b){
_b=_b||"utf-8";
var jf=new java.io.File(_a);
var is=new java.io.FileInputStream(jf);
return dj_readInputStream(is,_b);
};
function readUri(_c,_d){
var _e=(new java.net.URL(_c)).openConnection();
_d=_d||_e.getContentEncoding()||"utf-8";
var is=_e.getInputStream();
return dj_readInputStream(is,_d);
};
function dj_readInputStream(is,_f){
var _10=new java.io.BufferedReader(new java.io.InputStreamReader(is,_f));
try{
var sb=new java.lang.StringBuffer();
var _11="";
while((_11=_10.readLine())!==null){
sb.append(_11);
sb.append(java.lang.System.getProperty("line.separator"));
}
return sb.toString();
}
finally{
_10.close();
}
};
dojo._getText=function(uri,_12){
try{
var _13=dojo._isLocalUrl(uri);
var _14=(_13?readText:readUri)(uri,"UTF-8");
if(_14!==null){
_14+="";
}
return _14;
}
catch(e){
if(_12){
return null;
}else{
throw e;
}
}
};
dojo.doc=typeof document!="undefined"?document:null;
dojo.body=function(){
return document.body;
};
if(typeof setTimeout=="undefined"||typeof clearTimeout=="undefined"){
dojo._timeouts=[];
clearTimeout=function(idx){
if(!dojo._timeouts[idx]){
return;
}
dojo._timeouts[idx].stop();
};
setTimeout=function(_15,_16){
var def={sleepTime:_16,hasSlept:false,run:function(){
if(!this.hasSlept){
this.hasSlept=true;
java.lang.Thread.currentThread().sleep(this.sleepTime);
}
try{
_15();
}
catch(e){
}
}};
var _17=new java.lang.Runnable(def);
var _18=new java.lang.Thread(_17);
_18.start();
return dojo._timeouts.push(_18)-1;
};
}
if(dojo.config["modulePaths"]){
for(var param in dojo.config["modulePaths"]){
dojo.registerModulePath(param,dojo.config["modulePaths"][param]);
}
}