Add detailed name states

master
Ringo Watanabe 6 years ago
parent 05d5ee0279
commit adf885a772

@ -8,6 +8,7 @@ function Cycle()
this.number = 0; //number of new posts this cycle this.number = 0; //number of new posts this cycle
this.countries = {}; //stored as <code>: <number of times> this.countries = {}; //stored as <code>: <number of times>
this.namefags = {}; //stored as <name>: <number of times>
this.timestamp = new Date() this.timestamp = new Date()
this.threads=0; //number of new threads this.threads=0; //number of new threads

@ -15,6 +15,14 @@ function cycleAdd(rets, ar)
ret.countries[index]= ar[i].countries[index]; ret.countries[index]= ar[i].countries[index];
} }
for(var index in ar[i].namefags)
{
if(index in ret.namefags)
ret.namefags[index]+=ar[i].namefags[index];
else
ret.namefags[index]= ar[i].namefags[index];
}
ret.threads+=ar[i].threads; ret.threads+=ar[i].threads;
ret.comments+=ar[i].comments; ret.comments+=ar[i].comments;
ret.subjects+=ar[i].subjects; ret.subjects+=ar[i].subjects;
@ -47,7 +55,7 @@ function cycleAcc(rets, ar, n)
ret.countries[index]= acc(ret.countries[index], ar[i].countries[index], n); ret.countries[index]= acc(ret.countries[index], ar[i].countries[index], n);
else else
ret.countries[index]= acc(0, ar[i].countries[index], n); ret.countries[index]= acc(0, ar[i].countries[index], n);
}*/ //TODO: Implement this }*/ //TODO: Implement this & names?
ret.threads= acc(ret.threads, ar[i].threads, n); ret.threads= acc(ret.threads, ar[i].threads, n);
ret.comments = acc(ret.comments, ar[i].comments, n); ret.comments = acc(ret.comments, ar[i].comments, n);

