[fusion-commits] r1624 - trunk/lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Thu Oct 30 15:00:30 EDT 2008
Author: chrisclaydon
Date: 2008-10-30 15:00:30 -0400 (Thu, 30 Oct 2008)
New Revision: 1624
Modified:
trunk/lib/fusion.js
Log:
Closes #144 - Modified the parseQueryString function to convert '+' characters to spaces before URL decoding. This allows legitimate '+' characters to be passed in correctly.
Modified: trunk/lib/fusion.js
===================================================================
--- trunk/lib/fusion.js 2008-10-30 18:05:54 UTC (rev 1623)
+++ trunk/lib/fusion.js 2008-10-30 19:00:30 UTC (rev 1624)
@@ -66,86 +66,86 @@
* declare global namespace object for Fusion library to use
*/
window.Fusion = {
-
+
/***************************************************************************
* Class: Fusion.Tools
- *
+ *
* A set of utility classes that provide common tools for applications
***************************************************************************/
Tool: {},
/***************************************************************************
* Class: Fusion.Widget
- *
+ *
* A set of classes that implement the functionlity required for applications
***************************************************************************/
Widget: {},
/***************************************************************************
* Class: Fusion.Event
- *
+ *
* A class to provide for event handling at application runtime
***************************************************************************/
Event: {lastEventId: 1},
/***************************************************************************
* Class: Fusion.Lib
- *
+ *
* A set of classes to provide core funtionality
***************************************************************************/
Lib: {},
/***************************************************************************
* Class: Fusion.Maps
- *
- * A set of classes that implement mapping functionality for various server
+ *
+ * A set of classes that implement mapping functionality for various server
* technologies.
***************************************************************************/
Maps: {},
/***************************************************************************
* Class: Fusion.Constant
- *
+ *
* Application scope constants
***************************************************************************/
Constant: {},
-
+
applicationDefinition: null,
-
+
/**
* URL to the configuration file to use for this application. The
* configuration file must be located on the same domain as the
* application template.
*/
sConfigFileURL : "",
-
+
sWebAgentURL : "",
sWebTierURL : "",
- sRedirectScript : "",
+ sRedirectScript : "",
bForceRedirect : false,
sScriptLang : "",
locale : 'en',
Strings: {}, //locale specific strings
-
+
/** URL to the directory from which fusion.js was loaded */
fusionURL: null,
-
- /**
+
+ /**
* configuration object that holds the server configuration as
* loaded from fusion/config.xml
*/
configuration: null,
-
+
/* broker instance for communicating with the mapagent */
oBroker: null,
-
+
/** An array of scripts that are queued to be loaded */
aScripts : [],
/** An array of scripts that are currently being loaded */
aLoadingScripts: [],
/** The current state during initialization of the application */
loadState: null,
-
+
/** API loading has not begun */
UNLOADED: 0,
/** Load the configuration file for the application */
@@ -154,7 +154,7 @@
LOAD_WIDGETS: 2,
/** Loading is complete */
LOAD_COMPLETE: 3,
-
+
/** unit related stuff */
UNKNOWN: 0,
INCHES: 1,
@@ -200,12 +200,12 @@
111061.75033, /* 12 - DMS */
1.0 /* 13 - PIXELS */],
aUnitNames: ['Unknown','Inches', 'Feet', 'Yards', 'Miles', 'Nautical Miles',
- 'Millimeters', 'Centimeters', 'Meters', 'Kilometers',
+ 'Millimeters', 'Centimeters', 'Meters', 'Kilometers',
'Degrees', 'Decimal Degrees', 'Degrees Minutes Seconds', 'Pixels'],
- aUnitAbbr: ['unk', 'in', 'ft', 'yd', 'mi', 'nm',
- 'mm', 'cm', 'm', 'km',
+ aUnitAbbr: ['unk', 'in', 'ft', 'yd', 'mi', 'nm',
+ 'mm', 'cm', 'm', 'km',
'°', '°', '°', 'px'],
-
+
/**
* Function: initialize
*
@@ -215,7 +215,7 @@
*
* Optional paramters that can be passed to initialize are:
*
- * {String} applicationDefinition - a URL or resource ID
+ * {String} applicationDefinition - a URL or resource ID
* for an ApplicationDefinition file
* {String} sessionId - a session id to start the application
* with. Normally, applications are started without
@@ -226,13 +226,13 @@
options = options || {};
var sessionIdParam = this.getQueryParam('Session');
this.sessionId = sessionIdParam || (options.sessionId || null);
-
+
if (options.applicationDefinitionURL) {
- this.applicationDefinitionURL = options.applicationDefinitionURL;
+ this.applicationDefinitionURL = options.applicationDefinitionURL;
} else {
var queryAppDef = this.getQueryParam('ApplicationDefinition');
if (queryAppDef) {
- this.applicationDefinitionURL = queryAppDef.split('+').join(' ');
+ this.applicationDefinitionURL = queryAppDef;
this.appDefJson = null; //wipe out any preloaded AppDef in a single file build
} else {
this.applicationDefinitionURL = 'ApplicationDefinition.xml';
@@ -252,7 +252,7 @@
/*
* 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
+ * use the redirect script because we conform to the
* Same Origin Policy for XmlHttpRequest to work.
*/
var test = window.location.protocol+'//'+window.location.host;
@@ -264,10 +264,10 @@
this.sRedirectScript = 'redirect.php';
configUrl += '&method=get';
}
-
+
/*script language*/
this.sScriptLang = 'php';
-
+
if (Fusion.configuration) {
//config.json loaded via single file build
this.serverSet();
@@ -280,11 +280,11 @@
this.ajaxRequest(configUrl, options);
}
},
-
+
initializeLocale: function(locale) {
this.locale = locale ? locale : window._FusionLocale;
OpenLayers.Lang.setCode(this.locale);
-
+
//check if strings are defined for specified locale, if not, set them to the default locale
if (!OpenLayers.Lang[this.locale]) {
OpenLayers.Lang[this.locale] = OpenLayers.Lang[OpenLayers.String.defaultLangCode];
@@ -294,7 +294,7 @@
}
OpenLayers.Util.extend(OpenLayers.Lang[this.locale], Fusion.Strings[this.locale]);
},
-
+
/**
* Function: setLoadState
*
@@ -335,7 +335,7 @@
* queued and loaded before the load state is advanced.
*/
loadQueuedScripts: function() {
- //with the compressed version, all scripts are already laoded so just
+ //with the compressed version, all scripts are already laoded so just
//increment the load state
if (this.aScripts.length == 0) {
this.setLoadState(this.loadState+1);
@@ -354,12 +354,12 @@
for (var i=0; i<this.aLoadingScripts.length; i++) {
document.getElementsByTagName('head')[0].appendChild(this.aLoadingScripts[i]);
}
-
+
//if IE or Safari
this.checkLoadInterval = window.setInterval(
OpenLayers.Function.bind(this.checkLoadingScripts, this), 500);
},
-
+
/**
* Function: queueScript
*
@@ -367,7 +367,7 @@
* to the Fusion base url. The script will not actually be loaded until
* loadQueuedScripts is called.
*
- * Parameter: {String} url
+ * Parameter: {String} url
*
* The url of the script.
*/
@@ -390,7 +390,7 @@
*
* Called when a script fails to load for some reason.
*
- * Parameter: url
+ * Parameter: url
*
* {String} the url that failed to load
*
@@ -398,10 +398,10 @@
* so we need to decide how to inform the user and fail gracefully.
*/
scriptFailed: function(url) {
- Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL,
+ Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL,
OpenLayers.i18n('scriptFailed',{'script':url})));
},
-
+
/**
* Function: scriptLoaded
*
@@ -411,7 +411,7 @@
* If yes, then we loadQueuedScripts again, otherwise we advance
* the load state.
*
- * Parameter: url
+ * Parameter: url
*
* {String} the url of the script that was loaded.
*/
@@ -477,18 +477,18 @@
Fusion.setLoadState(Fusion.LOAD_WIDGETS);
}
},
-
+
/**
* Function: getConfigCB
*
* the server has returned the application configuration file that
* contains enough information to bootstrap the application.
*
- * Parameter {Object} r
+ * Parameter {Object} r
* an XMLHttpRequest object
*/
getConfigCB : function(r) {
- if (r.responseText) {
+ if (r.responseText) {
eval("this.configuration="+r.responseText);
this.serverSet();
} else {
@@ -496,14 +496,14 @@
alert(OpenLayers.i18n('configParseError'));
}
},
-
+
/**
* Function: serverSet
*
* the server has returned the application configuration file that
* contains enough information to bootstrap the application.
*
- * Parameter {Object} r
+ * Parameter {Object} r
* an XMLHttpRequest object
*/
serverSet : function() {
@@ -527,11 +527,11 @@
}
this.configuration.mapguide.webTierUrl = s;
this.configuration.mapguide.mapAgentUrl = s + 'mapagent/mapagent.fcgi';
-
+
//trigger loading stuff ...
this.setLoadState(this.LOAD_CONFIG);
},
-
+
/**
* Function: serverFailed
*
@@ -540,16 +540,16 @@
* happened.
*
* Parameter: {Object} r
- *
+ *
* the XMLHttpRequest object
*
* TODO: do something more useful in here?
*/
serverFailed: function(r) {
//console.log('error loading server configuration file');
- alert(OpenLayers.i18n('configLoadError'));
+ alert(OpenLayers.i18n('configLoadError'));
},
-
+
/**
* Function: ajaxRequest
*
@@ -557,7 +557,7 @@
* to the Fusion installation.
*
* Parameter: {String} scriptURL
- *
+ *
* the URL (relative to Fusion) to request
*
* Parameter: {Object} options
@@ -585,7 +585,7 @@
}
new OpenLayers.Ajax.Request( url, options);
},
-
+
/**
* Function: ajaxException
*
@@ -596,14 +596,14 @@
* Parameter: {Exception} e
*/
ajaxException: function(r, e) {
- this.reportError(new Fusion.Error(Fusion.Error.WARNING,
- OpenLayers.i18n('ajaxError', {'exception':e.message,
- 'filename':e.fileName,
+ this.reportError(new Fusion.Error(Fusion.Error.WARNING,
+ OpenLayers.i18n('ajaxError', {'exception':e.message,
+ 'filename':e.fileName,
'line':e.lineNumber,
'response': r.transport.responseText
})));
},
-
+
/**
* Function: convertXML
*
@@ -630,7 +630,7 @@
};
new OpenLayers.Ajax.Request(url, options);
},
-
+
xml2json: function(callback, r, json) {
if (json) {
var o;
@@ -638,7 +638,7 @@
callback(o);
} else {
if (r.status >= 400) {
- Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL,
+ Fusion.reportError(new Fusion.Error(Fusion.Error.FATAL,
'xml2json: invalid XML document: ' + r.statusText + " : " + r.request.url));
return;
}
@@ -652,7 +652,7 @@
Fusion.ajaxRequest('common/'+sl+'/Xml2JSON.'+sl, options);
}
},
-
+
/**
* Function: getMapByName
*
@@ -671,7 +671,7 @@
}
return map;
},
-
+
/**
* Function: getMapById
*
@@ -691,7 +691,7 @@
}
return map;
},
-
+
/**
* Function: getMapByIndice
*
@@ -710,7 +710,7 @@
}
return map;
},
-
+
/**
* Function: getWidgetById
*
@@ -738,7 +738,7 @@
return null;
}
},
-
+
/**
* Function getWidgetsByType
*
@@ -757,7 +757,7 @@
}
return widgets;
},
-
+
getSearchDefinitions: function() {
if (this.applicationDefinition) {
return this.applicationDefinition.searchDefinitions;
@@ -765,7 +765,7 @@
return {};
}
},
-
+
getSearchCategories: function() {
if (this.applicationDefinition) {
return this.applicationDefinition.searchCategories;
@@ -773,7 +773,7 @@
return {};
}
},
-
+
getApplicationDefinitionURL: function() { return this.applicationDefinitionURL; },
/**
@@ -781,7 +781,7 @@
*
* returns the applicaiton's absolute URL minus the filename.html part
*/
- getApplicationURL: function() {
+ getApplicationURL: function() {
var path = window.location.pathname;
var idx = path.lastIndexOf('/');
if (idx>=0) {
@@ -789,26 +789,26 @@
}
return window.location.protocol + "//" + window.location.host + path;
},
-
+
getFusionURL: function() {return this.fusionURL;},
-
- getConfigurationItem: function(arch, key) {
- if (this.configuration[arch] && this.configuration[arch][key]) {
- return this.configuration[arch][key];
- }
- return null;
+
+ getConfigurationItem: function(arch, key) {
+ if (this.configuration[arch] && this.configuration[arch][key]) {
+ return this.configuration[arch][key];
+ }
+ return null;
},
-
+
getScriptLanguage: function() { return this.configuration.general.scriptLanguage; },
-
+
getRedirectScript: function() { return this.sRedirectScript; },
-
+
getBroker: function() { return this.oBroker; },
-
+
require: function(url) { this.queueScript(url); },
-
+
reportError: function(o) { this.triggerEvent(Fusion.Event.FUSION_ERROR, o); },
-
+
unitFromName: function(unit) {
switch(unit.toLowerCase()) {
case 'unknown':
@@ -867,7 +867,7 @@
Fusion.UNKNOWN;
}
},
-
+
unitSystem: function(unit) {
switch(unit) {
@@ -892,7 +892,7 @@
return 'device';
}
},
-
+
unitName: function(unit) {
if (unit >= Fusion.UNKNOWN && unit <= Fusion.PIXELS) {
return (Fusion.aUnitNames[unit]);
@@ -925,15 +925,15 @@
return false;
},
convert: function(unitsIn, unitsOut, value) {
- if (unitsIn >= Fusion.UNKNOWN && unitsIn < Fusion.PIXELS &&
+ if (unitsIn >= Fusion.UNKNOWN && unitsIn < Fusion.PIXELS &&
unitsOut >= Fusion.UNKNOWN && unitsOut < Fusion.PIXELS) {
return Fusion.fromMeter(unitsOut, Fusion.toMeter(unitsIn, value));
}
return false;
},
-
+
/**
- * initializes the meters per unit values when a new map is loaded. Some systems make different
+ * initializes the meters per unit values when a new map is loaded. Some systems make different
* assumptions for the conversion of degrees to meters so this makes sure both Fusion and
* OpenLayers are using the same value.
*
@@ -949,13 +949,13 @@
Fusion.aUnitPerMeter[Fusion.DEGREES] = inverse;
Fusion.aUnitPerMeter[Fusion.DECIMALDEGREES] = inverse;
Fusion.aUnitPerMeter[Fusion.DMX] = inverse;
-
+
var inPerUnit = OpenLayers.INCHES_PER_UNIT.m * metersPerUnit;
OpenLayers.INCHES_PER_UNIT["dd"] = inPerUnit;
OpenLayers.INCHES_PER_UNIT["degrees"] = inPerUnit;
}
},
-
+
/**
* find the OpenLayers units identifier given the Fusion metersPerUnit value
*
@@ -989,6 +989,7 @@
var s=window.location.search;
if (s!='') {
s=s.substring( 1 );
+ s=s.split('+').join(' ');
var p=s.split('&');
for (var i=0;i<p.length;i++) {
var q=p[i].split('=');
@@ -1009,7 +1010,7 @@
return '';
}
},
-
+
/**
* Property: _scriptName
* {String} Relative path of this script.
@@ -1031,7 +1032,7 @@
for (var i = 0; i < scripts.length; i++) {
var src = scripts[i].getAttribute('src');
if (src) {
- var index = src.lastIndexOf(scriptName);
+ var index = src.lastIndexOf(scriptName);
if (index > -1) {
Fusion._scriptObject = scripts[i];
var img = document.createElement('img');
@@ -1054,22 +1055,22 @@
/*********************************************************************************/
/* actual bootstrap execution code follows */
-
+
Fusion._singleFile = singleFile;
var host = Fusion._getScriptLocation();
Jx.aPixel = Fusion.aPixel;
-
+
//determine the language to use and add resource bundles to be loaded to the core scripts
var locale = navigator.language ?
- navigator.language.substring(0,2): //e.g. en-CA becomes just en
- navigator.userLanguage.substring(0,2);//only use the prefix part for now,
+ navigator.language.substring(0,2): //e.g. en-CA becomes just en
+ navigator.userLanguage.substring(0,2);//only use the prefix part for now,
var s = window.location.search.toLowerCase();
var idx = s.indexOf('locale=');
if (idx>0) {
locale = s.substring(idx+7,idx+9);
}
window._FusionLocale = locale;
-
+
if (!Fusion._singleFile) {
var coreScripts = ['lib/OpenLayers/OpenLayers.js',
'lib/jxlib.uncompressed.js',
@@ -1088,7 +1089,7 @@
coreScripts.push('lib/OpenLayers/Lang/'+locale+'.js');
coreScripts.push('text/'+locale+'/strings.json');
}
-
+
var agent = navigator.userAgent;
var docWrite = (agent.match("MSIE") || agent.match("Safari"));
if (docWrite) {
@@ -1097,12 +1098,12 @@
for (var i = 0; i < coreScripts.length; i++) {
if (docWrite) {
allScriptTags[i] = "<script src='" + host + coreScripts[i] +
- "'></script>";
+ "'></script>";
} else {
var s = document.createElement("script");
s.src = host + coreScripts[i];
- var h = document.getElementsByTagName("head").length ?
- document.getElementsByTagName("head")[0] :
+ var h = document.getElementsByTagName("head").length ?
+ document.getElementsByTagName("head")[0] :
document.body;
h.appendChild(s);
}
More information about the fusion-commits
mailing list