From commits-return-1486-apmail-community-commits-archive=community.apache.org@community.apache.org Thu May 14 13:18:02 2015 Return-Path: X-Original-To: apmail-community-commits-archive@minotaur.apache.org Delivered-To: apmail-community-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 13FAE10774 for ; Thu, 14 May 2015 13:18:02 +0000 (UTC) Received: (qmail 27238 invoked by uid 500); 14 May 2015 13:18:01 -0000 Delivered-To: apmail-community-commits-archive@community.apache.org Received: (qmail 27214 invoked by uid 500); 14 May 2015 13:18:01 -0000 Mailing-List: contact commits-help@community.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@community.apache.org Delivered-To: mailing list commits@community.apache.org Received: (qmail 27205 invoked by uid 99); 14 May 2015 13:18:01 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 May 2015 13:18:01 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id B016FAC0043 for ; Thu, 14 May 2015 13:18:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1679361 - /comdev/projects.apache.org/site/js/projects.js Date: Thu, 14 May 2015 13:18:01 -0000 To: commits@community.apache.org From: hboutemy@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150514131801.B016FAC0043@hades.apache.org> 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 "" + fullname + ""; +} + +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 = "

" + json.name + " (" + pt + "):

" - - // 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 "

"+a+"

"}); - 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 += "" + cat + "   " - } - li.innerHTML = "Category: " + pls - ul.appendChild(li) - } - - // Website - if (json.homepage) { - var li = document.createElement('li'); - li.innerHTML = "Website: " + json.homepage + "" - ul.appendChild(li) - } - var li = document.createElement('li'); - if (unixgroups[state]) { - li.innerHTML = "Project status: Active"; - } else { - li.innerHTML = "Project status: Retired(?)"; - } - if (json.podling || json.name.match(/incubating/i)) { - li.innerHTML = "Project status: Incubating"; - isIncubating = true; - } - - ul.appendChild(li) - if (committees[json.name]) { - var li = document.createElement('li'); - li.innerHTML = "Project founded: " + 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 = "Sub-project of: " + pmcs[json.pmc].name + "" - ul.appendChild(li) - } - - if (isTLP) { - - // VP - if (chairs[json.name]) { - var li = document.createElement('li'); - li.innerHTML = "PMC Chair: " + chairs[json.name]; - ul.appendChild(li) - } - - // Reporting cycle - if (cycles[json.name]) { - var li = document.createElement('li'); - li.innerHTML = "Reporting cycle: " + cycles[json.name] + ", see minutes" - 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("" + fullname + "") - } - var li = document.createElement('li'); - li.innerHTML = "PMC Members (" + pmcgroup.length + "):
" + pmcl.join(",  ") + "" - 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("" + fullname + "") - } - var li = document.createElement('li'); - li.innerHTML = "Committers (" + commitgroup.length + "):
" + commitl.join(",  ") + "" - ul.appendChild(li) + if (!json || !json.name) { + obj.innerHTML = "

Sorry, I don't have any information available about this project

"; + 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 = "

" + json.name + " (" + pt + "):

"; + + // 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 "

"+a+"

"}); + 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 += "" + cat + "   "; + } + appendLiInnerHTML(ul, "Category: " + pls); + } + + // Website + if (json.homepage) { + appendLiInnerHTML(ul, "Website: " + json.homepage + ""); + } + if (unixgroups[state]) { + appendLiInnerHTML(ul, "Project status: Active"); + } else { + appendLiInnerHTML(ul, "Project status: Retired(?)"); + } + if (json.podling || json.name.match(/incubating/i)) { + appendLiInnerHTML(ul, "Project status: Incubating"); + isIncubating = true; + } + + if (committees[json.name]) { + appendLiInnerHTML(ul, "Project founded: " + 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 = "Project data maintainer: " + mt.substr(mt.indexOf(":") + 1) + "" - ul.appendChild(li) + } else { + json.pmc = state; + } + if (!committees[json.name] && pmcs[json.pmc]) { + appendLiInnerHTML(ul, "Sub-project of: " + pmcs[json.pmc].name + ""); + } + + if (isTLP) { + + // VP + if (chairs[json.name]) { + appendLiInnerHTML(ul, "PMC Chair: " + chairs[json.name]); } - // doap/rdf - if (json.doap) { - var li = document.createElement('li'); - li.innerHTML = "Project data file: RDF Source" - ul.appendChild(li) + + // Reporting cycle + if (cycles[json.name]) { + appendLiInnerHTML(ul, "Reporting cycle: " + cycles[json.name] + ", see minutes"); } - - 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 += "" + arr[i] + "   " + + // PMC + if (unixgroups[state+"-pmc"]) { + var pmcl = []; + var pmcgroup = unixgroups[state+"-pmc"]; + for (i in pmcgroup) { + pmcl.push(linkCommitterIndex(pmcgroup[i])); } - li.innerHTML = "Programming language: " + pls - ul.appendChild(li) - } - - if (json['bug-database']) { - var li = document.createElement('li'); - bd = json['bug-database'] - li.innerHTML = "Bug-tracking: " + bd + "" - ul.appendChild(li) + appendLiInnerHTML(ul, "PMC Members (" + pmcgroup.length + "):
" + pmcl.join(",  ") + ""); } - - 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 = "Mailing list(s): " + bd + "" - 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 = "Subversion: " + json.SVNRepository + "" - ul.appendChild(li); + appendLiInnerHTML(ul, "Committers (" + commitgroup.length + "):
" + commitl.join(",  ") + ""); + } + + // maintainer + if (json.maintainer && json.maintainer.Person && json.maintainer.Person.mbox) { + var mt = json.maintainer.Person.mbox; + appendLiInnerHTML(ul, "Project data maintainer: " + mt.substr(mt.indexOf(":") + 1) + ""); + } + // doap/rdf + if (json.doap) { + appendLiInnerHTML(ul, "Project data file: RDF Source"); + } + + 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 += "" + arr[i] + "   "; } - if (json.GitRepository && json.GitRepository.length > 0) { - var li = document.createElement('li'); - li.innerHTML = "Git: " + json.GitRepository + "" - ul.appendChild(li); + appendLiInnerHTML(ul, "Programming language: " + pls); + } + + if (json['bug-database']) { + var bd = json['bug-database']; + appendLiInnerHTML(ul, "Bug-tracking: " + bd + ""); + } + + 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 = "

