]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/configRhino.js
2cbbf8887bf38d26c8f465155851692be117b076
1 function rhinoDojoConfig(config
, baseUrl
, rhinoArgs
){
3 // This module provides bootstrap configuration for running dojo in rhino.
5 // TODO: v1.6 tries to set dojo.doc and dojo.body in rhino; why?
7 // get a minimal console up
8 var log = function(hint
, args
){
9 print((hint
? hint
+ ":" : "") + args
[0]);
10 for(var i
= 1; i
< args
.length
; i
++){
11 print(", " + args
[i
]);
14 // intentionally define console in the global namespace
16 log: function(){ log(0, arguments
); },
17 error: function(){ log("ERROR", arguments
); },
18 warn: function(){ log("WARN", arguments
); }
21 // any command line arguments with the load flag are pushed into deps
22 for(var deps
= [], i
= 0; i
< rhinoArgs
.length
; i
++){
23 var arg
= (rhinoArgs
[i
] + "").split("=");
29 // provides timed callbacks using Java threads
30 if(typeof setTimeout
== "undefined" || typeof clearTimeout
== "undefined"){
32 clearTimeout = function(idx
){
33 if(!timeouts
[idx
]){ return; }
37 setTimeout = function(func
, delay
){
45 java
.lang
.Thread
.currentThread().sleep(this.sleepTime
);
50 console
.debug("Error running setTimeout thread:" + e
);
55 var runnable
= new java
.lang
.Runnable(def
);
56 var thread
= new java
.lang
.Thread(runnable
);
58 return timeouts
.push(thread
) - 1;
62 var isLocal = function(url
){
63 return (new java
.io
.File(url
)).exists();
66 // reset the has cache with node-appropriate values;
76 "dojo-loader-catches":1,
77 "dojo-dom-ready-api":0,
78 "dojo-publish-privates":1,
84 for(var p
in hasCache
){
85 config
.hasCache
[p
] = hasCache
[p
];
88 // reset some configuration switches with rhino-appropriate values
91 commandLineArgs
:rhinoArgs
,
94 locale
:String(java
.util
.Locale
.getDefault().toString().replace('_', '-').toLowerCase()),
97 injectUrl: function(url
, callback
){
102 require
.eval(readUrl(url
, "UTF-8"));
106 console
.log("failed to load resource (" + url
+ ")");
111 getText: function(url
, sync
, onLoad
){
112 // TODO: test https://bugzilla.mozilla.org/show_bug.cgi?id=471005; see v1.6 hostenv_rhino
113 // note: async mode not supported in rhino
114 onLoad(isLocal(url
) ? readFile(url
, "UTF-8") : readUrl(url
, "UTF-8"));
118 for(p
in rhinoConfig
){
119 config
[p
] = rhinoConfig
[p
];