roojs-ui.js
[roojs1] / buildSDK / debugLoader.js
1 //<script type="text/javascript">
2 // file to load 
3
4 // could probably do this with anon-functions..
5
6
7
8 // -----------------------------------
9 // this stuff doesnt work!!!
10
11 // -----------------------------------
12
13 function RooDebugLoader(fn)
14 {
15     
16     // these fire off too fast for the thing to work correctly...
17     window.setTimeout(function() {
18             //console.log("load" + fn);
19             if (typeof(fn) == 'string') {
20                 RooDebugLoader.realLoad(fn);
21                 return;
22             }
23             fn.call();
24             
25         }, RooDebugLoader.timer);
26     RooDebugLoader.timer += 200;
27 }
28     
29  RooDebugLoader.realLoad = function (fn)   
30     function getpath()
31     {
32         if (typeof(RooDebugLoader.path) != 'undefined'){
33             return RooDebugLoader.path;
34         }
35         var sts = document.getElementsByTagName('script');
36         for (var i =0;i<sts.length;i++) {
37             if (/\/roojs-debug.js$/.test(sts[i].getAttribute('src'))) {
38                 RooDebugLoader.path = sts[i].getAttribute('src').replace(/\/roojs-debug.js$/,'')
39                 return RooDebugLoader.path;
40             }
41         }
42         alert("can not find path to roojs-debug.js");
43         throw "oops";
44         
45         
46     }
47     
48     var html_doc = document.getElementsByTagName('head')[0];
49     
50     if (/\.js$/.test(fn)) {
51             
52         
53         var js = document.createElement('script');
54         js.setAttribute('language', 'javascript');
55         js.setAttribute('type', 'text/javascript');
56         //js.setAttribute('src', getpath() + '/' + fn +'?_ts='+Math.random());
57         js.setAttribute('src', getpath() + '/' + fn);
58         html_doc.appendChild(js);
59         return
60     }
61     if (/\.css$/.test(fn)) {
62             
63         //<link rel="stylesheet" type="text/css" href="App_Themes/HCCCommonStyle.css" />
64         var js = document.createElement('link');
65         js.setAttribute('rel', 'stylesheet');
66         js.setAttribute('type', 'text/css');
67         
68         js.setAttribute('href', getpath() + '/' + fn);
69         html_doc.appendChild(js);
70     }
71 }
72 RooDebugLoader.timer = 200;
73 RooDebugLoader.loaded = false;
74 RooDebugLoader.onload = function()
75 {
76     if (RooDebugLoader.loaded) {
77         return false;
78     }
79     if (!document || !document.getElementsByTagName('script').length) {
80         window.setTimeout(RooDebugLoader.onload, 100);
81     }
82     RooDebugLoader.loaded = true;
83     RooDebugLoader.loader();
84 }
85 //RooDebugLoader.onload();
86 window.setTimeout(RooDebugLoader.onload, 100);
87
88 RooDebugLoader.loader = function () {
89     
90 RooDebugLoader('css/reset-min.css');
91 RooDebugLoader('css/core.css');
92 RooDebugLoader('css/basic-dialog.css');
93 RooDebugLoader('css/button.css');
94 RooDebugLoader('css/inline-editor.css');
95 RooDebugLoader('css/layout.css');
96 RooDebugLoader('css/qtips.css');
97 RooDebugLoader('css/resizable.css')
98 RooDebugLoader('css/tabs.css');
99 RooDebugLoader('css/toolbar.css');
100 RooDebugLoader('css/tree.css');
101 RooDebugLoader('css/ytheme-gray.css');
102
103
104
105