var logging=false;
function w3cValidate() {
document.location.href = "http://validator.w3.org/check?verbose=1&uri=" + escape(document.location.href);
}
var population={}
function getPopulationFromPopulationMap(rowCell) {
var cellId = rowCell.id;
return population[cellId];
}
function getPopulationFromAttribute(rowCell) {
return rowCell.getAttribute("population");
}
function getPopulationFromDataAttribute(rowCell) {
return rowCell.getAttribute("data-population");
}
// using HTML5 dataset
function getPopulationFromDataset(rowCell) {
return rowCell.dataset.population;
}
function getPopulationFromNamespaceAttribute(rowCell) {
return rowCell.getAttributeNS("http://thinkinghard.com/annotation", "population");
}
function getPopulationFromId(rowCell) {
var idString = rowCell.id;
var index = idString.search ("_population_");
return idString.substring(index + 12);
}
function getPopulationFromClass(rowCell) {
var classString = rowCell.className;
var classes = classString.split(" ");
for (var i=0; i<classes.length; i++) {
var className = classes[i];
if (className.indexOf("population_") == 0) {
return className.substring(11);
}
}
return null;
}
function getPopulationFromElement(rowCell) {
var spanElements = rowCell.getElementsByTagName("span");
for (var i=0; i<spanElements.length; i++) {
var spanElement = spanElements[i];
if (spanElement.className = "population") {
return spanElement.firstChild.nodeValue;
}
}
return null;
}
function getPopulationFromComment(rowCell) {
var childNodes = rowCell.childNodes;
for (var i=0; i<childNodes.length; i++) {
var childNode = childNodes[i];
if (childNode.nodeType == 8) {
var commentString = childNode.data;
if (commentString.indexOf("population_") == 0) {
return commentString.substring(11);
}
}
}
return null;
}
function drawPopulationBars(populationFunction) {
var populationTable = document.getElementById("populationTable");
var tableRows = populationTable.getElementsByTagName("tr");
for (var i=0; i<tableRows.length; i++) {
var tableRow = tableRows[i];
var rowCells = tableRow.getElementsByTagName("td");
var thisPopulation = populationFunction(rowCells[0]);
var barCell = document.createElement("td");
tableRow.appendChild(barCell);
barDiv = document.createElement("div");
barDiv.className = "graphBar";
barDiv.style.width = ((thisPopulation/1000000) * 2) + "pt";
barCell.appendChild (barDiv);
}
}