community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1679361 - /comdev/projects.apache.org/site/js/projects.js
Date Thu, 14 May 2015 13:18:01 GMT
Author: hboutemy
Date: Thu May 14 13:18:01 2015
New Revision: 1679361

URL: http://svn.apache.org/r1679361
Log:
code simplification

Modified:
    comdev/projects.apache.org/site/js/projects.js

Modified: comdev/projects.apache.org/site/js/projects.js
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/site/js/projects.js?rev=1679361&r1=1679360&r2=1679361&view=diff
==============================================================================
--- comdev/projects.apache.org/site/js/projects.js (original)
+++ comdev/projects.apache.org/site/js/projects.js Thu May 14 13:18:01 2015
@@ -70,13 +70,13 @@ var fetchCount = 0;
 function GetAsyncJSONArray(urls, finalCallback) {
     var obj = document.getElementById('progress');
     if (fetchCount == 0 ) {
-	fetchCount = urls.length
+	fetchCount = urls.length;
     }
 
     if (urls.length > 0) {
 	var a = urls.shift();
-	var URL = a[0]
-	var cb = a[1]
+	var URL = a[0];
+	var cb = a[1];
 	var xmlHttp = null;
 	if (window.XMLHttpRequest) {
 	    xmlHttp = new XMLHttpRequest();
@@ -241,222 +241,195 @@ function newProject(form) {
 
 // ------------ Project information page ------------\\
 
+function linkCommitterIndex(cid) {
+    var fullname = people[cid];
+    var cl = isMember(cid) ? "member" : "committer";
+    return "<a class='" + cl + "' title='" + cid + "' href='http://people.apache.org/committer-index.html#"
+ cid + "' target='_blank'>" + fullname + "</a>";
+}
+
+function appendElementWithInnerHTML(obj,type,html) {
+    var child = document.createElement(type);
+    child.innerHTML = html;
+    obj.appendChild(child);
+}
+
+function appendLiInnerHTML(ul,html) {
+    appendElementWithInnerHTML(ul,'li',html);
+}
+
 function renderProjectPage(json, state) {
 
     var obj = document.getElementById('contents');
-    var isTLP = false
-    var isIncubating = false
+    var isTLP = false;
+    var isIncubating = false;
     if ((!json || !json.name) && projects[state]) {
 	json = projects[state];
     }
-    if (json && json.name) {
-	// Start by splitting the name, thus fetching the root name of the project, and not the
sub-project.
-	
-	if (!json.description || json.description.length == 0) {
-	    json.description = (json.shortdesc && json.shortdesc.length > 0 ) ? json.shortdesc
: "No description available"
-	}
-	
-	// Title + description
-	pt = "Top Level Project"
-	if ((!committees[json.name] && pmcs[json.pmc]) || json.name.match("Incubating",
"i")) {
-	    pt = (json.pmc == "attic") ? "in the Attic" : "Sub-project"
-	} else {
-	    isTLP = true
-	}
-	obj.innerHTML = "<h1>" + json.name + " (" + pt + "):</h1>"
-	
-	// Rerig the unix name and pmc
-	state = state.split("-")[0];
-	if (json.name.match("incubating", "i")) {
-	    json.pmc = 'incubator'
-	}
-	
-	var p = document.createElement('p');
-	p.style.fontFamily = '"Times New Roman", Times, serif';
-	p.innerHTML = json.description.replace(/([^\r\n]+)\r?\n\r?\n/g,function(a) { return "<p>"+a+"</p>"});
-	obj.appendChild(p);
-	
-	
-	// Base data
-	var p = document.createElement('h4');
-	p.innerHTML = "Project base data:"
-	obj.appendChild(p);	
-	var ul = document.createElement('ul');
-	
-	// Categories
-	if (json['category']) {
-	    var li = document.createElement('li');
-	    pl = json['category']
-	    var arr = pl.split(/,\s*/)
-	    pls = "";
-	    for (i in arr) {
-		var cat = arr[i].replace("http://projects.apache.org/category/", "").toLowerCase();
-		pls += "<a href='/projects.html?category#" + cat + "'>" + cat + "</a> &nbsp;
"
-	    }
-	    li.innerHTML = "<b>Category:</b> " + pls
-	    ul.appendChild(li)
-	}
-	
-	// Website
-	if (json.homepage) {
-	    var li = document.createElement('li');
-	    li.innerHTML = "<b>Website:</b> <a href='" + json.homepage + "' target='_blank'>"
+ json.homepage + "</a>"
-	    ul.appendChild(li)
-	}
-	var li = document.createElement('li');
-	if (unixgroups[state]) {
-	    li.innerHTML = "<b>Project status:</b> <span class='pactive'>Active</span>";
-	} else {
-	    li.innerHTML = "<b>Project status:</b> <span class='pretired'>Retired(?)</span>";
-	}
-	if (json.podling || json.name.match(/incubating/i)) {
-	    li.innerHTML = "<b>Project status:</b> <span class='ppodling'>Incubating</span>";
-	    isIncubating = true;
-	}
-	
-	ul.appendChild(li)
-	if (committees[json.name]) {
-	    var li = document.createElement('li');
-	    li.innerHTML = "<b>Project founded:</b> " + committees[json.name]
-	    ul.appendChild(li)
-	}
-	
-	// TLP Owner?
-	if (json.pmc) {
-	    if (json.pmc.match(/http:\/\/([a-z0-9]+)/i)) {
-		json.pmc = json.pmc.match(/http:\/\/([a-z0-9]+)/i)[1];
-	    }	    
-	} else {
-	    json.pmc = state
-	}
-	if (!committees[json.name] && pmcs[json.pmc]) {
-	    var li = document.createElement('li');
-	    li.innerHTML = "<b>Sub-project of:</b> <a href='/project.html?" + json.pmc
+ "'>" + pmcs[json.pmc].name + "</a>"
-	    ul.appendChild(li)
-	}
-	
-	if (isTLP) {
-		
-	    // VP
-	    if (chairs[json.name]) {
-		var li = document.createElement('li');
-		li.innerHTML = "<b>PMC Chair:</b> " + chairs[json.name];
-		ul.appendChild(li)
-	    }
-	    
-	    // Reporting cycle
-	    if (cycles[json.name]) {
-		var li = document.createElement('li');
-		li.innerHTML = "<b>Reporting cycle:</b> " + cycles[json.name] + ", see <a
href='https://whimsy.apache.org/board/minutes/" + camelCase(json.pmc) + ".html'>minutes</a>"
-		ul.appendChild(li)
-	    }
-	    
-	    // PMC
-	    if (unixgroups[state+"-pmc"]) {
-		var pmcl = [];
-		var pmcgroup = unixgroups[state+"-pmc"];
-		for (i in pmcgroup) {
-		    var cid = pmcgroup[i]
-		    var fullname = people[cid];
-		    var cl = isMember(cid) ? "member" : "committer"
-		    pmcl.push("<a class='" + cl + "' title='" + cid + "' href='http://people.apache.org/committer-index.html#"
+ cid + "' target='_blank'>" + fullname + "</a>")
-		}
-		var li = document.createElement('li');
-		li.innerHTML = "<b>PMC Members (" + pmcgroup.length + "):</b> <blockquote>"
+ pmcl.join(", &nbsp;") + "</blockqoute>"
-		ul.appendChild(li)
-	    }
-	}
-	
-	// Committers
-	if (unixgroups[state] && (isTLP || isIncubating)) {
-	    var commitl = [];
-	    var commitgroup = unixgroups[state];
-	    for (i in commitgroup) {
-		var cid = commitgroup[i]
-		var fullname = people[cid];
-		var cl = isMember(cid) ? "member" : "committer"
-		commitl.push("<a class='" + cl + "' title='" + cid + "' href='http://people.apache.org/committer-index.html#"
+ cid + "' target='_blank'>" + fullname + "</a>")
-	    }
-	    var li = document.createElement('li');
-	    li.innerHTML = "<b>Committers (" + commitgroup.length + "):</b> <blockquote>"
+ commitl.join(", &nbsp;") + "</blockqoute>"
-	    ul.appendChild(li)
+    if (!json || !json.name) {
+	obj.innerHTML = "<h2>Sorry, I don't have any information available about this project</h2>";
+	return;
+    }
+
+    // Start by splitting the name, thus fetching the root name of the project, and not the
sub-project.
+
+    if (!json.description || json.description.length == 0) {
+	json.description = (json.shortdesc && json.shortdesc.length > 0 ) ? json.shortdesc
: "No description available"
+    }
+
+    // Title + description
+    var pt = "Top Level Project";
+    if ((!committees[json.name] && pmcs[json.pmc]) || json.name.match("Incubating",
"i")) {
+	pt = (json.pmc == "attic") ? "in the Attic" : "Sub-project"
+    } else {
+	isTLP = true
+    }
+    obj.innerHTML = "<h1>" + json.name + " (" + pt + "):</h1>";
+
+    // Rerig the unix name and pmc
+    state = state.split("-")[0];
+    if (json.name.match("incubating", "i")) {
+	json.pmc = 'incubator'
+    }
+
+    var p = document.createElement('p');
+    p.style.fontFamily = '"Times New Roman", Times, serif';
+    p.innerHTML = json.description.replace(/([^\r\n]+)\r?\n\r?\n/g,function(a) { return "<p>"+a+"</p>"});
+    obj.appendChild(p);
+
+
+    // Base data
+    appendElementWithInnerHTML(obj,'h4',"Project base data:");
+    obj.appendChild(p);
+    var ul = document.createElement('ul');
+
+    // Categories
+    if (json['category']) {
+	var pl = json['category'].replace(new RegExp("http://projects.apache.org/category/", 'g'),
'').toLowerCase();
+	var arr = pl.split(/,\s*/);
+	var pls = "";
+	for (i in arr) {
+	    var cat = arr[i];
+	    pls += "<a href='/projects.html?category#" + cat + "'>" + cat + "</a> &nbsp;
";
+	}
+	appendLiInnerHTML(ul, "<b>Category:</b> " + pls);
+    }
+
+    // Website
+    if (json.homepage) {
+	appendLiInnerHTML(ul, "<b>Website:</b> <a href='" + json.homepage + "' target='_blank'>"
+ json.homepage + "</a>");
+    }
+    if (unixgroups[state]) {
+	appendLiInnerHTML(ul, "<b>Project status:</b> <span class='pactive'>Active</span>");
+    } else {
+	appendLiInnerHTML(ul, "<b>Project status:</b> <span class='pretired'>Retired(?)</span>");
+    }
+    if (json.podling || json.name.match(/incubating/i)) {
+	appendLiInnerHTML(ul, "<b>Project status:</b> <span class='ppodling'>Incubating</span>");
+	isIncubating = true;
+    }
+
+    if (committees[json.name]) {
+	appendLiInnerHTML(ul, "<b>Project founded:</b> " + committees[json.name]);
+    }
+
+    // TLP Owner?
+    if (json.pmc) {
+	if (json.pmc.match(/http:\/\/([a-z0-9]+)/i)) {
+	    json.pmc = json.pmc.match(/http:\/\/([a-z0-9]+)/i)[1];
 	}
-	
-	// maintainer
-	if (json.maintainer && json.maintainer.Person && json.maintainer.Person.mbox)
{
-	    var li = document.createElement('li');
-	    mt = json.maintainer.Person.mbox
-	    li.innerHTML = "<b>Project data maintainer:</b> <a href='" + mt + "'>"
+ mt.substr(mt.indexOf(":") + 1) + "</a>"
-	    ul.appendChild(li)
+    } else {
+	json.pmc = state;
+    }
+    if (!committees[json.name] && pmcs[json.pmc]) {
+	appendLiInnerHTML(ul, "<b>Sub-project of:</b> <a href='/project.html?" +
json.pmc + "'>" + pmcs[json.pmc].name + "</a>");
+    }
+
+    if (isTLP) {
+
+	// VP
+	if (chairs[json.name]) {
+	    appendLiInnerHTML(ul, "<b>PMC Chair:</b> " + chairs[json.name]);
 	}
-	// doap/rdf
-	if (json.doap) {
-	    var li = document.createElement('li');
-	    li.innerHTML = "<b>Project data file:</b> <a href='" + json.doap + "'
target='_blank'>RDF Source</a>"
-	    ul.appendChild(li)
+
+	// Reporting cycle
+	if (cycles[json.name]) {
+	    appendLiInnerHTML(ul, "<b>Reporting cycle:</b> " + cycles[json.name] + ",
see <a href='https://whimsy.apache.org/board/minutes/" + camelCase(json.pmc) + ".html'>minutes</a>");
 	}
-	    
-	obj.appendChild(ul);
-	
-	// Code data	
-	var p = document.createElement('h4');
-	p.innerHTML = "Development:"
-	obj.appendChild(p);	
-	var ul = document.createElement('ul');
-	
-	if (json['programming-language']) {
-	    var li = document.createElement('li');
-	    pl = json['programming-language']
-	    var arr = pl.split(/,\s*/)
-	    pls = "";
-	    for (i in arr) {
-		pls += "<a href='/projects.html?language#" + arr[i] + "'>" + arr[i] + "</a>
&nbsp; "
+
+	// PMC
+	if (unixgroups[state+"-pmc"]) {
+	    var pmcl = [];
+	    var pmcgroup = unixgroups[state+"-pmc"];
+	    for (i in pmcgroup) {
+		pmcl.push(linkCommitterIndex(pmcgroup[i]));
 	    }
-	    li.innerHTML = "<b>Programming language:</b> " + pls
-	    ul.appendChild(li)
-	}
-	
-	if (json['bug-database']) {
-	    var li = document.createElement('li');
-	    bd = json['bug-database']
-	    li.innerHTML = "<b>Bug-tracking:</b> <a href='" + bd + "'>" + bd +
"</a>"
-	    ul.appendChild(li)
+	    appendLiInnerHTML(ul, "<b>PMC Members (" + pmcgroup.length + "):</b> <blockquote>"
+ pmcl.join(", &nbsp;") + "</blockqoute>");
 	}
-	
-	if (json['mailing-list']) {
-	    var li = document.createElement('li');
-	    bd = json['mailing-list']
-	    xbd = bd
-	    // email instead of link?
-	    if (bd.match(/@/)) {
-		xbd = "mailto:" + bd
-	    }
-	    li.innerHTML = "<b>Mailing list(s):</b> <a href='" + xbd + "'>" +
bd + "</a>"
-	    ul.appendChild(li)
+    }
+
+    // Committers
+    if (unixgroups[state] && (isTLP || isIncubating)) {
+	var commitl = [];
+	var commitgroup = unixgroups[state];
+	for (i in commitgroup) {
+	    commitl.push(linkCommitterIndex(commitgroup[i]));
 	}
-	
-	obj.appendChild(ul);
-    
-	// repositories
-	var p = document.createElement('h4');
-	p.innerHTML = "Repositories:"
-	obj.appendChild(p);	
-	var ul = document.createElement('ul');
-	if (json.SVNRepository&& json.SVNRepository.length > 0) {
-	    var li = document.createElement('li');
-	    li.innerHTML = "<b>Subversion:</b> <a target=*_blank' href='" + json.SVNRepository
+ "'>" + json.SVNRepository + "</a>"
-	    ul.appendChild(li);
+	appendLiInnerHTML(ul, "<b>Committers (" + commitgroup.length + "):</b> <blockquote>"
+ commitl.join(", &nbsp;") + "</blockqoute>");
+    }
+
+    // maintainer
+    if (json.maintainer && json.maintainer.Person && json.maintainer.Person.mbox)
{
+	var mt = json.maintainer.Person.mbox;
+	appendLiInnerHTML(ul, "<b>Project data maintainer:</b> <a href='" + mt +
"'>" + mt.substr(mt.indexOf(":") + 1) + "</a>");
+    }
+    // doap/rdf
+    if (json.doap) {
+	appendLiInnerHTML(ul, "<b>Project data file:</b> <a href='" + json.doap +
"' target='_blank'>RDF Source</a>");
+    }
+
+    obj.appendChild(ul);
+
+    // Code data
+    appendElementWithInnerHTML(obj,'h4',"Development:");
+    ul = document.createElement('ul');
+
+    if (json['programming-language']) {
+	pl = json['programming-language'];
+	var arr = pl.split(/,\s*/);
+	pls = "";
+	for (i in arr) {
+	    pls += "<a href='/projects.html?language#" + arr[i] + "'>" + arr[i] + "</a>
&nbsp; ";
 	}
-	if (json.GitRepository && json.GitRepository.length > 0) {
-	    var li = document.createElement('li');
-	    li.innerHTML = "<b>Git:</b> <a target=*_blank' href='" + json.GitRepository
+ "'>" + json.GitRepository + "</a>"
-	    ul.appendChild(li);
+	appendLiInnerHTML(ul, "<b>Programming language:</b> " + pls);
+    }
+
+    if (json['bug-database']) {
+	var bd = json['bug-database'];
+	appendLiInnerHTML(ul, "<b>Bug-tracking:</b> <a href='" + bd + "'>" + bd
+ "</a>");
+    }
+
+    if (json['mailing-list']) {
+	bd = json['mailing-list'];
+	var xbd = bd;
+	// email instead of link?
+	if (bd.match(/@/)) {
+	    xbd = "mailto:" + bd;
 	}
-	obj.appendChild(ul);
-    } else {
-	obj.innerHTML = "<h2>Sorry, I don't have any information available about this project</h2>"
+	appendLiInnerHTML(ul, "<b>Mailing list(s):</b> <a href='" + xbd + "'>"
+ bd + "</a>");
     }
-    
+
+    obj.appendChild(ul);
+
+    // repositories
+    appendElementWithInnerHTML(obj,'h4',"Repositories:");
+    ul = document.createElement('ul');
+    if (json.SVNRepository&& json.SVNRepository.length > 0) {
+	appendLiInnerHTML(ul, "<b>Subversion:</b> <a target=*_blank' href='" + json.SVNRepository
+ "'>" + json.SVNRepository + "</a>");
+    }
+    if (json.GitRepository && json.GitRepository.length > 0) {
+	appendLiInnerHTML(ul, "<b>Git:</b> <a target=*_blank' href='" + json.GitRepository
+ "'>" + json.GitRepository + "</a>");
+    }
+    obj.appendChild(ul);
 }
 
 
@@ -510,9 +483,7 @@ function renderProjectsList(cat) {
 	var ul = document.createElement('ul');
 	for (i in projectsSorted) {
 	    project = projectsSorted[i]
-	    var li = document.createElement('li');
-	    li.innerHTML = projectIcon(projects[project].name) + projectLink(project);
-	    ul.appendChild(li)
+	    appendLiInnerHTML(ul, projectIcon(projects[project].name) + projectLink(project));
 	}
 	obj.appendChild(ul);
     }
@@ -520,18 +491,18 @@ function renderProjectsList(cat) {
     // By language
     if (cat == "language") {
 	// Title + description
-	obj.innerHTML = "<h1>Projects by language:</h1>"
+	obj.innerHTML = "<h1>Projects by language:</h1>";
     
 	// Compile Language array
-	var lingos = []
-	var lcount = {}
+	var lingos = [];
+	var lcount = {};
 	for (i in projects) {
 	    if (projects[i]['programming-language']) {
-		var a = projects[i]['programming-language'].split(/,\s*/)
+		var a = projects[i]['programming-language'].split(/,\s*/);
 		for (x in a) {
-		    a[x] = camelCase(a[x])
+		    a[x] = camelCase(a[x]);
 		    if (lingos.indexOf(a[x]) < 0) {
-			lingos.push(a[x])
+			lingos.push(a[x]);
 			lcount[a[x]] = 0;
 		    }
 		    lcount[a[x]]++;
@@ -540,23 +511,21 @@ function renderProjectsList(cat) {
 	}
 	
 	// Construct language list
-	lingos.sort()
+	lingos.sort();
 	var ul = document.createElement('ul');
 	
 	for (l in lingos) {
-	    var lang = lingos[l]
+	    var lang = lingos[l];
 	    var li = document.createElement('li');
-	    li.innerHTML = "<h3><a id='" + lang + "'>" + lang + " (" + lcount[lang]
+ ")</a>:</h3>"
+	    li.innerHTML = "<h3><a id='" + lang + "'>" + lang + " (" + lcount[lang]
+ ")</a>:</h3>";
 	    var cul = document.createElement('ul');
 	    for (i in projectsSorted) {
-		i = projectsSorted[i]
+		i = projectsSorted[i];
 		if (projects[i]['programming-language']) {
-		    var a = projects[i]['programming-language'].split(/,\s*/)
+		    var a = projects[i]['programming-language'].split(/,\s*/);
 		    for (x in a) {
 			if (a[x].toLowerCase() == lang.toLowerCase()) {
-			    var cli = document.createElement('li');
-			    cli.innerHTML = projectIcon(projects[i].name) + projectLink(i);
-			    cul.appendChild(cli)
+			    appendLiInnerHTML(cul, projectIcon(projects[i].name) + projectLink(i));
 			}
 		    }
 		}
@@ -570,46 +539,43 @@ function renderProjectsList(cat) {
     // By category
     if (cat == "category") {
 	// Title + description
-	obj.innerHTML = "<h1>Projects by category:</h1>"
+	obj.innerHTML = "<h1>Projects by category:</h1>";
     
-	var cats = []
-	var ccount = {}
+	var cats = [];
+	var ccount = {};
 	for (i in projects) {
 	    if (projects[i].category) {
-		var a = projects[i].category.split(/,\s*/)
-		for (x in a) {
-		    a[x] = a[x].replace("http://projects.apache.org/category/", "").toLowerCase();
-		}
+		var a = projects[i].category.replace(new RegExp("http://projects.apache.org/category/",
'g'), '').toLowerCase().split(/,\s*/);
 		for (x in a) {
-		    if (cats.indexOf(a[x]) < 0) {
-			cats.push(a[x])
-			ccount[a[x]] = 0;
+                    x = a[x];
+		    if (cats.indexOf(x) < 0) {
+			cats.push(x);
+			ccount[x] = 0;
 		    }
-		    ccount[a[x]]++;
+		    ccount[x]++;
 		}
 	    }
 	    
 	}
-	cats.sort()
+	cats.sort();
 	
 	// Construct category list
 	var ul = document.createElement('ul');
 	
 	for (l in cats) {
-	    var lang = cats[l]
+	    var lang = cats[l];
 	    var li = document.createElement('li');
-	    li.innerHTML = "<h3><a id='" + lang + "'>" + lang + " (" + ccount[lang]
+ ")</a>:</h3>"
+	    li.innerHTML = "<h3><a id='" + lang + "'>" + lang + " (" + ccount[lang]
+ ")</a>:</h3>";
 	    var cul = document.createElement('ul');
 	    for (i in projectsSorted) {
-		i = projectsSorted[i]
-		if (projects[i].category) {
-		    var a = projects[i]['category'].split(/,\s*/)
+		i = projectsSorted[i];
+                var project = projects[i];
+		if (project.category) {
+                    var a = project.category.replace(new RegExp("http://projects.apache.org/category/",
'g'), '').toLowerCase().split(/,\s*/);
 		    for (x in a) {
-			a[x] = a[x].replace("http://projects.apache.org/category/", "").toLowerCase();
-			if (a[x] == lang) {
-			    var cli = document.createElement('li');
-			    cli.innerHTML = projectIcon(projects[i].name) + projectLink(i);
-			    cul.appendChild(cli)
+			x = a[x];
+			if (x == lang) {
+			    appendLiInnerHTML(cul, projectIcon(project.name) + projectLink(i));
 			}
 		    }
 		}
@@ -624,16 +590,16 @@ function renderProjectsList(cat) {
     // By date founded
     if (cat == "date") {
 	// Title + description
-	obj.innerHTML = "<h1>Projects by founding date (TLPs only):</h1>"
+	obj.innerHTML = "<h1>Projects by founding date (TLPs only):</h1>";
     
-	var dates = []
-	var dcount = {}
+	var dates = [];
+	var dcount = {};
 	for (i in projects) {
 	    if (committees[projects[i].name]) {
-		var date = committees[projects[i].name]
+		var date = committees[projects[i].name];
 	    
 		if (dates.indexOf(date) < 0) {
-		    dates.push(date)
+		    dates.push(date);
 		    dcount[date] = 0;
 		}
 		dcount[date]++;
@@ -655,9 +621,7 @@ function renderProjectsList(cat) {
 		 if (committees[projects[i].name]) {
 		    xdate = committees[projects[i].name]
 		    if (xdate == date) {
-			var cli = document.createElement('li');
-			cli.innerHTML = projectIcon(projects[i].name) + projectLink(i);
-			cul.appendChild(cli)
+			appendLiInnerHTML(cul, projectIcon(projects[i].name) + projectLink(i));
 		    }
 		 }
 	    }
@@ -672,38 +636,37 @@ function renderProjectsList(cat) {
     // By number of committers
     if (cat == "number") {
 	// Title + description
-	obj.innerHTML = "<h1>Projects by number of committers:</h1>"
+	obj.innerHTML = "<h1>Projects by number of committers:</h1>";
     
-	var lens = []
-	var lcount = {}
+	var lens = [];
+	var lcount = {};
 	for (i in projects) {
 	    if (unixgroups[i] && i != 'incubator') {
 		var len = unixgroups[i].length;
 		if (lens.indexOf(len) < 0) {
-		    lens.push(len)
+		    lens.push(len);
 		    lcount[len] = 0;
 		}
 		lcount[len]++;
 	    }
 	}
-	lens.sort(function(a,b) { return b - a })
+	lens.sort(function(a,b) { return b - a });
 	
 	// Construct date list
 	var ul = document.createElement('ul');
 	
 	for (l in lens) {
-	    var len = lens[l]
+	    var len = lens[l];
 	    for (i in projectsSorted) {
-		i = projectsSorted[i]
+		i = projectsSorted[i];
 		if (unixgroups[i]) {
-		    var xlen = unixgroups[i].length
+		    var xlen = unixgroups[i].length;
 		    if (xlen == len) {
-			var cli = document.createElement('li');
-			cli.innerHTML = projectIcon(projects[i].name) + projectLink(i) + ": " + len + " committers";
+			var html = projectIcon(projects[i].name) + projectLink(i) + ": " + len + " committers";
 			if (unixgroups[i+'-pmc']) {
-			    cli.innerHTML += ", " + unixgroups[i+'-pmc'].length + " PMC members";
+			    html += ", " + unixgroups[i+'-pmc'].length + " PMC members";
 			}
-			ul.appendChild(cli)
+			appendLiInnerHTML(ul,html);
 		    }
 		 }
 	    }
@@ -715,17 +678,18 @@ function renderProjectsList(cat) {
     // By PMC
     if (cat == "pmc") {
 	// Title + description
-	obj.innerHTML = "<h1>Projects by PMC:</h1>"
+	obj.innerHTML = "<h1>Projects by PMC:</h1>";
     
-	var lpmcs = []
-	var dcount = {}
+	var lpmcs = [];
+	var dcount = {};
 	for (i in projects) {
+	    i = projects[i];
 	    // Fix Incubating projects
-	    if (projects[i].name.match("incubating", "i")) {
-		projects[i].pmc = 'incubator'
+	    if (i.name.match("incubating", "i")) {
+		i.pmc = 'incubator'
 	    }
-	    if (pmcs[projects[i].pmc]) {
-		var lpmc = projects[i].pmc
+	    if (pmcs[i.pmc]) {
+		var lpmc = i.pmc
 	    
 		if (lpmcs.indexOf(lpmc) < 0) {
 		    lpmcs.push(lpmc)
@@ -741,22 +705,21 @@ function renderProjectsList(cat) {
 	var ul = document.createElement('ul');
 	
 	for (l in lpmcs) {
-	    var lpmc = lpmcs[l]
+	    var lpmc = lpmcs[l];
 	    var li = document.createElement('li');
-	    li.innerHTML = "<h3><a id='" + lpmc + "'>" + pmcs[lpmc].name + " (" + dcount[lpmc]
+ ")</a>:</h3>"
+	    li.innerHTML = "<h3><a id='" + lpmc + "'>" + pmcs[lpmc].name + " (" + dcount[lpmc]
+ ")</a>:</h3>";
 	    var cul = document.createElement('ul');
 	    for (i in projectsSorted) {
-		i = projectsSorted[i]
+		i = projectsSorted[i];
+		var project = projects[i];
 		// Fix Incubating projects
-		if (projects[i].name.match("incubating", "i")) {
-		    projects[i].pmc = 'incubator'
+		if (project.name.match("incubating", "i")) {
+		    project.pmc = 'incubator'
 		}
-		 if (pmcs[projects[i].pmc]) {
-		    xlpmc = projects[i].pmc
+		 if (pmcs[project.pmc]) {
+		    xlpmc = project.pmc;
 		    if (xlpmc == lpmc) {
-			var cli = document.createElement('li');
-			cli.innerHTML = projectIcon(projects[i].name) + projectLink(i);
-			cul.appendChild(cli)
+			appendLiInnerHTML(cul,projectIcon(project.name) + projectLink(i));
 		    }
 		 }
 	    }
@@ -784,32 +747,32 @@ function buildProjectList(json) {
 
 // Rendering project list using DataTables instead of the usual stuff:
 function buildProjectListAsTable(json) {
-    var arr = []
+    var arr = [];
     for (p in projects) {
-	var project = projects[p]
+	var project = projects[p];
 	
 	// Get name of PMC
-	var pmc = pmcs[project.pmc] ? pmcs[project.pmc].name : "Unknown"
+	var pmc = pmcs[project.pmc] ? pmcs[project.pmc].name : "Unknown";
 	
 	// Get project type
-	var type = "Sub-Project"
+	var type = "Sub-Project";
 	var shortp = p.split("-")[0];
 	if (unixgroups[shortp]) {
-	    type = "TLP"
+	    type = "TLP";
 	    if ((!committees[project.name] && pmcs[project.pmc]) || project.name.match(/incubating/i))
{
-		type = "Sub-project"
+		type = "Sub-project";
 	    }
 	} else {
-	    type = "Retired"
+	    type = "Retired";
 	}
 	
 	if (project.podling || project.name.match(/incubating/i)) {
-	    type = "Podling"
-	    pmc = "Apache Incubator"
+	    type = "Podling";
+	    pmc = "Apache Incubator";
 	}
 	
 	// Project category, minus the old RDF cruft
-	var cat = (project.category ? project.category : "").replace(/http:\/\/projects.apache.org\/category\/?/g,
"")
+	var cat = (project.category ? project.category : "").replace(/http:\/\/projects.apache.org\/category\/?/g,
"");
 	
 	// Programming language
 	var pl = project['programming-language'] ? project['programming-language'] : "Unknown";
@@ -846,10 +809,7 @@ function buildProjectListAsTable(json) {
 
 
 function isTLP(project) {
-    if (committees[project]) {
-	return true;
-    }
-    return false
+    return committees[project];
 }
 
 // ------------ Front page rendering ------------\\
@@ -861,29 +821,33 @@ function htmlListTooltip(date,name,value
 }
 
 function renderFrontPage() {
-    numchairs = 0;
+    var numchairs = 0;
     for (i in committees) numchairs++;
     cur = evolution[0].current;
     var nsubs = 0;
     
     for (i in projects) {
-	if (!projects[i].name.match(/incubating/i)) {
+	i = projects[i];
+	if (!i.name.match(/incubating/i)) {
 	    initiatives++;
-	}
-	if (!isTLP(projects[i].name) && !projects[i].name.match(/incubating/i)) {
-	    nsubs++;
+	    if (!isTLP(i.name)) {
+		nsubs++;
+	    }
 	}
     }
     var initiatives = cur + numchairs + nsubs + 5; // podlings + tlps + sub-projects + specials
     initiatives -= initiatives % 100; // round down
     var obj = document.getElementById('contents');
     obj.innerHTML = "<h2>Welcome to the Apache Projects Directory</h2>"
-    obj.innerHTML += "<p>This site is a catalog of Apache Software Foundation projects.
It is designed to help you find specific projects that meet your interests and to gain a broader
understanding of the wide variety of work currently underway in the Apache community.</p>"
-    var p = document.createElement('p');
-    p.innerHTML = "<h3 style='text-align: center;'>There are currently <span style='color:
#269;'>" + initiatives + "+</span> open source initatives at the ASF:</h3>";
-    p.innerHTML += "<ul style='width: 300px; margin: 0 auto; font-size: 18px; color: #269;
font-weight: bold;'><li>" + numchairs + " top level software projects</li><li>"
+ nsubs + " sub-projects</li><li>5 special committees*</li><li>" +
cur + " incubating podlings</li></ul><p><small>*Infrastructure, Travel
Assistance, Security Team, Legal Affairs and Brand Management</small></p>"
-    obj.appendChild(p);
-    
+	+ "<p>This site is a catalog of Apache Software Foundation projects. It is designed
to help you find specific projects that meet your interests and to gain a broader understanding
of the wide variety of work currently underway in the Apache community.</p>"
+    appendElementWithInnerHTML(obj,'p',"<h3 style='text-align: center;'>There are currently
<span style='color: #269;'>" + initiatives + "+</span> open source initatives
at the ASF:</h3>"
+	+ "<ul style='width: 300px; margin: 0 auto; font-size: 18px; color: #269; font-weight:
bold;'>"
+    	+ "<li>" + numchairs + " top level software projects</li>"
+    	+ "<li>" + nsubs + " sub-projects</li>"
+    	+ "<li>5 special committees*</li>"
+    	+ "<li>" + cur + " incubating podlings</li></ul>"
+    	+ "<p><small>*Infrastructure, Travel Assistance, Security Team, Legal Affairs
and Brand Management</small></p>");
+
     var parr = [];
     var cur = 0;
     var karr = [];
@@ -892,12 +856,12 @@ function renderFrontPage() {
     }
     karr.sort();
     
-    for (j in karr) {
+    for (var j in karr) {
 	var i = karr[j];
 	var changes = committees_raw[i];
 	var newTlps = [];
 	var retiredTlps = [];
-	for (k in changes) {
+	for (var k in changes) {
 	    var change = changes[k];
 	    if (change.match(/retired: /)) {
 		retiredTlps.push(change.substring(9))
@@ -930,7 +894,7 @@ function renderFrontPage() {
 	tooltip: {isHtml: true},
 	vAxes:[
               {title: 'Change in states'},
-              {title: 'Current number of TLPs'},
+              {title: 'Current number of TLPs'}
               ]
     };
     var div = document.createElement('div');
@@ -942,9 +906,10 @@ function renderFrontPage() {
     var earr = [];
     for (i in evolution) {
 	if (i > 260) {
-	    break
+	    break;
 	}
-	earr.push([evolution[i].month, evolution[i].new, evolution[i].graduated, evolution[i].retired,
evolution[i].current]);
+	var evo = evolution[i];
+	earr.push([evo.month, evo.new, evo.graduated, evo.retired, evo.current]);
     }
     //narr.sort(function(a,b) { return (b[1] - a[1]) });
     var data = new google.visualization.DataTable();
@@ -965,10 +930,10 @@ function renderFrontPage() {
 	series: {3: {type: "line", targetAxisIndex: 1}},
 	vAxes:[
               {title: 'Change in states'},
-              {title: 'Current number of podlings'},
+              {title: 'Current number of podlings'}
               ]
     };
-    var div = document.createElement('div');
+    div = document.createElement('div');
     obj.appendChild(div);
     chart = new google.visualization.ComboChart(div);
     chart.draw(data, coptions);
@@ -986,26 +951,28 @@ function renderLanguageChart() {
     
     
     // Languages
-    var lingos = []
-    var lcount = {}
+    var lingos = [];
+    var lcount = {};
     for (i in projects) {
-	if (projects[i]['programming-language']) {
-	    var a = projects[i]['programming-language'].split(", ")
+        i = projects[i];
+	if (i['programming-language']) {
+	    var a = i['programming-language'].split(", ");
 	    for (x in a) {
-		if (lingos.indexOf(a[x]) < 0) {
-		    lingos.push(a[x])
-		    lcount[a[x]] = 0;
+                x = a[x];
+		if (lingos.indexOf(x) < 0) {
+		    lingos.push(x);
+		    lcount[x] = 0;
 		}
-		lcount[a[x]]++;
+		lcount[x]++;
 	    }
 	}
     }
     
     
-    narr = []
+    narr = [];
     for (i in lingos) {
-	var lang = lingos[i]
-	narr.push([lang, lcount[lang], 'Click here to view all projects using ' + lang])
+	var lang = lingos[i];
+	narr.push([lang, lcount[lang], 'Click here to view all projects using ' + lang]);
     }
     narr.sort(function(a,b) { return (b[1] - a[1]) });
     
@@ -1022,7 +989,7 @@ function renderLanguageChart() {
     };
 
     var chart = new google.visualization.PieChart(chartDiv);
-    obj.appendChild(chartDiv)
+    obj.appendChild(chartDiv);
     
     function selectHandlerLanguage() {
 	var selectedItem = chart.getSelection()[0];
@@ -1036,17 +1003,18 @@ function renderLanguageChart() {
     
     
     // Categories    
-    var cats = []
-    var ccount = {}
+    var cats = [];
+    var ccount = {};
     for (i in projects) {
-	if (projects[i].category) {
-	    var a = projects[i].category.split(", ")
-	    for (x in a) {
+	i = projects[i];
+	if (i.category) {
+	    var a = i.category.split(", ");
+	    for (var x in a) {
 		a[x] = a[x].replace("http://projects.apache.org/category/", "");
 	    }
 	    for (x in a) {
 		if (cats.indexOf(a[x]) < 0) {
-		    cats.push(a[x])
+		    cats.push(a[x]);
 		    ccount[a[x]] = 0;
 		}
 		ccount[a[x]]++;
@@ -1055,9 +1023,9 @@ function renderLanguageChart() {
     }
     
     
-    carr = []
+    carr = [];
     for (i in cats) {
-	var cat = cats[i]
+	var cat = cats[i];
 	carr.push([cat, ccount[cat], 'Click here to view all projects in the ' + cat + ' category'])
     }
     carr.sort(function(a,b) { return (b[1] - a[1]) });
@@ -1077,7 +1045,7 @@ function renderLanguageChart() {
 
     var chartDiv = document.createElement('div');
     var chart2 = new google.visualization.PieChart(chartDiv);
-    obj.appendChild(chartDiv)
+    obj.appendChild(chartDiv);
     
     
     function selectHandlerCategory() {
@@ -1102,8 +1070,9 @@ function buildFrontPage() {
 // ------- Account creation chart function -------- \\
 
 function drawAccountCreation() {
-
-    var narr = new Array();
+    var i;
+    var j;
+    var narr = [];
     var json = accounts;
     var obj = document.createElement('div');
     obj.style = "float: left; width: 1160px; height: 450px;";
@@ -1114,20 +1083,20 @@ function drawAccountCreation() {
     cdata.addColumn('number', 'New committers');
     cdata.addColumn('number', 'Total number of committers');
     var max = 0;
-    var jsort = []
-    for (var j in json) {
-	jsort.push(j)
+    var jsort = [];
+    for (j in json) {
+	jsort.push(j);
     }
     
     jsort.sort();
-    var c = 0
-    for (var i in jsort) {
-	var j = jsort[i]
-	var entry = json[j];
-	var arr = j.split("-");
+    var c = 0;
+    for (i in jsort) {
+	i = jsort[i];
+	var entry = json[i];
+	var arr = i.split("-");
 	var d = new Date(parseInt(arr[0]), parseInt(arr[1]), 1);
-	c += entry
-	narr.push([j, entry, c])
+	c += entry;
+	narr.push([i, entry, c]);
 	max = (max < entry) ? entry : max;
     }
     cdata.addRows(narr);
@@ -1146,7 +1115,7 @@ function drawAccountCreation() {
 	0: {type: "bars", targetAxisIndex: 0, maxValue: max*2}
 	},
 	seriesType: "bars",
-      tooltip: {isHtml: true},
+      tooltip: {isHtml: true}
     };
 
     var chart = new google.visualization.ComboChart(obj);
@@ -1160,16 +1129,16 @@ function drawAccountCreation() {
 function searchProjects(str) {
     var obj = document.getElementById('contents');
     
-    str = str.toLowerCase()
-    hits = {}
-    hitssorted = []
+    str = str.toLowerCase();
+    hits = {};
+    hitssorted = [];
     
     // Search TLPs
     for (p in projects) {
 	var project = projects[p];
 	for (key in project) {
 	    if (typeof project[key] == "string") {
-	        val = project[key].toLowerCase()
+	        val = project[key].toLowerCase();
 		if (val.indexOf(str) >= 0 && val.substr(0,1) != "{") {
 		    if (!hits[p]) {
 			hits[p] = [];
@@ -1178,7 +1147,7 @@ function searchProjects(str) {
 		    hits[p].push({
 			'key': key,
 			'val': project[key].replace(estr, function(a) { return "<u style='color: #963;'>"+a+"</u>"},
"img")
-		    })
+		    });
 		    if (hitssorted.indexOf(p) < 0) {
 			hitssorted.push(p);
 		    }
@@ -1187,21 +1156,21 @@ function searchProjects(str) {
 	}
     }
     
-    obj.innerHTML = "<h2>Search results for '" + str + "' (" + hitssorted.length +
"):</h2>"
-    hitssorted.sort(function(a,b) { return hits[b].length - hits[a].length })
+    obj.innerHTML = "<h2>Search results for '" + str + "' (" + hitssorted.length +
"):</h2>";
+    hitssorted.sort(function(a,b) { return hits[b].length - hits[a].length });
     var ul = document.createElement('ul');
 	
     for (h in hitssorted) {
-	var project = hits[hitssorted[h]]
-	var li = document.createElement('li');
-	li.innerHTML = "<h4><a href='/project.html?" + hitssorted[h] + "'>" + projects[hitssorted[h]].name
+ "</a> (" + project.length + " hit(s)):</h4>"
+        h = hitssorted;
+	var project = hits[h];
+	var html = "<h4><a href='/project.html?" + h + "'>" + projects[h].name + "</a>
(" + project.length + " hit(s)):</h4>";
 	for (x in project) {
-	    li.innerHTML += "<blockquote><b>" + project[x].key + ":</b> " +  project[x].val
+ "</blockquote>"
+	    html += "<blockquote><b>" + project[x].key + ":</b> " +  project[x].val
+ "</blockquote>";
 	}
-	ul.appendChild(li);
+	appendLiInnerHTML(ul,html);
     }
     if (hitssorted.length == 0) {
-	obj.innerHTML += "No search results found"
+	obj.innerHTML += "No search results found";
     }
     obj.appendChild(ul);
 }
@@ -1233,7 +1202,7 @@ function setCommittees(json, state) {
     committees_raw = json
     for (established in json) {
 	for (j in json[established]) {
-		var name = json[established][j]
+		var name = json[established][j];
 		if (name.match(/retired: /i)) {
 			delete committees[name.substring(9)]
 		} else {
@@ -1249,14 +1218,14 @@ function setCommittees(json, state) {
 
 // Render releases using datatables
 function buildReleases() {
-    var arr = []
+    var arr = [];
     for (p in releases) {
-	var releasedata = releases[p]
+	var releasedata = releases[p];
 	
 	for (filename in releasedata) {
-	    var date = releasedata[filename]
+	    var date = releasedata[filename];
 	    // Shove the result into a row
-	    arr.push([ p, p, date, filename])
+	    arr.push([ p, p, date, filename]);
 	}
 	
     }
@@ -1270,7 +1239,7 @@ function buildReleases() {
 	    { "title": "ID", "visible": false },
 	    { "title": "Name" },
 	    { "title": "Date" },
-	    { "title": "Release name" },
+	    { "title": "Release name" }
 	],
 	"fnRowCallback": function( nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                     jQuery(nRow).attr('id', aData[0]);
@@ -1281,7 +1250,7 @@ function buildReleases() {
     
     $('#releases tbody').on('click', 'tr', function () {
         var name = $(this).attr('id');
-        location.href = "https://www.apache.org/dist/" + name
+        location.href = "https://www.apache.org/dist/" + name;
     } );
 }
 
@@ -1302,7 +1271,7 @@ function preloadEverything(callback) {
 	    ["/json/foundation/tlps-evolution.json", setCommittees],
 	    ["/json/foundation/projects.json", weaveInProjects],
 	    ["/json/foundation/podlings.json", weaveInProjects],
-	    ["/json/foundation/releases.json", function(json) { releases = json; }],
+	    ["/json/foundation/releases.json", function(json) { releases = json; }]
         ],
 	callback);
 }



Mime
View raw message