// The var "population" contains the entry for 570 objects in the form
// of {"year": "String", "age": "String ", "sex": "String", "people": "String" }
// Example: {"year": "1850", "age": "0", "sex": "1", "people": "1483789" }
// From Minnesota Population Center - Gist raw added as a resource
// https://gist.github.com/jjperezaguinaga/5126932/raw/b9962891eaaead272520df5b835bfd889e43fe4c/population.js
function ajaxSingleton() {
var self = {};
var httpRequest = new XMLHttpRequest();
self.callback = null;
self.loadResponse = function () {
if (httpRequest.readyState === 4) {
if (httpRequest.status === 200 && self.callback) {
self.callback(httpRequest.responseText);
} else {
console.error('There was a problem with the request.', httpRequest);
}
}
}
self.get = function (url, data, callback) {
self.callback = callback;
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded; charset=UTF-8');
httpRequest.onreadystatechange = self.loadResponse;
httpRequest.send("json=" + JSON.stringify(data));
}
return self;
}
function NavBarContent(activePage) {
var self = this;
var ulContainer = ".ulContainer";
var paginationId = 'paginationList';
self.pages = [];
self.oldActivePage = null;
self.activePage = activePage;
var removeActive = function (index) {
self.pages[index].classList.remove('active');
}
var paintActive = function (index) {
self.pages[index].classList.add('active');
}
var updateCellsValue = function (updateValue) {
var page;
for (var i = 1, len = self.pages.length; i < len; i++) {
page = self.pages[i].querySelector('a');
page.innerHTML = +page.innerHTML + updateValue;
removeActive(i);
if (+page.innerHTML ===...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Fiddle Pages
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Get Fiddle Pages with PRO
Your fiddles accessible under a custom domain and a vanity path - the simplest hosting for your personal project.