Created
January 7, 2012 21:48
-
-
Save SlexAxton/1576166 to your computer and use it in GitHub Desktop.
JavaScript Code Improver output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() | |
{ | |
function getScriptUrl(re) | |
{ | |
var scripts = document.getElementsByTagName('script'), | |
element, | |
src; | |
for (var i = 0; i < scripts.length; i++) | |
{ | |
element = scripts[i]; | |
src = element.getAttribute ? | |
element.getAttribute('src') : el.src; | |
if (src && re.test(src)) | |
{ | |
return src; | |
} | |
} | |
return null; | |
} | |
function getQueryParameters(query) | |
{ | |
var args = query.split('&'), | |
params = | |
{ | |
} | |
, | |
pair, | |
key, | |
value; | |
function decode(string) | |
{ | |
return decodeURIComponent(string || "") | |
.replace('+', ' '); | |
} | |
for (var i = 0; i < args.length; i++) | |
{ | |
pair = args[i].split('='); | |
key = decode(pair.shift()); | |
value = decode(pair ? pair[0] : null); | |
params[key] = value; | |
} | |
return params; | |
}; | |
var url = getScriptUrl(/^fragment\.js/); | |
var params = getQueryParameters(url.replace(/^.*\#/, '')); | |
document.getElementById('fragment-ident-out').innerHTML = JSON.stringify(params); | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment