F2: List and extend F2.Constants
HTML
<script src="http:////cdnjs.cloudflare.com/ajax/libs/F2/1.3.0/f2.js"></script>
<ul id="output"></ul>
CSS
li {
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
font-size: 12px;
}
JavaScript
var $list = $("#output");
var showConstants = function() {
$.each(F2.Constants, function(i, item) {
$list.append('<li>F2.' + i);
if (typeof item !== 'string') { //skip 'JSONP_CALLBACK'
var $group = $('<ul/>');
$.each(item, function(j, x) {
$group.append('<li>' + j + ' = ' + x + '</li>');
});
$list.append($group);
}
$list.append('</li>');
});
}
//show constants first
showConstants();
//add a new Constant by extending
//http://docs.openf2.org/extending-f2.html
F2.extend('Constants', (function() {
return {
NEW_CONSTANT: ['foo', 'bar']
}
})());
//add divider between lists
$list.find('ul:last').after('<hr />');
//display updated F2.Constants
showConstants();