/* * Copyright (c) 2008-2010 Institut Geographique National France, released under the * BSD license. */ (function() { /** * Before creating the Geoportal namespace, check to see if * Geoportal.singleFile is true. This occurs if the * Geoportail/SingleFile.js script is included before this one - as is the * case with single file builds. * */ var singleFile = (typeof(Geoportal)=="object" && Geoportal.singleFile); /** * Namespace: Geoportal * The Geoportal API based on OpenLayers 2.8. * The Geoportal object provides a namespace for all things Geoportal */ window.Geoportal = { /** * Property: _scriptName * {String} Relative path of this script. */ _scriptName: (!singleFile) ? "lib/GeoportalMin.js" : "GeoportalMin.js", /** * Property: _scriptLocation * {String} Path of this script. */ _scriptLocation: null, /** * Function: _getScriptLocation * Return the path to this script. * * Returns: * {String} Path to this script */ _getScriptLocation: function () { if(Geoportal._scriptLocation) { return Geoportal._scriptLocation; } var scriptName= Geoportal._scriptName; var scriptNameLen= scriptName.length; // From GeoExt : // If we load other scripts right before Geoportal using the same // mechanism to add script resources dynamically (e.g. OpenLayers), // document.getElementsByTagName will not find the GeoExt script tag // in FF2. Using document.documentElement.getElementsByTagName instead // works around this issue. var scripts= document.documentElement.getElementsByTagName('script'); for (var i= 0; i < scripts.length; i++) { var src= scripts[i].getAttribute('src'); if (src) { var index= src.lastIndexOf(scriptName); // set path length for src up to a query string var pathLength= src.lastIndexOf('?'); if (pathLength < 0) { pathLength= src.length; } // is it found, at the end of the URL? if ((index > -1) && (index + scriptNameLen == pathLength)) { Geoportal._scriptLocation= src.slice(0, -scriptNameLen); break; } } } return Geoportal._scriptLocation||""; } }; /** * Geoportal.singleFile is a flag indicating this file is being included * in a Single File Library build of the Geoportal Library. * * When we are *not* part of a SFL build we dynamically include the * Geoportal library code. * * When we *are* part of a SFL build we do not dynamically include the * Geoportal library code as it will be appended at the end of this file. */ if(!singleFile) { var jsfiles = [ // PROJ4JS: "../../proj4js/lib/proj4js.js", "../../proj4js/lib/OverloadedProj4js.js", // GEOPORTAL: "OpenLayers/OverloadedOpenLayersMinimum.js", "Geoportal/Catalogue.js", "Geoportal/Control.js", "Geoportal/Lang.js", "Geoportal/Lang/en.js", "Geoportal/Lang/fr.js", "Geoportal/Lang/de.js", "Geoportal/Lang/es.js", "Geoportal/Lang/it.js", "Geoportal/Layer.js", "Geoportal/Tile.js", "Geoportal/Util.js", "Geoportal/Control/PermanentLogo.js", "Geoportal/Control/TermsOfService.js", "Geoportal/GeoRMHandler.js", "Geoportal/Layer/Grid.js", "Geoportal/Layer/WFS.js", "Geoportal/Layer/WMS.js", "Geoportal/Layer/WMSC.js", "Geoportal/Tile/Image.js" ]; // etc. var agent= navigator.userAgent; var docWrite= (agent.match("MSIE") || agent.match("Safari")); if(docWrite) { var allScriptTags= new Array(jsfiles.length); } else { var h= document.getElementsByTagName("head").length ? document.getElementsByTagName("head")[0] : document.body; if (!h) { alert('no head and body to include the JavaScript API.'); return; } } var host= Geoportal._getScriptLocation() + "lib/"; for (var i= 0, len= jsfiles.length; i < len; i++) { if(docWrite) { allScriptTags[i]= ""; } else { if(h) { var s= document.createElement("script"); s.src= host + jsfiles[i]; s.charset= "UTF-8"; s.type= "text/javascript"; h.appendChild(s); } } } if(docWrite) { document.write(allScriptTags.join("")); } } })(); /** * Constant: VERSION_NUMBER * {String} *"1.0"* */ Geoportal.VERSION_NUMBER="1.0";