2016-08-20 11:46:22 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
|
|
|
<title>Analysis Information Leak framework Dashboard</title>
|
|
|
|
|
|
|
|
<!-- Core CSS -->
|
|
|
|
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
|
|
|
<link href="{{ url_for('static', filename='font-awesome/css/font-awesome.css') }}" rel="stylesheet">
|
|
|
|
<link href="{{ url_for('static', filename='css/sb-admin-2.css') }}" rel="stylesheet">
|
|
|
|
<link href="{{ url_for('static', filename='css/dataTables.bootstrap.css') }}" rel="stylesheet" type="text/css" />
|
|
|
|
<link href="{{ url_for('static', filename='css/jquery-ui.min.css') }}" rel="stylesheet" type="text/css" />
|
|
|
|
<script language="javascript" src="{{ url_for('static', filename='js/jquery.js')}}"></script>
|
|
|
|
<script src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
|
|
|
|
<script src="{{ url_for('static', filename='js/jquery.dataTables.min.js') }}"></script>
|
|
|
|
<script src="{{ url_for('static', filename='js/dataTables.bootstrap.js') }}"></script>
|
|
|
|
<script src="{{ url_for('static', filename='js/jquery.flot.js') }}"></script>
|
|
|
|
<script src="{{ url_for('static', filename='js/jquery.flot.time.js') }}"></script>
|
|
|
|
<script src="{{ url_for('static', filename='js/jquery.flot.stack.js') }}"></script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
.sparkLineStats ul {
|
|
|
|
padding-left:0;
|
|
|
|
list-style:none
|
|
|
|
}
|
2016-08-23 14:52:02 +02:00
|
|
|
.table > tbody > tr > td {
|
|
|
|
padding: 5px;
|
|
|
|
}
|
2016-08-20 11:46:22 +02:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div id="wrapper">
|
|
|
|
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
|
|
|
|
{% include 'header.html' %}
|
|
|
|
<!-- /.navbar-top-links -->
|
|
|
|
<div class="navbar-default sidebar" role="navigation">
|
|
|
|
<div class="sidebar-collapse">
|
|
|
|
<ul class="nav" id="side-menu">
|
|
|
|
<li class="sidebar-search">
|
|
|
|
{% include 'searchbox.html' %}
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<!-- /#side-menu -->
|
|
|
|
</div>
|
|
|
|
<!-- /.sidebar-collapse -->
|
|
|
|
<a href="{{ url_for('index') }}"><img src="{{ url_for('static', filename='image/AIL.png') }}" /></a>
|
|
|
|
</div>
|
|
|
|
<!-- /.navbar-static-side -->
|
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="page-wrapper">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<h1 class="page-header" data-page="page-termsfrequency" >Terms frequency: Top set information</h1>
|
|
|
|
</div>
|
|
|
|
<!-- /.col-lg-12 -->
|
|
|
|
</div>
|
|
|
|
<!-- /.row -->
|
|
|
|
<div class="row">
|
|
|
|
|
|
|
|
<!-- Panel OPTIONS -->
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<div id="panel-today" class="panel panel-info">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Today</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div id="panel-today" class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Today top word</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<table class="table table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Term</th>
|
|
|
|
<th>Value</th>
|
|
|
|
<th>Action</th>
|
2016-08-23 14:52:02 +02:00
|
|
|
<th>Show</th>
|
|
|
|
<th data-toggle="tooltip" data-placement="left" title="Position of the term in the week and month set">Position</th>
|
2016-08-20 11:46:22 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="table-today">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<table class="table table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Term</th>
|
|
|
|
<th>Value</th>
|
|
|
|
<th>Action</th>
|
2016-08-23 14:52:02 +02:00
|
|
|
<th>Show</th>
|
|
|
|
<th data-toggle="tooltip" data-placement="left" title="Position of the term in the week and month set">Position</th>
|
2016-08-20 11:46:22 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="table-today2">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
<div id="panel-today" class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Graph</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div id="graph-today" style="height: 400px;"></div>
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.panel -->
|
|
|
|
</div>
|
|
|
|
<!-- /.panel -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Panel OPTIONS -->
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<div id="panel-today" class="panel panel-info">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Week</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div id="panel-week" class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Week top word</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<table class="table table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Term</th>
|
|
|
|
<th>Value</th>
|
|
|
|
<th>Action</th>
|
2016-08-23 14:52:02 +02:00
|
|
|
<th>Show</th>
|
|
|
|
<th data-toggle="tooltip" data-placement="left" title="Position of the term in the day and month set">Position</th>
|
2016-08-20 11:46:22 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="table-week">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<table class="table table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Term</th>
|
|
|
|
<th>Value</th>
|
|
|
|
<th>Action</th>
|
2016-08-23 14:52:02 +02:00
|
|
|
<th>Show</th>
|
|
|
|
<th data-toggle="tooltip" data-placement="left" title="Position of the term in the day and month set">Position</th>
|
2016-08-20 11:46:22 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="table-week2">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
<div id="panel-week" class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Graph</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div id="graph-week" style="height: 400px;"></div>
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.panel -->
|
|
|
|
</div>
|
|
|
|
<!-- /.panel -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- Panel OPTIONS -->
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-lg-12">
|
|
|
|
<div id="panel-today" class="panel panel-info">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Month</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div id="panel-month" class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Month top word</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<table class="table table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Term</th>
|
|
|
|
<th>Value</th>
|
|
|
|
<th>Action</th>
|
2016-08-23 14:52:02 +02:00
|
|
|
<th>Show</th>
|
|
|
|
<th data-toggle="tooltip" data-placement="left" title="Position of the term in the day and week set">Position</th>
|
2016-08-20 11:46:22 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="table-month">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div class="col-lg-6">
|
|
|
|
<table class="table table-striped">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Term</th>
|
|
|
|
<th>Value</th>
|
|
|
|
<th>Action</th>
|
2016-08-23 14:52:02 +02:00
|
|
|
<th>Show</th>
|
|
|
|
<th data-toggle="tooltip" data-placement="left" title="Position of the term in the day and week set">Position</th>
|
2016-08-20 11:46:22 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody id="table-month2">
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
<div id="panel-month" class="panel panel-default">
|
|
|
|
<div class="panel-heading">
|
|
|
|
<strong>Graph</strong>
|
|
|
|
</div>
|
|
|
|
<div class="panel-body">
|
|
|
|
<div id="graph-month" style="height: 400px;"></div>
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<!-- /.panel-body -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- /.panel -->
|
|
|
|
</div>
|
|
|
|
<!-- /.panel -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- /.row -->
|
|
|
|
</div>
|
|
|
|
<!-- /#page-wrapper -->
|
|
|
|
</div>
|
|
|
|
|
2016-08-22 13:35:49 +02:00
|
|
|
<div style="position: absolute; border: 1px solid rgb(255, 221, 221); padding: 2px; background-color: #333; color:white; opacity: 0.8; top: 423px; left: 616px; display: none;" id="tooltip"></div>
|
2016-08-20 11:46:22 +02:00
|
|
|
|
|
|
|
<!-- import graph function -->
|
|
|
|
<script>
|
|
|
|
$(document).ready(function(){
|
|
|
|
activePage = $('h1.page-header').attr('data-page');
|
|
|
|
$("#"+activePage).addClass("active");
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var graph_options = {
|
|
|
|
series: {
|
2016-08-23 15:39:13 +02:00
|
|
|
lines: {
|
2016-08-20 11:46:22 +02:00
|
|
|
show: true,
|
|
|
|
lineWidth: 2
|
|
|
|
},
|
|
|
|
bars: {show: false, barWidth: 60*60*1000},
|
|
|
|
shadowSize: 0
|
|
|
|
},
|
2016-08-23 15:39:13 +02:00
|
|
|
grid: {
|
|
|
|
hoverable: true,
|
|
|
|
clickable: true,
|
2016-08-20 11:46:22 +02:00
|
|
|
tickColor: "#f9f9f9",
|
|
|
|
borderWidth: 0
|
|
|
|
},
|
2016-08-23 10:16:33 +02:00
|
|
|
legend: { show: true,
|
2016-08-23 12:03:23 +02:00
|
|
|
noColumns: 1,
|
2016-08-23 15:39:13 +02:00
|
|
|
position: "nw",
|
|
|
|
labelFormatter: function(label, series) {
|
|
|
|
return "<a href=\"#\" onClick=\"hide_or_show2("+series.idx+", "+series.graphNum+"); return false;\" >" + label + "</a>";
|
|
|
|
}
|
2016-08-23 10:16:33 +02:00
|
|
|
},
|
2016-08-20 11:46:22 +02:00
|
|
|
xaxis: {
|
|
|
|
mode: "time",
|
|
|
|
timeformat: "%m/%d",
|
|
|
|
minTickSize: [1, "day"]
|
|
|
|
},
|
|
|
|
yaxis: {
|
2016-08-23 10:16:33 +02:00
|
|
|
//transform: function (v) { return v < 1 ? v : Math.log(v); }
|
2016-08-20 11:46:22 +02:00
|
|
|
autoscaleMargin: 0.1,
|
|
|
|
},
|
2016-08-22 13:35:49 +02:00
|
|
|
tooltip: true,
|
|
|
|
tooltipOpts: {
|
2016-08-23 10:16:33 +02:00
|
|
|
content: " %s (%x.1 is %y.4) ",
|
2016-08-22 13:35:49 +02:00
|
|
|
shifts: {
|
|
|
|
x: -60,
|
|
|
|
y: 25
|
|
|
|
}
|
|
|
|
}
|
2016-08-20 11:46:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
set_today = "TopTermFreq_set_day";
|
|
|
|
set_week = "TopTermFreq_set_week";
|
|
|
|
set_month = "TopTermFreq_set_month";
|
2016-08-23 11:02:36 +02:00
|
|
|
default_num_curves = 8;
|
2016-08-20 11:46:22 +02:00
|
|
|
|
2016-08-20 15:59:22 +02:00
|
|
|
var plot_today;
|
|
|
|
var plot_week;
|
|
|
|
var plot_month;
|
|
|
|
|
2016-08-20 11:46:22 +02:00
|
|
|
var promises = []; // Used to know when everything has been received
|
|
|
|
|
2016-08-22 13:35:49 +02:00
|
|
|
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_today, num_day: 5 }, function(data, status){
|
2016-08-20 11:46:22 +02:00
|
|
|
data.sort(function(a, b){return b[2]-a[2];});
|
|
|
|
// Sort data
|
|
|
|
var table_today = $("#table-today")
|
|
|
|
var table_today2 = $("#table-today2")
|
|
|
|
var to_plot = [];
|
2016-08-23 11:02:36 +02:00
|
|
|
var unchecked_label = [];
|
2016-08-20 11:46:22 +02:00
|
|
|
for(i=0; i<data.length; i++) {
|
2016-08-23 14:52:02 +02:00
|
|
|
var highlight = data[i][3].week == "<20"? " style=\"background-color: lightgreen;\" " : "";
|
2016-08-20 11:46:22 +02:00
|
|
|
var curr_data = [];
|
|
|
|
for(j=0; j<data[i][1].length; j++) {
|
|
|
|
curr_data.push([data[i][1][j][0]*1000, data[i][1][j][1]]);
|
|
|
|
}
|
2016-08-23 11:02:36 +02:00
|
|
|
if (i>=default_num_curves) {
|
|
|
|
unchecked_label.push(data[i][0]);
|
|
|
|
}
|
2016-08-23 15:39:13 +02:00
|
|
|
to_plot.push({ data: curr_data, label: data[i][0], idx: i});
|
2016-08-20 11:46:22 +02:00
|
|
|
if ( i < (data.length/2))
|
2016-08-23 14:52:02 +02:00
|
|
|
table_today.append("<tr"+highlight+"><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("today", data[i][0], i<default_num_curves)+"</td><td>"+data[i][3].week+", "+data[i][3].month+"</td></tr>");
|
2016-08-20 11:46:22 +02:00
|
|
|
else
|
2016-08-23 14:52:02 +02:00
|
|
|
table_today2.append("<tr"+highlight+"><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("today", data[i][0], i<default_num_curves)+"</td><td>"+data[i][3].week+", "+data[i][3].month+"</td></tr>");
|
2016-08-20 11:46:22 +02:00
|
|
|
}
|
2016-08-23 15:39:13 +02:00
|
|
|
graph_options.series.graphNum=1;
|
2016-08-20 15:59:22 +02:00
|
|
|
plot_today = $.plot($("#graph-today"), to_plot, graph_options);
|
2016-08-23 11:02:36 +02:00
|
|
|
hide_unchecked_curves(plot_today, unchecked_label);
|
2016-08-22 13:35:49 +02:00
|
|
|
$("#graph-today").bind("plothover", function (event, pos, item) {
|
|
|
|
if (item) {
|
|
|
|
var date = new Date(item.datapoint[0]);
|
|
|
|
var x = parseInt(date.getUTCMonth())+1 + "/" + date.getUTCDate();
|
|
|
|
var y = item.datapoint[1];
|
|
|
|
|
|
|
|
$("#tooltip").html(item.series.label + " for "+x + " = " + y)
|
|
|
|
.css({top: item.pageY+5, left: item.pageX+5})
|
|
|
|
.fadeIn(200);
|
|
|
|
} else {
|
|
|
|
$("#tooltip").hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-08-20 11:46:22 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_week, num_day: 7 }, function(data, status){
|
|
|
|
data.sort(function(a, b){return b[2]-a[2];});
|
|
|
|
// Sort data
|
|
|
|
var table = $("#table-week")
|
|
|
|
var table2 = $("#table-week2")
|
|
|
|
var to_plot = [];
|
2016-08-23 11:02:36 +02:00
|
|
|
var unchecked_label = [];
|
2016-08-20 11:46:22 +02:00
|
|
|
for(i=0; i<data.length; i++) {
|
2016-08-23 14:52:02 +02:00
|
|
|
var highlight = parseInt(data[i][3].day) > 20? " style=\"background-color: orange;\" " : "";
|
2016-08-20 11:46:22 +02:00
|
|
|
var curr_data = [];
|
|
|
|
for(j=0; j<data[i][1].length; j++) {
|
|
|
|
curr_data.push([data[i][1][j][0]*1000, data[i][1][j][1]]);
|
|
|
|
}
|
2016-08-23 11:02:36 +02:00
|
|
|
if (i>=default_num_curves) {
|
|
|
|
unchecked_label.push(data[i][0]);
|
|
|
|
}
|
2016-08-23 15:39:13 +02:00
|
|
|
to_plot.push({ data: curr_data, label: data[i][0], idx: i});
|
2016-08-20 11:46:22 +02:00
|
|
|
if ( i < (data.length/2))
|
2016-08-23 14:52:02 +02:00
|
|
|
table.append("<tr"+highlight+"><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("week", data[i][0], i<default_num_curves)+"</td><td><strong>"+data[i][3].day+"</strong>, "+data[i][3].month+"</td></tr>");
|
2016-08-20 11:46:22 +02:00
|
|
|
else
|
2016-08-23 14:52:02 +02:00
|
|
|
table2.append("<tr"+highlight+"><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("week", data[i][0], i<default_num_curves)+"</td><td><strong>"+data[i][3].day+"</strong>, "+data[i][3].month+"</td></tr>");
|
2016-08-20 11:46:22 +02:00
|
|
|
}
|
2016-08-23 15:39:13 +02:00
|
|
|
graph_options.series.graphNum=2;
|
2016-08-20 15:59:22 +02:00
|
|
|
plot_week = $.plot($("#graph-week"), to_plot, graph_options);
|
2016-08-23 11:02:36 +02:00
|
|
|
hide_unchecked_curves(plot_week, unchecked_label);
|
2016-08-22 13:35:49 +02:00
|
|
|
$("#graph-week").bind("plothover", function (event, pos, item) {
|
|
|
|
if (item) {
|
|
|
|
var date = new Date(item.datapoint[0]);
|
|
|
|
var x = parseInt(date.getUTCMonth())+1 + "/" + date.getUTCDate();
|
|
|
|
var y = item.datapoint[1];
|
|
|
|
|
|
|
|
$("#tooltip").html(item.series.label + " for "+x + " = " + y)
|
|
|
|
.css({top: item.pageY+5, left: item.pageX+5})
|
|
|
|
.fadeIn(200);
|
|
|
|
} else {
|
|
|
|
$("#tooltip").hide();
|
|
|
|
}
|
|
|
|
});
|
2016-08-20 11:46:22 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
promises.push($.getJSON("{{ url_for('terms_plot_top_data') }}", { set: set_month, num_day: 31 }, function(data, status){
|
|
|
|
data.sort(function(a, b){return b[2]-a[2];});
|
|
|
|
// Sort data
|
|
|
|
var table = $("#table-month")
|
|
|
|
var table2 = $("#table-month2")
|
|
|
|
var to_plot = [];
|
2016-08-23 11:02:36 +02:00
|
|
|
var unchecked_label = [];
|
2016-08-20 11:46:22 +02:00
|
|
|
for(i=0; i<data.length; i++) {
|
2016-08-23 14:52:02 +02:00
|
|
|
var highlight = parseInt(data[i][3].day) > 20? " style=\"background-color: orange;\" " : "";
|
2016-08-20 11:46:22 +02:00
|
|
|
var curr_data = [];
|
|
|
|
for(j=0; j<data[i][1].length; j++) {
|
|
|
|
curr_data.push([data[i][1][j][0]*1000, data[i][1][j][1]]);
|
|
|
|
}
|
2016-08-23 11:02:36 +02:00
|
|
|
if (i>=default_num_curves) {
|
|
|
|
unchecked_label.push(data[i][0]);
|
|
|
|
}
|
2016-08-23 15:39:13 +02:00
|
|
|
to_plot.push({ data: curr_data, label: data[i][0], idx: i});
|
2016-08-20 11:46:22 +02:00
|
|
|
if ( i < (data.length/2))
|
2016-08-23 14:52:02 +02:00
|
|
|
table.append("<tr"+highlight+"><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("month", data[i][0], i<default_num_curves)+"</td><td><strong>"+data[i][3].day+"</strong>, "+data[i][3].week+"</td></tr>");
|
2016-08-20 11:46:22 +02:00
|
|
|
else
|
2016-08-23 14:52:02 +02:00
|
|
|
table2.append("<tr"+highlight+"><td>"+data[i][0]+"</td><td>"+data[i][2]+"</td><td>"+addbuttons(data[i][0])+"</td><td>"+addcheckbox("month", data[i][0], i<default_num_curves)+"</td><td><strong>"+data[i][3].day+"</strong>, "+data[i][3].week+"</td></tr>");
|
2016-08-20 11:46:22 +02:00
|
|
|
}
|
2016-08-23 15:39:13 +02:00
|
|
|
graph_options.series.graphNum=3;
|
2016-08-20 15:59:22 +02:00
|
|
|
plot_month = $.plot($("#graph-month"), to_plot, graph_options);
|
2016-08-23 11:02:36 +02:00
|
|
|
hide_unchecked_curves(plot_month, unchecked_label);
|
2016-08-22 13:35:49 +02:00
|
|
|
$("#graph-month").bind("plothover", function (event, pos, item) {
|
|
|
|
if (item) {
|
|
|
|
var date = new Date(item.datapoint[0]);
|
|
|
|
var x = parseInt(date.getUTCMonth())+1 + "/" + date.getUTCDate();
|
|
|
|
var y = item.datapoint[1];
|
|
|
|
|
|
|
|
$("#tooltip").html(item.series.label + " for "+x + " = " + y)
|
|
|
|
.css({top: item.pageY+5, left: item.pageX+5})
|
|
|
|
.fadeIn(200);
|
|
|
|
} else {
|
|
|
|
$("#tooltip").hide();
|
|
|
|
}
|
|
|
|
});
|
2016-08-20 11:46:22 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
/* When everything has been received, start adding tooltip */
|
|
|
|
$.when.apply($, promises).done( function (arg) {
|
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
|
|
|
|
|
|
$(".btn-interaction").unbind("click.interaction");
|
|
|
|
$(".btn-interaction").bind("click.interaction", perform_operation);
|
|
|
|
$(".check-interaction").unbind("click.interaction");
|
|
|
|
$(".check-interaction").bind("click.interaction", hide_or_show);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
function addbuttons(term) {
|
2016-08-20 15:59:22 +02:00
|
|
|
return "<button class=\"fa fa-eye btn-interaction btn btn-success\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Add to tracked list\" style=\"margin-right: 5px;\""+
|
2016-08-20 11:46:22 +02:00
|
|
|
"data-section=\"followTerm\" data-term=\""+term+"\"></button>"+
|
2016-08-20 15:59:22 +02:00
|
|
|
"<button class=\"fa fa-eye-slash btn-interaction btn btn-danger\" data-toggle=\"tooltip\" data-placement=\"right\" title=\"Add to black-list\""+
|
2016-08-20 11:46:22 +02:00
|
|
|
"data-section=\"blacklistTerm\" data-term=\""+term+"\"></button>";
|
|
|
|
}
|
|
|
|
|
2016-08-23 11:02:36 +02:00
|
|
|
function addcheckbox(graph, term, checked) {
|
|
|
|
var checked_text = checked ? "checked" : "";
|
|
|
|
return "<input type=checkbox "+checked_text+" class=\"check-interaction\" data-term=\""+term+"\" data-graph=\""+graph+"\"></input>";
|
2016-08-20 11:46:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function perform_operation(){
|
|
|
|
var curr_section = $(this).attr('data-section');
|
|
|
|
var curr_term = $(this).attr('data-term');
|
|
|
|
|
|
|
|
var data_to_send = { section: curr_section, action:"add", term: curr_term};
|
|
|
|
|
|
|
|
$.get("{{ url_for('terms_management_action') }}", data_to_send, function(data, status){
|
|
|
|
if(status == "success") {
|
|
|
|
location.reload();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-08-23 11:02:36 +02:00
|
|
|
|
|
|
|
function hide_unchecked_curves(plot, unchecked_label) {
|
|
|
|
var graphData = plot.getData();
|
|
|
|
var index;
|
|
|
|
for(i=0; i<graphData.length; i++) {
|
|
|
|
if($.inArray( graphData[i].label, unchecked_label ) != -1){
|
|
|
|
graphData[i].lines.show = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
plot.setData(graphData);
|
|
|
|
plot.draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-20 11:46:22 +02:00
|
|
|
function hide_or_show() {
|
|
|
|
var curr_term = $(this).attr('data-term');
|
|
|
|
var graph = $(this).attr('data-graph');
|
|
|
|
var checked = $(this).prop('checked')
|
2016-08-23 15:39:13 +02:00
|
|
|
|
2016-08-20 15:59:22 +02:00
|
|
|
if(graph == "today") {
|
|
|
|
var graphData = plot_today.getData();
|
|
|
|
var index;
|
|
|
|
for(i=0; i<graphData.length; i++){
|
|
|
|
if(graphData[i].label == curr_term){
|
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
graphData[index].lines.show = checked;
|
|
|
|
plot_today.setData(graphData);
|
|
|
|
plot_today.draw();
|
|
|
|
} else if (graph == "week") {
|
|
|
|
var graphData = plot_week.getData();
|
|
|
|
var index;
|
|
|
|
for(i=0; i<graphData.length; i++){
|
|
|
|
if(graphData[i].label == curr_term){
|
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
graphData[index].lines.show = checked;
|
|
|
|
plot_week.setData(graphData);
|
|
|
|
plot_week.draw();
|
|
|
|
} else if (graph == "month") {
|
|
|
|
var graphData = plot_month.getData();
|
|
|
|
var index;
|
|
|
|
for(i=0; i<graphData.length; i++){
|
|
|
|
if(graphData[i].label == curr_term){
|
|
|
|
index = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
graphData[index].lines.show = checked;
|
|
|
|
plot_month.setData(graphData);
|
|
|
|
plot_month.draw();
|
|
|
|
}
|
2016-08-20 11:46:22 +02:00
|
|
|
|
|
|
|
// graph, hide curve
|
|
|
|
}
|
|
|
|
|
2016-08-23 15:39:13 +02:00
|
|
|
function hide_or_show2(index, graphNum) {
|
|
|
|
if (graphNum == 1)
|
|
|
|
var plot = plot_today;
|
|
|
|
else if (graphNum == 2)
|
|
|
|
var plot = plot_week;
|
|
|
|
else if (graphNum == 3)
|
|
|
|
var plot = plot_month;
|
|
|
|
|
|
|
|
var graphData = plot.getData();
|
|
|
|
graphData[index].lines.show = !graphData[index].lines.show;
|
|
|
|
plot.setData(graphData);
|
|
|
|
plot.draw();
|
|
|
|
}
|
2016-08-20 11:46:22 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|