Last active
January 20, 2016 07:41
-
-
Save RauliL/9913ec05077422dbf1da to your computer and use it in GitHub Desktop.
JavaScript: Globals object.
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
window.Globals = (function() { | |
var result = {}; | |
$("meta[name^='global:']").each(function() { | |
var tag = $(this); | |
var name = tag.attr("name").substring(7); | |
var content = tag.attr("content"); | |
if (/^json:/.test(name)) { | |
name = name.substring(5); | |
content = JSON.parse(content); | |
} | |
result[name] = content; | |
}); | |
return result; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment