[fusion-commits] r1899 - trunk/lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu Sep 17 23:49:58 EDT 2009
Author: zjames
Date: 2009-09-17 23:49:57 -0400 (Thu, 17 Sep 2009)
New Revision: 1899
Modified:
trunk/lib/fusion.js
Log:
re #289: only attempt to load apis from AppDef if it's in the repository
Modified: trunk/lib/fusion.js
===================================================================
--- trunk/lib/fusion.js 2009-09-17 17:36:19 UTC (rev 1898)
+++ trunk/lib/fusion.js 2009-09-18 03:49:57 UTC (rev 1899)
@@ -1115,5 +1115,97 @@
document.write(allScriptTags.join(""));
}
}
+
+ /*********************************************************************************/
+ /* Load commercial layer API scripts */
+
+ /*This function is extracted from Fusion to get the MapAgentUrl */
+ var getAgentUrl = function() {
+ /*
+ * if the application has been loaded from the same host as
+ * fusion is installed in, then technically we don't need to
+ * use the redirect script because we conform to the
+ * Same Origin Policy for XmlHttpRequest to work.
+ */
+ var fusionURL = Fusion._getScriptLocation();
+ var testUrl = window.location.protocol + '//' + window.location.host;
+ var configUrl = 'config.json';
+
+ if (((Fusion.fusionURL.indexOf("http://") < 0) || (Fusion.fusionURL.indexOf(testUrl, 0) == 0)) && !(Fusion.bForceRedirect)) {
+ Fusion.sRedirectScript = '';
+ }
+ else {
+ Fusion.sRedirectScript = 'redirect.php';
+ configUrl += '&method=get';
+ }
+
+ var r = Fusion.getRedirectScript();
+ if (r != '') {
+ r = r + '?s=';
+ }
+
+ var fusionURL = r + Fusion.getFusionURL() + configUrl;
+
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", fusionURL, false);
+ xhr.send(null);
+
+ eval("Fusion.configuration=" + xhr.responseText);
+ var s = Fusion.configuration.mapguide.webTierUrl;
+ /* if it is set, use it ... otherwise assume fusion is installed in
+ * the default location and compute the web tier url from that
+ */
+ if (s) {
+ var nLength = s.length;
+ var slastChar = s.charAt((nLength - 1));
+ if (slastChar != '/') {
+ s = s + "/";
+ }
+ }
+ else {
+ var idx = Fusion.fusionURL.lastIndexOf('fusion');
+ if (idx == -1) {
+ s = Fusion.fusionURL + "../"; //loaded relatively from within fusion directory
+ }
+ else {
+ s = Fusion.fusionURL.substring(0, idx);
+ }
+ }
+ Fusion.configuration.mapguide.mapAgentUrl = s + 'mapagent/mapagent.fcgi';
+ return Fusion.configuration.mapguide.mapAgentUrl;
+ }
+
+ var addElement = function(element) {
+ if (!element) {
+ return;
+ }
+ var src = element.textContent;
+
+ // For IE Browser
+ if (!src) {
+ src = element.text;
+ }
+
+ document.writeln('<script src="' + src + '"><\/script>');
+ }
+
+ var appDefUrl = Fusion.getQueryParam('ApplicationDefinition');
+ if(appDefUrl){
+ var xhr = new XMLHttpRequest();
+ var mapAgentUrl = getAgentUrl();
+ xhr.open("GET", mapAgentUrl + "?OPERATION=GETRESOURCECONTENT&VERSION=1.0.0&LOCALE=en&CLIENTAGENT=MapGuide+Developer&RESOURCEID=" + appDefUrl + "&FORMAT=text%2Fxml", false);
+ xhr.send(null);
+ var appDefXML = xhr.responseXML.documentElement;
+
+ if(appDefXML){
+ var googleElement = appDefXML.getElementsByTagName("GoogleScript")[0];
+ var yahooElement = appDefXML.getElementsByTagName("YahooScript")[0];
+ var veElement = appDefXML.getElementsByTagName("VirtualEarthScript")[0];
+
+ addElement(googleElement);
+ addElement(yahooElement);
+ addElement(veElement);
+ }
+ }
})();
More information about the fusion-commits
mailing list