// log file structure: website, page, N.R., ip, host, datetime
function readLog2Array()
{
logLines = $("filelog").value.split("\n");
sitesCounter = [];
ipCounter = [];
for (i=0 ; i< logLines.length ; i++) {
line = logLines[i].split(",");
// sites counter
if (sitesCounter[line[0]] == undefined)
sitesCounter[line[0]] = 1;
else
sitesCounter[line[0]] +=1 ;
// IP counter
if (ipCounter[line[3]] == undefined)
ipCounter[line[3]] = {counter:1} // ,city:,region:,country:}; will be added later
else
ipCounter[line[3]].counter +=1 ;
}
// console.log(sitesCounter);
// console.log(ipCounter);
sitesCouterByVizit = []; // simple array of object to sort
for (site1 in sitesCounter) {
sitesCouterByVizit.push({"site":site1,"visit":sitesCounter[site1]} );
}
// Sorting the simple array based on JSON objects
sitesCouterByVizit.sort( function(a,b) { return b.visit - a.visit} );
// console.log(sitesCouterByVizit);
}