Sorry, I don't have any information available about this project

" + appendLiInnerHTML(ul, "Mailing list(s): " + bd + ""); } - + + obj.appendChild(ul); + + // repositories + appendElementWithInnerHTML(obj,'h4',"Repositories:"); + ul = document.createElement('ul'); + if (json.SVNRepository&& json.SVNRepository.length > 0) { + appendLiInnerHTML(ul, "Subversion: " + json.SVNRepository + ""); + } + if (json.GitRepository && json.GitRepository.length > 0) { + appendLiInnerHTML(ul, "Git: " + json.GitRepository + ""); + } + 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 = "

Projects by language:

" + obj.innerHTML = "

Projects by language:

"; // 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 = "

" + lang + " (" + lcount[lang] + "):

" + li.innerHTML = "

" + lang + " (" + lcount[lang] + "):

"; 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 = "

Projects by category:

" + obj.innerHTML = "

Projects by category:

"; - 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 = "

" + lang + " (" + ccount[lang] + "):

" + li.innerHTML = "

" + lang + " (" + ccount[lang] + "):

"; 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 = "

Projects by founding date (TLPs only):

" + obj.innerHTML = "

Projects by founding date (TLPs only):

"; - 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 = "

Projects by number of committers:

" + obj.innerHTML = "

Projects by number of committers:

"; - 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 = "

Projects by PMC:

" + obj.innerHTML = "

Projects by PMC:

"; - 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 = "

" + pmcs[lpmc].name + " (" + dcount[lpmc] + "):

" + li.innerHTML = "

" + pmcs[lpmc].name + " (" + dcount[lpmc] + "):

"; 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 = "

Welcome to the Apache Projects Directory

" - obj.innerHTML += "

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.

" - var p = document.createElement('p'); - p.innerHTML = "

There are currently " + initiatives + "+ open source initatives at the ASF:

"; - p.innerHTML += "
  • " + numchairs + " top level software projects
  • " + nsubs + " sub-projects
  • 5 special committees*
  • " + cur + " incubating podlings

*Infrastructure, Travel Assistance, Security Team, Legal Affairs and Brand Management

" - obj.appendChild(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.

" + appendElementWithInnerHTML(obj,'p',"

There are currently " + initiatives + "+ open source initatives at the ASF:

" + + "
    " + + "
  • " + numchairs + " top level software projects
  • " + + "
  • " + nsubs + " sub-projects
  • " + + "
  • 5 special committees*
  • " + + "
  • " + cur + " incubating podlings
" + + "

*Infrastructure, Travel Assistance, Security Team, Legal Affairs and Brand Management

"); + 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 ""+a+""}, "img") - }) + }); if (hitssorted.indexOf(p) < 0) { hitssorted.push(p); } @@ -1187,21 +1156,21 @@ function searchProjects(str) { } } - obj.innerHTML = "

Search results for '" + str + "' (" + hitssorted.length + "):

" - hitssorted.sort(function(a,b) { return hits[b].length - hits[a].length }) + obj.innerHTML = "

Search results for '" + str + "' (" + hitssorted.length + "):

"; + 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 = "

" + projects[hitssorted[h]].name + " (" + project.length + " hit(s)):

" + h = hitssorted; + var project = hits[h]; + var html = "

" + projects[h].name + " (" + project.length + " hit(s)):

"; for (x in project) { - li.innerHTML += "
" + project[x].key + ": " + project[x].val + "
" + html += "
" + project[x].key + ": " + project[x].val + "
"; } - 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); }