1 |
4307
|
leinfelder
|
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
|
2 |
|
|
<html>
|
3 |
|
|
<head>
|
4 |
|
|
<title>
|
5 |
|
|
<a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008 Overview
|
6 |
|
|
</title>
|
7 |
|
|
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
|
8 |
|
|
<script>
|
9 |
|
|
function asd() {
|
10 |
|
|
|
11 |
|
|
parent.document.title="Mapbuilder.js Overview";
|
12 |
|
|
|
13 |
|
|
}
|
14 |
|
|
</script>
|
15 |
|
|
</head>
|
16 |
|
|
<body bgcolor="white" onload="asd();">
|
17 |
|
|
|
18 |
|
|
<!-- ========== START OF NAVBAR ========== -->
|
19 |
|
|
<a name="navbar_top"><!-- --></a>
|
20 |
|
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
21 |
|
|
<tr>
|
22 |
|
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
23 |
|
|
<a name="navbar_top_firstrow"><!-- --></a>
|
24 |
|
|
<table border="0" cellpadding="0" cellspacing="3">
|
25 |
|
|
<tr align="center" valign="top">
|
26 |
|
|
|
27 |
|
|
|
28 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
29 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
30 |
|
|
|
31 |
|
|
|
32 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
33 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
34 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
35 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
36 |
|
|
</tr>
|
37 |
|
|
</table>
|
38 |
|
|
</td>
|
39 |
|
|
<td bgcolor="#EEEEFF" align="right" valign="top">
|
40 |
|
|
<em>
|
41 |
|
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
42 |
|
|
</td>
|
43 |
|
|
</tr>
|
44 |
|
|
|
45 |
|
|
<tr>
|
46 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
47 |
|
|
PREV
|
48 |
|
|
NEXT</font></td>
|
49 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
50 |
|
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
51 |
|
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
52 |
|
|
|
53 |
|
|
<script>
|
54 |
|
|
<!--
|
55 |
|
|
if(window==top) {
|
56 |
|
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
57 |
|
|
}
|
58 |
|
|
//-->
|
59 |
|
|
</script>
|
60 |
|
|
<noscript>
|
61 |
|
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
62 |
|
|
</noscript>
|
63 |
|
|
</font></td>
|
64 |
|
|
</tr>
|
65 |
|
|
</table>
|
66 |
|
|
<!-- =========== END OF NAVBAR =========== -->
|
67 |
|
|
|
68 |
|
|
<hr>
|
69 |
|
|
<center>
|
70 |
|
|
|
71 |
|
|
<h2>Mapbuilder.js</h2>
|
72 |
|
|
|
73 |
|
|
</center>
|
74 |
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
<h4>Summary</h4>
|
79 |
|
|
<p>
|
80 |
|
|
|
81 |
|
|
No overview generated for 'Mapbuilder.js'<BR/><BR/>
|
82 |
|
|
|
83 |
|
|
</p>
|
84 |
|
|
|
85 |
|
|
<hr>
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
<table border="1" cellpadding="3" cellspacing="0" width="100%">
|
89 |
|
|
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
|
90 |
|
|
<td colspan=2><font size="+2">
|
91 |
|
|
|
92 |
|
|
<b>Class Summary</b>
|
93 |
|
|
|
94 |
|
|
</font></td>
|
95 |
|
|
</tr>
|
96 |
|
|
|
97 |
|
|
<tr bgcolor="white" class="TableRowColor">
|
98 |
|
|
<td width="15%"><b><a href="Mapbuilder.html">Mapbuilder</a></b></td>
|
99 |
|
|
<td> </td>
|
100 |
|
|
</tr>
|
101 |
|
|
|
102 |
|
|
</table>
|
103 |
|
|
<hr/>
|
104 |
|
|
|
105 |
|
|
|
106 |
|
|
<!-- ========== METHOD SUMMARY =========== -->
|
107 |
|
|
|
108 |
|
|
<a name="method_summary"><!-- --></a>
|
109 |
|
|
<table border="1" cellpadding="3" cellspacing="0" width="100%">
|
110 |
|
|
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
|
111 |
|
|
<td colspan=2>
|
112 |
|
|
<font size="+2">
|
113 |
|
|
<b>Method Summary</b>
|
114 |
|
|
</font>
|
115 |
|
|
</td>
|
116 |
|
|
</tr>
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
<tr bgcolor="white" class="TableRowColor">
|
120 |
|
|
<td align="right" valign="top" width="1%">
|
121 |
|
|
<font size="-1">
|
122 |
|
|
<code>static void</code>
|
123 |
|
|
</font>
|
124 |
|
|
</td>
|
125 |
|
|
<td>
|
126 |
|
|
<code>
|
127 |
|
|
<b>
|
128 |
|
|
<a href="GLOBALS.html#checkIESecurity">checkIESecurity</a></b>()
|
129 |
|
|
</code>
|
130 |
|
|
<br>
|
131 |
|
|
|
132 |
|
|
copied from sarissa, a function to check browser security setting in IE,
|
133 |
|
|
opens a help page if ActiveX objects are disabled.
|
134 |
|
|
</td>
|
135 |
|
|
</tr>
|
136 |
|
|
|
137 |
|
|
<tr bgcolor="white" class="TableRowColor">
|
138 |
|
|
<td align="right" valign="top" width="1%">
|
139 |
|
|
<font size="-1">
|
140 |
|
|
<code>static void</code>
|
141 |
|
|
</font>
|
142 |
|
|
</td>
|
143 |
|
|
<td>
|
144 |
|
|
<code>
|
145 |
|
|
<b>
|
146 |
|
|
<a href="GLOBALS.html#mapbuilderInit">mapbuilderInit</a></b>()
|
147 |
|
|
</code>
|
148 |
|
|
<br>
|
149 |
|
|
|
150 |
|
|
Initialise Mapbuilder if script has been loaded, else wait to be called
|
151 |
|
|
again.
|
152 |
|
|
</td>
|
153 |
|
|
</tr>
|
154 |
|
|
|
155 |
|
|
<tr bgcolor="white" class="TableRowColor">
|
156 |
|
|
<td align="right" valign="top" width="1%">
|
157 |
|
|
<font size="-1">
|
158 |
|
|
<code>static void</code>
|
159 |
|
|
</font>
|
160 |
|
|
</td>
|
161 |
|
|
<td>
|
162 |
|
|
<code>
|
163 |
|
|
<b>
|
164 |
|
|
<a href="GLOBALS.html#mbDoLoad">mbDoLoad</a></b>(initFunction)
|
165 |
|
|
</code>
|
166 |
|
|
<br>
|
167 |
|
|
|
168 |
|
|
Mapbuilder's main initialisation script.
|
169 |
|
|
</td>
|
170 |
|
|
</tr>
|
171 |
|
|
|
172 |
|
|
|
173 |
|
|
</table>
|
174 |
|
|
<p>
|
175 |
|
|
|
176 |
|
|
<!-- ========== END METHOD SUMMARY =========== -->
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
<pre class="sourceview"><span class="comment">/*
|
180 |
|
|
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
|
181 |
|
|
$Id: Mapbuilder.js 3819 2008-02-01 00:31:29Z ahocevar $
|
182 |
|
|
*/</span>
|
183 |
|
|
|
184 |
|
|
<span class="comment">/** get a time stamp at start of the page load */</span>
|
185 |
|
|
var mbTimerStart = new Date();
|
186 |
|
|
|
187 |
|
|
<span class="comment">/** the global config object */</span>
|
188 |
|
|
var config;
|
189 |
|
|
|
190 |
|
|
<span class="reserved">if</span>( typeof baseDir == <span class="literal">"undefined"</span>) {
|
191 |
|
|
<span class="comment">/** URL of Mapbuilder's lib/ directory. */</span>
|
192 |
|
|
var baseDir;
|
193 |
|
|
}
|
194 |
|
|
|
195 |
|
|
<span class="comment">/** mapbuilder environement settings, defaults to a .xml extension but is
|
196 |
|
|
auto-configured by the ant build script to .jsp for tomcat environment
|
197 |
|
|
the URL to this file will be pre-pended with the baseDir value.
|
198 |
|
|
*/</span>
|
199 |
|
|
var mbServerConfig = <span class="literal">"mapbuilderConfig.xml"</span>;
|
200 |
|
|
var mbNsUrl = <span class="literal">"http://mapbuilder.sourceforge.net/mapbuilder"</span>;
|
201 |
|
|
<span class="comment">
|
202 |
|
|
// LoadState Constants</span>
|
203 |
|
|
var MB_UNLOADED=0; // Scripts not loaded yet
|
204 |
|
|
var MB_LOAD_CORE=1; // Loading scripts loaded defined in Mapbuilder
|
205 |
|
|
var MB_LOAD_CONFIG=2; // Loading scripts loaded defined in Config
|
206 |
|
|
var MB_LOADED=3; // All scripts loaded
|
207 |
|
|
|
208 |
|
|
<span class="comment">/**
|
209 |
|
|
* This Object bootstraps the Mapbuilder libraries by loading the core
|
210 |
|
|
* script files.
|
211 |
|
|
* When Config.js is loaded, the script files for objects described in the
|
212 |
|
|
* Mapbuilder config file are loaded.
|
213 |
|
|
* Objects which have dependencies will trigger the dependancies to load
|
214 |
|
|
* when they are loaded.
|
215 |
|
|
*
|
216 |
|
|
* <span class="attrib">@constructor</span>
|
217 |
|
|
* <span class="attrib">@author</span> Cameron Shorter
|
218 |
|
|
* <span class="attrib">@requires</span> Config
|
219 |
|
|
* <span class="attrib">@requires</span> Listener
|
220 |
|
|
* <span class="attrib">@requires</span> ModelBase
|
221 |
|
|
* <span class="attrib">@requires</span> Sarissa
|
222 |
|
|
* <span class="attrib">@requires</span> Util
|
223 |
|
|
*/</span>
|
224 |
|
|
<span class="reserved">function</span> Mapbuilder() {
|
225 |
|
|
|
226 |
|
|
<span class="comment">/**
|
227 |
|
|
* Determines which Mapbuilder scripts are loading.
|
228 |
|
|
* TBD: Is it possible to use enumerated types in JS?
|
229 |
|
|
*/</span>
|
230 |
|
|
<span class="reserved">this</span>.loadState=MB_UNLOADED;
|
231 |
|
|
|
232 |
|
|
<span class="comment">/** Array of objects that are loading. Don't continue initialisation until
|
233 |
|
|
* all objects have loaded. */</span>
|
234 |
|
|
<span class="reserved">this</span>.loadingScripts=new Array();
|
235 |
|
|
|
236 |
|
|
<span class="comment">/** Array of scripts that have to be loaded ordered */</span>
|
237 |
|
|
<span class="reserved">this</span>.orderedScripts = new Array();
|
238 |
|
|
|
239 |
|
|
<span class="comment">/** Timer to load ordered scripts */</span>
|
240 |
|
|
<span class="reserved">this</span>.scriptLoader = null;
|
241 |
|
|
|
242 |
|
|
<span class="comment">/** Timer to periodically check if scripts have loaded. */</span>
|
243 |
|
|
<span class="reserved">this</span>.scriptsTimer=null;
|
244 |
|
|
|
245 |
|
|
<span class="comment">/**
|
246 |
|
|
* Called periodically and moves onto the next loadState when this round of
|
247 |
|
|
* scripts have loaded.
|
248 |
|
|
* For IE clients, object.readyState is used to check if scripts are loaded.
|
249 |
|
|
* Mozilla works fine without this function - I think it is single threaded.
|
250 |
|
|
*/</span>
|
251 |
|
|
<span class="reserved">this</span>.checkScriptsLoaded=<span class="reserved">function</span>() {
|
252 |
|
|
<span class="reserved">if</span> (document.readyState!=null){
|
253 |
|
|
<span class="comment"> // IE client</span>
|
254 |
|
|
<span class="comment">
|
255 |
|
|
// Scripts are removed from array when they have loaded</span>
|
256 |
|
|
<span class="reserved">while</span>(<span class="reserved">this</span>.loadingScripts.length>0
|
257 |
|
|
&&(<span class="reserved">this</span>.loadingScripts[0].readyState==<span class="literal">"loaded"</span>
|
258 |
|
|
||<span class="reserved">this</span>.loadingScripts[0].readyState==<span class="literal">"complete"</span>
|
259 |
|
|
||<span class="reserved">this</span>.loadingScripts[0].readyState==null))
|
260 |
|
|
{
|
261 |
|
|
<span class="reserved">this</span>.loadingScripts.shift();
|
262 |
|
|
}
|
263 |
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.loadingScripts.length==0 && <span class="reserved">this</span>.orderedScripts.length == 0){
|
264 |
|
|
<span class="reserved">this</span>.setLoadState(<span class="reserved">this</span>.loadState+1);
|
265 |
|
|
}
|
266 |
|
|
}
|
267 |
|
|
<span class="reserved">else</span>{
|
268 |
|
|
<span class="comment"> // Mozilla client</span>
|
269 |
|
|
<span class="reserved">if</span>(<span class="reserved">this</span>.loadState==MB_LOAD_CORE && config!=null){
|
270 |
|
|
<span class="comment"> // Config has finished loading</span>
|
271 |
|
|
<span class="reserved">this</span>.setLoadState(MB_LOAD_CONFIG);
|
272 |
|
|
}
|
273 |
|
|
}
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
<span class="comment">/**
|
277 |
|
|
* Move onto loading the next set of scripts.
|
278 |
|
|
* <span class="attrib">@param</span> newState The new loading state.
|
279 |
|
|
*/</span>
|
280 |
|
|
<span class="reserved">this</span>.setLoadState=<span class="reserved">function</span>(newState){
|
281 |
|
|
<span class="reserved">this</span>.loadState=newState;
|
282 |
|
|
switch (newState){
|
283 |
|
|
case MB_LOAD_CORE:
|
284 |
|
|
<span class="comment"> // core scripts have to be loaded in the correct order (needed for IE)</span>
|
285 |
|
|
<span class="reserved">this</span>.loadOrdered = true;
|
286 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/openlayers/OpenLayers.js"</span>);
|
287 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/sarissa/Sarissa.js"</span>);
|
288 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/sarissa/javeline_xpath.js"</span>);
|
289 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/sarissa/javeline_xslt.js"</span>);
|
290 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/sarissa/sarissa_dhtml.js"</span>);
|
291 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/sarissa/sarissa_ieemu_xpath.js"</span>);
|
292 |
|
|
<span class="comment"> //this.loadScript(baseDir+"/util/sarissa/sarissa_ieemu_xslt.js");//all deprecated</span>
|
293 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/proj4js/proj4js-compressed.js"</span>);
|
294 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/Util.js"</span>);
|
295 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/util/Listener.js"</span>);
|
296 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/model/ModelBase.js"</span>);
|
297 |
|
|
<span class="reserved">this</span>.loadScript(baseDir+<span class="literal">"/model/Config.js"</span>);
|
298 |
|
|
<span class="comment"> // from now on, scripts can be loaded in any order</span>
|
299 |
|
|
<span class="reserved">this</span>.loadOrdered = false;
|
300 |
|
|
break;
|
301 |
|
|
case MB_LOAD_CONFIG:
|
302 |
|
|
<span class="reserved">if</span>(document.readyState){
|
303 |
|
|
<span class="comment"> // IE</span>
|
304 |
|
|
config=new Config(mbConfigUrl);
|
305 |
|
|
config.loadConfigScripts();
|
306 |
|
|
}<span class="reserved">else</span>{
|
307 |
|
|
<span class="comment"> // Mozilla</span>
|
308 |
|
|
<span class="reserved">this</span>.setLoadState(MB_LOADED);
|
309 |
|
|
}
|
310 |
|
|
break;
|
311 |
|
|
case MB_LOADED:
|
312 |
|
|
window.clearInterval(<span class="reserved">this</span>.scriptsTimer);
|
313 |
|
|
break;
|
314 |
|
|
}
|
315 |
|
|
}
|
316 |
|
|
|
317 |
|
|
<span class="comment">/**
|
318 |
|
|
* Dynamically load a script file if it has not already been loaded.
|
319 |
|
|
* <span class="attrib">@param</span> url The url of the script.
|
320 |
|
|
* that loadScript was called
|
321 |
|
|
*/</span>
|
322 |
|
|
<span class="reserved">this</span>.loadScript=<span class="reserved">function</span>(url){
|
323 |
|
|
<span class="comment"> // if we are working with a compressed build, load only scripts that</span>
|
324 |
|
|
<span class="comment"> // are not part of the compressed build. This check is done by looking</span>
|
325 |
|
|
<span class="comment"> // into the global namespace for a function that has the same name as</span>
|
326 |
|
|
<span class="comment"> // the script file (without path and without .js). Because script files</span>
|
327 |
|
|
<span class="comment"> // in the util dir do not follow that pattern, exclude them from the</span>
|
328 |
|
|
<span class="comment"> // check separately.</span>
|
329 |
|
|
<span class="reserved">if</span>(typeof MapBuilder_Release == <span class="literal">"boolean"</span>) {
|
330 |
|
|
<span class="reserved">if</span> (url.indexOf(baseDir+<span class="literal">"/util/"</span>) != -1) {
|
331 |
|
|
<span class="reserved">return</span>;
|
332 |
|
|
}
|
333 |
|
|
var urlElements = url.split(<span class="literal">"/"</span>);
|
334 |
|
|
var scriptClass = urlElements[urlElements.length-1].replace(/.js$/, <span class="literal">""</span>);
|
335 |
|
|
<span class="reserved">if</span>(typeof window[scriptClass] == <span class="literal">"function"</span>) {
|
336 |
|
|
<span class="reserved">return</span>;
|
337 |
|
|
}
|
338 |
|
|
}
|
339 |
|
|
|
340 |
|
|
<span class="reserved">if</span>(!document.getElementById(url)){
|
341 |
|
|
var script = document.createElement(<span class="literal">'script'</span>);
|
342 |
|
|
script.src = url;
|
343 |
|
|
script.id = url;
|
344 |
|
|
script.defer = false; //not sure of effect of <span class="reserved">this</span>?
|
345 |
|
|
script.type = <span class="literal">"text/javascript"</span>;
|
346 |
|
|
<span class="reserved">if</span> (document.readyState && <span class="reserved">this</span>.loadOrdered == true) {
|
347 |
|
|
<span class="comment"> // in IE, mark the script as ordered</span>
|
348 |
|
|
<span class="reserved">this</span>.orderedScripts.push(script);
|
349 |
|
|
<span class="reserved">if</span> (!<span class="reserved">this</span>.scriptLoader) {
|
350 |
|
|
<span class="reserved">this</span>.scriptLoader = window.setInterval(<span class="literal">'mapbuilder.loadNextScript()'</span>, 50);
|
351 |
|
|
}
|
352 |
|
|
} <span class="reserved">else</span> {
|
353 |
|
|
<span class="comment"> // add to dom tree, except if we are using IE and want to load ordered</span>
|
354 |
|
|
document.getElementsByTagName(<span class="literal">'head'</span>)[0].appendChild(script);
|
355 |
|
|
}
|
356 |
|
|
<span class="reserved">if</span> (document.readyState) {
|
357 |
|
|
<span class="comment"> // this is only needed for IE</span>
|
358 |
|
|
<span class="reserved">this</span>.loadingScripts.push(script);
|
359 |
|
|
}
|
360 |
|
|
}
|
361 |
|
|
}
|
362 |
|
|
|
363 |
|
|
<span class="comment">/**
|
364 |
|
|
* loads one script after another - only for IE. This function is run in a
|
365 |
|
|
* 50ms interval and clears its interval if there are no more scripts to
|
366 |
|
|
* load. It actually loads the first script from the orderedScripts array.
|
367 |
|
|
*/</span>
|
368 |
|
|
<span class="reserved">this</span>.loadNextScript = <span class="reserved">function</span>() {
|
369 |
|
|
<span class="reserved">if</span> (<span class="reserved">this</span>.orderedScripts.length == 0) {
|
370 |
|
|
window.clearInterval(<span class="reserved">this</span>.scriptLoader);
|
371 |
|
|
<span class="reserved">this</span>.scriptLoader = null;
|
372 |
|
|
} <span class="reserved">else</span> {
|
373 |
|
|
var script = <span class="reserved">this</span>.orderedScripts[0];
|
374 |
|
|
<span class="reserved">if</span> (!script.loading) {
|
375 |
|
|
script.loading = true;
|
376 |
|
|
<span class="reserved">this</span>.doLoadScript(script);
|
377 |
|
|
}
|
378 |
|
|
}
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
<span class="comment">/**
|
382 |
|
|
* starts script loading by adding the script node to the dom tree - IE only.
|
383 |
|
|
* This function adds a readyState handler to the script node.
|
384 |
|
|
*/</span>
|
385 |
|
|
<span class="reserved">this</span>.doLoadScript = <span class="reserved">function</span>(script) {
|
386 |
|
|
var objRef = <span class="reserved">this</span>;
|
387 |
|
|
script.onreadystatechange = <span class="reserved">function</span>(){objRef.checkScriptState(<span class="reserved">this</span>)};
|
388 |
|
|
document.getElementsByTagName(<span class="literal">'head'</span>)[0].appendChild(script);
|
389 |
|
|
}
|
390 |
|
|
|
391 |
|
|
<span class="comment">/**
|
392 |
|
|
* readyState handler for scripts - IE only. This will remove the script from
|
393 |
|
|
* the array of scripts that have still to be loaded.
|
394 |
|
|
*/</span>
|
395 |
|
|
<span class="reserved">this</span>.checkScriptState = <span class="reserved">function</span>(script) {
|
396 |
|
|
<span class="reserved">if</span> (script.readyState == <span class="literal">"loaded"</span> || script.readyState == <span class="literal">"complete"</span>) {
|
397 |
|
|
<span class="reserved">for</span> (var i=0; i<<span class="reserved">this</span>.orderedScripts.length; i++) {
|
398 |
|
|
<span class="reserved">if</span> (script == <span class="reserved">this</span>.orderedScripts[i]) {
|
399 |
|
|
<span class="reserved">this</span>.orderedScripts.splice(i, 1);
|
400 |
|
|
break;
|
401 |
|
|
}
|
402 |
|
|
}
|
403 |
|
|
}
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
<span class="comment">/**
|
407 |
|
|
* Internal function to load scripts for components that don't have <scriptfile>
|
408 |
|
|
* specified in the config file.
|
409 |
|
|
* <span class="attrib">@param</span> xPath Xpath match of components from the Config file.
|
410 |
|
|
* <span class="attrib">@param</span> dir The directory the script is located in.
|
411 |
|
|
*/</span>
|
412 |
|
|
<span class="reserved">this</span>.loadScriptsFromXpath=<span class="reserved">function</span>(nodes,dir) {
|
413 |
|
|
<span class="comment"> //var nodes = this.doc.selectNodes(xPath);</span>
|
414 |
|
|
<span class="reserved">for</span> (var i=0; i<nodes.length; i++) {
|
415 |
|
|
<span class="reserved">if</span> (nodes[i].selectSingleNode(<span class="literal">"mb:scriptFile"</span>)==null){
|
416 |
|
|
scriptFile = baseDir+<span class="literal">"/"</span>+dir+nodes[i].nodeName+<span class="literal">".js"</span>;
|
417 |
|
|
<span class="reserved">this</span>.loadScript(scriptFile);
|
418 |
|
|
}
|
419 |
|
|
}
|
420 |
|
|
}
|
421 |
|
|
<span class="comment">
|
422 |
|
|
//derive the baseDir value by looking for the script tag that loaded this file</span>
|
423 |
|
|
<span class="reserved">if</span> (!baseDir) {
|
424 |
|
|
var head = document.getElementsByTagName(<span class="literal">'head'</span>)[0];
|
425 |
|
|
var nodes = head.childNodes;
|
426 |
|
|
<span class="reserved">for</span> (var i=0; i<nodes.length; ++i ){
|
427 |
|
|
var src = nodes.item(i).src;
|
428 |
|
|
<span class="reserved">if</span> (src) {
|
429 |
|
|
<span class="comment"> //var index = src.indexOf("/Mapbuilder.js");</span>
|
430 |
|
|
<span class="comment"> // Modified so it will work with original or compressed file</span>
|
431 |
|
|
var index = src.indexOf(<span class="literal">"/Mapbuilder.js"</span>);
|
432 |
|
|
<span class="reserved">if</span> (index>=0) {
|
433 |
|
|
baseDir = src.substring(0, index);
|
434 |
|
|
} <span class="reserved">else</span> {
|
435 |
|
|
index = src.indexOf(<span class="literal">"/MapbuilderCompressed.js"</span>);
|
436 |
|
|
<span class="reserved">if</span> (index>=0) {
|
437 |
|
|
baseDir = src.substring(0, index);
|
438 |
|
|
}
|
439 |
|
|
}
|
440 |
|
|
}
|
441 |
|
|
}
|
442 |
|
|
}
|
443 |
|
|
<span class="comment">
|
444 |
|
|
// Start loading core scripts.</span>
|
445 |
|
|
<span class="reserved">this</span>.setLoadState(MB_LOAD_CORE);
|
446 |
|
|
<span class="comment">
|
447 |
|
|
// Start a timer which periodically calls checkScriptsLoaded().</span>
|
448 |
|
|
<span class="reserved">this</span>.scriptsTimer=window.setInterval(<span class="literal">'mapbuilder.checkScriptsLoaded()'</span>,100);
|
449 |
|
|
}
|
450 |
|
|
|
451 |
|
|
<span class="comment">/**
|
452 |
|
|
* copied from sarissa, a function to check browser security setting in IE,
|
453 |
|
|
* opens a help page if ActiveX objects are disabled.
|
454 |
|
|
*/</span>
|
455 |
|
|
<span class="reserved">function</span> checkIESecurity()
|
456 |
|
|
{
|
457 |
|
|
var testPrefixes = [<span class="literal">"Msxml2.DOMDocument.5.0"</span>, <span class="literal">"Msxml2.DOMDocument.4.0"</span>, <span class="literal">"Msxml2.DOMDocument.3.0"</span>, <span class="literal">"MSXML2.DOMDocument"</span>, <span class="literal">"MSXML.DOMDocument"</span>, <span class="literal">"Microsoft.XMLDOM"</span>];
|
458 |
|
|
<span class="comment"> // found progID flag</span>
|
459 |
|
|
var bFound = false;
|
460 |
|
|
<span class="reserved">for</span>(var i=0; i < testPrefixes.length && !bFound; i++) {
|
461 |
|
|
try {
|
462 |
|
|
var oDoc = new ActiveXObject(testPrefixes[i]);
|
463 |
|
|
bFound = true;
|
464 |
|
|
}
|
465 |
|
|
catch (e) {
|
466 |
|
|
<span class="comment"> //trap; try next progID</span>
|
467 |
|
|
}
|
468 |
|
|
}
|
469 |
|
|
<span class="reserved">if</span> (!bFound) window.open(<span class="literal">"/mapbuilder/docs/help/IESetup.html"</span>); //TBD: set <span class="reserved">this</span> URL in config
|
470 |
|
|
}
|
471 |
|
|
|
472 |
|
|
<span class="reserved">if</span> (navigator.userAgent.toLowerCase().indexOf(<span class="literal">"msie"</span>) > -1) checkIESecurity();
|
473 |
|
|
var mapbuilder=new Mapbuilder();
|
474 |
|
|
|
475 |
|
|
<span class="comment">/**
|
476 |
|
|
* Initialise Mapbuilder if script has been loaded, else wait to be called
|
477 |
|
|
* again.
|
478 |
|
|
*/</span>
|
479 |
|
|
<span class="reserved">function</span> mapbuilderInit(){
|
480 |
|
|
<span class="reserved">if</span>(mapbuilder && mapbuilder.loadState==MB_LOADED){
|
481 |
|
|
window.clearInterval(mbTimerId);
|
482 |
|
|
config.parseConfig(config);
|
483 |
|
|
<span class="reserved">if</span> (Proj4js) {
|
484 |
|
|
Proj4js.libPath = baseDir+<span class="literal">"/util/proj4js/"</span>;
|
485 |
|
|
Proj4js.proxyScript = config.proxyUrl+<span class="literal">'?url='</span>;
|
486 |
|
|
}
|
487 |
|
|
config.callListeners(<span class="literal">"init"</span>);
|
488 |
|
|
var mbTimerStop = new Date();
|
489 |
|
|
<span class="comment"> //alert("load time:"+(mbTimerStop.getTime()-mbTimerStart.getTime()) );</span>
|
490 |
|
|
<span class="reserved">if</span> (window.mbInit) window.mbInit();
|
491 |
|
|
config.callListeners(<span class="literal">"loadModel"</span>);
|
492 |
|
|
}
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
<span class="comment">/** Timer used when checking if scripts have loaded. */</span>
|
496 |
|
|
var mbTimerId;
|
497 |
|
|
|
498 |
|
|
<span class="comment">/**
|
499 |
|
|
* Mapbuilder's main initialisation script.
|
500 |
|
|
* This should be called from the main html file using:
|
501 |
|
|
* <body onload="mbDoLoad()">
|
502 |
|
|
* <span class="attrib">@param</span> initFunction Optional - A function reference that will be called after
|
503 |
|
|
* config.init() has been called. This is to give application code a chance to
|
504 |
|
|
* do initialization and be guaranteed that all objects exist (inlcuding config).
|
505 |
|
|
*/</span>
|
506 |
|
|
<span class="reserved">function</span> mbDoLoad(initFunction) {
|
507 |
|
|
<span class="comment"> // See if scripts have been loaded every 100msecs, then call config.init().</span>
|
508 |
|
|
mbTimerId=window.setInterval(<span class="literal">'mapbuilderInit()'</span>,100);
|
509 |
|
|
<span class="reserved">if</span> (initFunction) window.mbInit = initFunction;
|
510 |
|
|
}
|
511 |
|
|
</pre>
|
512 |
|
|
<hr>
|
513 |
|
|
|
514 |
|
|
|
515 |
|
|
|
516 |
|
|
<!-- ========== START OF NAVBAR ========== -->
|
517 |
|
|
<a name="navbar_top"><!-- --></a>
|
518 |
|
|
<table border="0" width="100%" cellpadding="1" cellspacing="0">
|
519 |
|
|
<tr>
|
520 |
|
|
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
|
521 |
|
|
<a name="navbar_top_firstrow"><!-- --></a>
|
522 |
|
|
<table border="0" cellpadding="0" cellspacing="3">
|
523 |
|
|
<tr align="center" valign="top">
|
524 |
|
|
|
525 |
|
|
|
526 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
|
527 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
|
528 |
|
|
|
529 |
|
|
|
530 |
|
|
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
|
531 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
|
532 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
|
533 |
|
|
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
|
534 |
|
|
</tr>
|
535 |
|
|
</table>
|
536 |
|
|
</td>
|
537 |
|
|
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
|
538 |
|
|
<b><a href='http://mapbuilder.sourceforge.net'>Community Map Builder</a> 27 Apr 2008</b></em>
|
539 |
|
|
</td>
|
540 |
|
|
</tr>
|
541 |
|
|
|
542 |
|
|
<tr>
|
543 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
544 |
|
|
PREV
|
545 |
|
|
NEXT</font></td>
|
546 |
|
|
<td bgcolor="white" class="NavBarCell2"><font size="-2">
|
547 |
|
|
<a href="index.html" target="_top"><b>FRAMES</b></a>
|
548 |
|
|
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
|
549 |
|
|
|
550 |
|
|
<script>
|
551 |
|
|
<!--
|
552 |
|
|
if(window==top) {
|
553 |
|
|
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
|
554 |
|
|
}
|
555 |
|
|
//-->
|
556 |
|
|
</script>
|
557 |
|
|
<noscript>
|
558 |
|
|
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
|
559 |
|
|
</noscript>
|
560 |
|
|
</font></td>
|
561 |
|
|
</tr>
|
562 |
|
|
</table>
|
563 |
|
|
<!-- =========== END OF NAVBAR =========== -->
|
564 |
|
|
|
565 |
|
|
<hr>
|
566 |
|
|
<font size="-1">
|
567 |
|
|
|
568 |
|
|
</font>
|
569 |
|
|
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Sun Apr 27 20:30:54 2008</div>
|
570 |
|
|
</body>
|
571 |
|
|
</html>
|