]> git.wh0rd.org - tt-rss.git/blame - lib/dojo/_base/configSpidermonkey.js
if plugin method get_css(), embed plugin-specific css to main UI
[tt-rss.git] / lib / dojo / _base / configSpidermonkey.js
CommitLineData
1354d172 1// TODO: this file needs to be converted to the v1.7 loader
2f01fe57
AD
2
3
a089699c
AD
4/*
5 * SpiderMonkey host environment
6 */
7
2f01fe57 8if(dojo.config["baseUrl"]){
a089699c 9 dojo.baseUrl = dojo.config["baseUrl"];
2f01fe57 10}else{
a089699c 11 dojo.baseUrl = "./";
2f01fe57 12}
a089699c
AD
13
14dojo._name = 'spidermonkey';
15
16/*=====
17dojo.isSpidermonkey = {
81bea17a 18 // summary: Detect spidermonkey
2f01fe57 19};
a089699c
AD
20=====*/
21
22dojo.isSpidermonkey = true;
81bea17a
AD
23dojo.exit = function(exitcode){
24 quit(exitcode);
1354d172 25};
a089699c
AD
26
27if(typeof print == "function"){
28 console.debug = print;
2f01fe57 29}
a089699c
AD
30
31if(typeof line2pc == 'undefined'){
32 throw new Error("attempt to use SpiderMonkey host environment when no 'line2pc' global");
2f01fe57 33}
a089699c
AD
34
35dojo._spidermonkeyCurrentFile = function(depth){
81bea17a 36 //
a089699c
AD
37 // This is a hack that determines the current script file by parsing a
38 // generated stack trace (relying on the non-standard "stack" member variable
39 // of the SpiderMonkey Error object).
81bea17a 40 //
a089699c
AD
41 // If param depth is passed in, it'll return the script file which is that far down
42 // the stack, but that does require that you know how deep your stack is when you are
43 // calling.
81bea17a 44 //
1354d172
AD
45 var s = '';
46 try{
a089699c
AD
47 throw Error("whatever");
48 }catch(e){
49 s = e.stack;
50 }
1354d172
AD
51 // lines are like: bu_getCurrentScriptURI_spidermonkey("ScriptLoader.js")@burst/Runtime.js:101
52 var matches = s.match(/[^@]*\.js/gi);
53 if(!matches){
a089699c
AD
54 throw Error("could not parse stack string: '" + s + "'");
55 }
1354d172
AD
56 var fname = (typeof depth != 'undefined' && depth) ? matches[depth + 1] : matches[matches.length - 1];
57 if(!fname){
a089699c
AD
58 throw Error("could not find file name in stack string '" + s + "'");
59 }
1354d172
AD
60 //print("SpiderMonkeyRuntime got fname '" + fname + "' from stack string '" + s + "'");
61 return fname;
62};
a089699c 63
81bea17a 64// print(dojo._spidermonkeyCurrentFile(0));
a089699c
AD
65
66dojo._loadUri = function(uri){
67 // spidermonkey load() evaluates the contents into the global scope (which
68 // is what we want).
81bea17a 69 // TODO: sigh, load() does not return a useful value.
a089699c 70 // Perhaps it is returning the value of the last thing evaluated?
1354d172
AD
71 // var ok =
72 load(uri);
a089699c
AD
73 // console.log("spidermonkey load(", uri, ") returned ", ok);
74 return 1;
1354d172 75};
a089699c
AD
76
77//Register any module paths set up in djConfig. Need to do this
78//in the hostenvs since hostenv_browser can read djConfig from a
79//script tag's attribute.
2f01fe57 80if(dojo.config["modulePaths"]){
a089699c
AD
81 for(var param in dojo.config["modulePaths"]){
82 dojo.registerModulePath(param, dojo.config["modulePaths"][param]);
83 }
2f01fe57 84}