@ -233,6 +233,22 @@ server.listen(config.PORT);
logger.log("Listening on port "+config.PORT); logger.log("Listening on port "+config.PORT);
function addNames(cycle, json)
{
var str = "Anonymous";
if("name" in json)
str = json["name"];
if("trip" in json)
str = str+json["trip"];
if(str!="Anonymous")
{
if(str in cycle.namefags)
cycle.namefags[str] += 1;
else
cycle.namefags[str] = 1;
}
}
var backend = setInterval(function() { var backend = setInterval(function() {
//logger.log("Polling backend"); //logger.log("Polling backend");
process.execFile(config.PYTHON_EXECUTABLE, [config.RTBWCTL_FILENAME, config.BACKEND_SOCKET, "get-clear", "--data", lastNumber], function(error,stdout,stderr) { process.execFile(config.PYTHON_EXECUTABLE, [config.RTBWCTL_FILENAME, config.BACKEND_SOCKET, "get-clear", "--data", lastNumber], function(error,stdout,stderr) {
@ -278,6 +294,8 @@ var backend = setInterval(function() {
cycle.names+=1; cycle.names+=1;
else if(bein(json[i], "trip")) else if(bein(json[i], "trip"))
cycle.trips+=1; cycle.trips+=1;
addNames(cycle, json[i]);
} }
cycle.interval = timeAverage(timeInters); cycle.interval = timeAverage(timeInters);

@ -38,11 +38,25 @@ em {
} }
.expshare { .expshare {
border:solid; border:solid 1px;
border-radius: 10px; border-radius: 10px;
color: #e5e8e6; color: #e5e8e6;
} }
.expshare2 {
position: relative;
}
.indentbar {
background-color:#215615;
height: 100%;
width:10px;
position: absolute;
left: 0;
top: 0;
border-radius: 2px;
}
.tab { .tab {
border: 1px solid; border: 1px solid;
border-radius: 3px; border-radius: 3px;

@ -63,6 +63,18 @@
<canvas id='tSubjects'></canvas> <canvas id='tSubjects'></canvas>
</div> </div>
</div> </div>
Identity breakdown: <a class='expand' id='at_ident_bd_expand'>+</a>
<div>
<div class='expshare2' hidden id='at_idbd_share'>
<div class='indentbar'> </div>
<div style='padding-left: 17px'>
<div class='contain' style="height: 300px; width:20%;">
<canvas id='tNmaesDetailed'></canvas>
</div>
Show Anon <input type='checkbox' checked id='at_idbd_showanon' />
</div>
</div>
</div>
<hr></hr> <hr></hr>
<h2>Session stats</h2> <h2>Session stats</h2>
<ul> <ul>
@ -105,7 +117,18 @@
<canvas id='tsSubjects'></canvas> <canvas id='tsSubjects'></canvas>
</div> </div>
</div> </div>
Identity breakdown: <a class='expand' id='s_ident_bd_expand'>+</a>
<div>
<div class='expshare2' hidden id='s_idbd_share'>
<div class='indentbar'> </div>
<div style='padding-left: 17px'>
<div class='contain' style="height: 300px; width:20%;">
<canvas id='tsNmaesDetailed'></canvas>
</div>
Show Anon <input type='checkbox' checked id='s_idbd_showanon' />
</div>
</div>
</div>
<h3>Average comparisons</h3> <h3>Average comparisons</h3>
<div class='contain' style="height: 300px; width:100%;"> <div class='contain' style="height: 300px; width:100%;">
<canvas id='tsCycleSpeed'></canvas> <canvas id='tsCycleSpeed'></canvas>

@ -13,6 +13,9 @@ var tThreadsCan = $('#tThreads');
var tIdsCan= $('#tIds'); var tIdsCan= $('#tIds');
var tSubjectsCan = $('#tSubjects'); var tSubjectsCan = $('#tSubjects');
var tNmaesDetailedCan = $('#tNmaesDetailed');
var tsNmaesDetailedCan = $('#tsNmaesDetailed');
var tsflagCan = $('#tsPostsByFlag'); var tsflagCan = $('#tsPostsByFlag');
var tsflagPieCan = $('#tsPostsByFlagPie'); var tsflagPieCan = $('#tsPostsByFlagPie');
var tsNmaesCan = $('#tsNmaes'); var tsNmaesCan = $('#tsNmaes');
@ -47,6 +50,22 @@ function _lerpRGB(a,b,t)
}; };
} }
function addExpander(ex, ct)
{
$(ex).on("click", function() {
if($(ct).is(":hidden")) {
$(ct).slideDown(500, function() {
$(ex).text("-");
});
} else {
$(ct).slideUp(500, function() {
$(ex).text("+");
});
}
});
}
function lerpRGB(a,b,c,s,l) function lerpRGB(a,b,c,s,l)
{ {
var t = s/l; var t = s/l;
@ -177,6 +196,30 @@ function updateSection(gr, pfx, allTime, allTimeAverage,data=null)
} }
allTime.namefags["Anonymous"] = (allTime.number-(allTime.names+allTime.trips+allTime.nametrips));
var nshare = flagShare(allTime.number, allTime.namefags);
nshare.sort(function (a, b) {
return a.total < b.total ? 1 : -1;
});
gr.anamedpie.data.labels.length =
gr.anamedpie.data.datasets[0].data.length =
gr.anamedpie.data.datasets[0].backgroundColor.length = 0;
if(!$(gr.anamedpie.options.showAnon).is(":checked")) {
for(var i in nshare)
if(nshare[i]["key"] == "Anonymous")
delete nshare[i];
}
for(var i in nshare)
{
gr.anamedpie.data.labels.push(nshare[i]["key"]);
gr.anamedpie.data.datasets[0].data.push(nshare[i]["total"]);
gr.anamedpie.data.datasets[0].backgroundColor.push(colstr(lerpRGB(cols,colm,cole,i,nshare.length)));
}
gr.anamepie.data.datasets[0].data[0] = allTime.number-(allTime.names+allTime.trips+allTime.nametrips); gr.anamepie.data.datasets[0].data[0] = allTime.number-(allTime.names+allTime.trips+allTime.nametrips);
gr.anamepie.data.datasets[0].data[1] = allTime.names; gr.anamepie.data.datasets[0].data[1] = allTime.names;
@ -198,6 +241,7 @@ function updateSection(gr, pfx, allTime, allTimeAverage,data=null)
gr.aflag.update(); gr.aflag.update();
gr.aflagpie.update(); gr.aflagpie.update();
gr.anamepie.update(); gr.anamepie.update();
gr.anamedpie.update();
gr.aimagepie.update(); gr.aimagepie.update();
gr.athreadpie.update(); gr.athreadpie.update();
gr.aidspie.update(); gr.aidspie.update();
@ -395,6 +439,7 @@ function begin() {
maintainAspectRatio: false, maintainAspectRatio: false,
} }
}); });
var chartAFlagsPie = new Chart(tflagPieCan, { var chartAFlagsPie = new Chart(tflagPieCan, {
type: "pie", type: "pie",
data: { data: {
@ -415,6 +460,27 @@ function begin() {
} }
}); });
var chartANamesDetailedPie = new Chart(tNmaesDetailedCan, {
type: "pie",
data: {
labels: ["Anonymous"],
datasets: [{
label: "Share",
backgroundColor: ["blue","green","red"],
//fillColor: ["blue", "green", "red"],
borderColor: 'rgba(255,255,255, 0.75)',
data: [1]
}]
}, options: {
maintainAspectRatio: false,
animation: false,
legend: {
display: false
},
showAnon: '#at_idbd_showanon'
}
});
var chartAFlags = new Chart(tflagCan, { var chartAFlags = new Chart(tflagCan, {
type: "bar", type: "bar",
data: { data: {
@ -533,6 +599,27 @@ function begin() {
} }
}); });
var chartSNamesDetailedPie = new Chart(tsNmaesDetailedCan, {
type: "pie",
data: {
labels: ["Anonymous"],
datasets: [{
label: "Share",
backgroundColor: ["blue","green","red"],
//fillColor: ["blue", "green", "red"],
borderColor: 'rgba(255,255,255, 0.75)',
data: [1]
}]
}, options: {
maintainAspectRatio: false,
animation: false,
legend: {
display: false
},
showAnon: '#s_idbd_showanon'
}
});
var chartSFlags = new Chart(tsflagCan, { var chartSFlags = new Chart(tsflagCan, {
type: "bar", type: "bar",
data: { data: {
@ -762,6 +849,7 @@ function begin() {
aflag: chartAFlags, aflag: chartAFlags,
aflagpie: chartAFlagsPie, aflagpie: chartAFlagsPie,
anamepie: chartsANamesPie, anamepie: chartsANamesPie,
anamedpie: chartANamesDetailedPie,
aimagepie: chartAImagesPie, aimagepie: chartAImagesPie,
athreadpie: chartAthreadsPie, athreadpie: chartAthreadsPie,
aidspie: chartAIdsPie, aidspie: chartAIdsPie,
@ -774,6 +862,7 @@ function begin() {
aflag: chartSFlags, aflag: chartSFlags,
aflagpie: chartSFlagsPie, aflagpie: chartSFlagsPie,
anamepie: chartsSNamesPie, anamepie: chartsSNamesPie,
anamedpie: chartSNamesDetailedPie,
aimagepie: chartSImagesPie, aimagepie: chartSImagesPie,
athreadpie: chartSthreadsPie, athreadpie: chartSthreadsPie,
aidspie: chartSIdsPie, aidspie: chartSIdsPie,
@ -822,6 +911,9 @@ function begin() {
chartAGLine.data.datasets[1].data.push(client.superBuffer[i].number/client.superBuffer[i]._cycles); chartAGLine.data.datasets[1].data.push(client.superBuffer[i].number/client.superBuffer[i]._cycles);
} }
if(client.superBuffer[i]!==undefined)
cyTotal = client.superBuffer[i]._cycles;
/*if(client.superBuffer.length<1) /*if(client.superBuffer.length<1)
{ {
add_new_candle(g_chartsSuper(), {_candle:{number:{o:0,c:0,h:0,l:0,t:new Date()}}}, false); add_new_candle(g_chartsSuper(), {_candle:{number:{o:0,c:0,h:0,l:0,t:new Date()}}}, false);
@ -838,7 +930,7 @@ function begin() {
chartAGLine.update(); chartAGLine.update();
$('#at_flagshare_exp').on("click", function() { /*$('#at_flagshare_exp').on("click", function() {
if($('#at_flagshare_container').is(":hidden")) { if($('#at_flagshare_container').is(":hidden")) {
$('#at_flagshare_container').show(1000, function() { $('#at_flagshare_container').show(1000, function() {
@ -849,9 +941,10 @@ function begin() {
$('#at_flagshare_exp').text("+"); $('#at_flagshare_exp').text("+");
}); });
} }
}); });*/
addExpander('#at_flagshare_exp', '#at_flagshare_container');
$('#s_flagshare_exp').on("click", function() { /*$('#s_flagshare_exp').on("click", function() {
if($('#s_flagshare_container').is(":hidden")) { if($('#s_flagshare_container').is(":hidden")) {
$('#s_flagshare_container').show(1000, function() { $('#s_flagshare_container').show(1000, function() {
@ -862,7 +955,13 @@ function begin() {
$('#s_flagshare_exp').text("+"); $('#s_flagshare_exp').text("+");
}); });
} }
}); });*/
addExpander('#s_flagshare_exp', '#s_flagshare_container');
addExpander('#at_ident_bd_expand', '#at_idbd_share');
addExpander('#s_ident_bd_expand', '#s_idbd_share');
$('#cytb_purge').on("click", function() { $('#cytb_purge').on("click", function() {
$('#cytb_body').empty(); $('#cytb_body').empty();

Loading…
Cancel
Save