Project

General

Profile

1
/*
2
License: LGPL as per: http://www.gnu.org/copyleft/lesser.html
3
$Id: MapbuilderServerLoad.js 2546 2007-01-23 12:07:39Z gjvoosten $
4
*/
5

    
6
/** URL of Mapbuilder's lib/ directory. */
7
var baseDir;
8

    
9
function Mapbuilder() {
10
  /**
11
   * Dynamically load a script file if it has not already been loaded.
12
   * @param url The url of the script.
13
   */
14
  this.loadScript=function(url){
15
    //no-op so that dynamic verison doesn't break
16
  }
17

    
18
  /**
19
   * Internal function to load scripts for components that don't have <scriptfile>
20
   * specified in the config file.
21
   * @param xPath Xpath match of components from the Config file.
22
   * @param dir The directory the script is located in.
23
   */
24
  this.loadScriptsFromXpath=function(xPath,dir) {
25
    var nodes = this.doc.selectNodes(xPath);
26
    for (var i=0; i<nodes.length; i++) {
27
      if (nodes[i].selectSingleNode("mb:scriptFile")==null){
28
        scriptFile = baseDir+"/"+dir+nodes[i].nodeName+".js";
29
        this.loadScript(scriptFile);
30
      }
31
    }
32
  }
33

    
34
  //derive the baseDir value by looking for the script tag that loaded this file
35
  var head = document.getElementsByTagName('head')[0];
36
  var nodes = head.childNodes;
37
  for (var i=0; i<nodes.length; ++i ){
38
    var src = nodes.item(i).src;
39
    if (src) {
40
      var index = src.indexOf("/MapbuilderServerLoad.js");
41
      if (index>=0) {
42
        baseDir = src.substring(0, index);
43
      }
44
    }
45
  }
46
}
47

    
48
var mapbuilder=new Mapbuilder();
49

    
50
/**
51
 * Mapbuilder's main initialisation script.
52
 * This should be called from the main html file using:
53
 *   <body onload="mbDoLoad()">
54
 */
55
function mbDoLoad() {
56
  config.init(config);
57
  var mbTimerStop = new Date();
58
  //alert("load time:"+(mbTimerStop.getTime()-mbTimerStart.getTime()) );
59
  config.callListeners("loadModel");
60
}
(4-4/6)