I am currently setting over a hundred global variables by performing individual checks against the URL string.
var Query_MenuTiles = getParameterByName("menutiles")
var Query_Link = getParameterByName("link")
var Query_Speed = getParameterByName("speed")
Unless it would slow things down, I assume that setting keys and properties of an object would be a cleaner way of doing this.
The getParameterByName
function is as follows:
function getParameterByName(name, source ) {
if (typeof source == 'undefined') {
source = window.location.search
}
if ( user_fastquery == '1' ) {
return search[name] || ''
}
else {
name = name.toLowerCase()
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)"; //"=([^&#]*)";
var regex = new RegExp(regexS);
var query_x = 'back'
var query_y = 'frame'
if ( name != query_x ) {
if ( source.indexOf("&" + query_x + "=") >= 0 ) {
var array_source = source.split('&' + query_x + '=')
source = array_source[0]
var source_tail = array_source[1]
}
else if ( source.indexOf("?" + query_x + "=") >= 0 ) {
var array_source = source.split("?" + query_x + "=" )
source = array_source[0]
}
}
var results = regex.exec( source );
if(results == null)
return "";
else
return decodeURIComponent(results[1].replace(/\+/g, " "));
}
}