2018-12-26 21:32:39 +00:00
|
|
|
|
const IPV4_EX = new RegExp("")
|
2018-12-26 22:59:40 +00:00
|
|
|
|
const regex = RegExp(/^((([0–9A-Fa-f]{1,4}:){7}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){6}:[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){5}:([0–9A-Fa-f]{1,4}:)?[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){4}:([0–9A-Fa-f]{1,4}:){0,2}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){3}:([0–9A-Fa-f]{1,4}:){0,3}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){2}:([0–9A-Fa-f]{1,4}:){0,4}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){6}((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|(([0–9A-Fa-f]{1,4}:){0,5}:((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|(::([0–9A-Fa-f]{1,4}:){0,5}((b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b).){3}(b((25[0–5])|(1d{2})|(2[0–4]d)|(d{1,2}))b))|([0–9A-Fa-f]{1,4}::([0–9A-Fa-f]{1,4}:){0,5}[0–9A-Fa-f]{1,4})|(::([0–9A-Fa-f]{1,4}:){0,6}[0–9A-Fa-f]{1,4})|(([0–9A-Fa-f]{1,4}:){1,7}:))$/)
|
2018-12-26 12:29:13 +00:00
|
|
|
|
|
2018-12-26 21:32:39 +00:00
|
|
|
|
var addresses = []
|
|
|
|
|
var date = []
|
|
|
|
|
var ipv4_v6 = []
|
|
|
|
|
|
2019-01-01 14:16:42 +00:00
|
|
|
|
//colors object for different graphs
|
|
|
|
|
var chartColors = {
|
|
|
|
|
red: 'rgb(255, 99, 132)',
|
|
|
|
|
orange: 'rgb(255, 159, 64)',
|
|
|
|
|
yellow: 'rgb(255, 205, 86)',
|
|
|
|
|
green: 'rgb(75, 192, 192)',
|
|
|
|
|
blue: 'rgb(54, 162, 235)',
|
|
|
|
|
purple: 'rgb(153, 102, 255)',
|
|
|
|
|
grey: 'rgb(231,233,237)'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//test function for ip addresses
|
2018-12-26 21:32:39 +00:00
|
|
|
|
function Ip4OrIp6(ipAddress){
|
2018-12-28 13:23:03 +00:00
|
|
|
|
if(ipAddress.length == 39){
|
|
|
|
|
ipv4_v6.push(1);
|
|
|
|
|
}else{
|
|
|
|
|
ipv4_v6.push(-1);
|
|
|
|
|
}
|
2018-12-26 21:32:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-12-28 13:23:03 +00:00
|
|
|
|
|
2018-12-26 21:32:39 +00:00
|
|
|
|
// Refactor getStudents and getScores to return Promise for their response bodies
|
|
|
|
|
function getData(){
|
|
|
|
|
return fetch(`address.json`, {
|
|
|
|
|
headers: {
|
|
|
|
|
'Content-Type': 'application/json',
|
2018-12-28 13:23:03 +00:00
|
|
|
|
'Accept': 'application/json',
|
2018-12-26 21:32:39 +00:00
|
|
|
|
}
|
|
|
|
|
}).then((response) => response.json())
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
getData().then((data)=>{
|
2018-12-26 12:29:13 +00:00
|
|
|
|
data.forEach(element => {
|
2019-01-01 14:16:42 +00:00
|
|
|
|
date.push(element.date);
|
|
|
|
|
// Ip4OrIp6(element.ip);
|
|
|
|
|
// });
|
2018-12-28 13:23:03 +00:00
|
|
|
|
|
2019-01-01 14:16:42 +00:00
|
|
|
|
// console.log(date);
|
|
|
|
|
// console.log(ipv4_v6);
|
2018-12-26 21:32:39 +00:00
|
|
|
|
|
2018-12-31 14:40:15 +00:00
|
|
|
|
date.sort((a, b)=>{
|
2018-12-31 14:42:06 +00:00
|
|
|
|
return new Date(a) - new Date(b)
|
2018-12-31 14:40:15 +00:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
2019-01-01 14:16:42 +00:00
|
|
|
|
|
2018-12-26 21:32:39 +00:00
|
|
|
|
var ctx = document.getElementById("myChart").getContext('2d');
|
|
|
|
|
var chart = new Chart(ctx, {
|
2019-01-01 14:16:42 +00:00
|
|
|
|
type: 'line',
|
2018-12-26 21:32:39 +00:00
|
|
|
|
data: {
|
|
|
|
|
labels:date ,
|
2019-01-01 14:16:42 +00:00
|
|
|
|
datasets: [
|
|
|
|
|
{
|
|
|
|
|
label: "My First dataset",
|
|
|
|
|
backgroundColor: chartColors.red,
|
|
|
|
|
borderColor: chartColors.red,
|
|
|
|
|
data: [
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor()
|
|
|
|
|
],
|
|
|
|
|
fill: false,
|
|
|
|
|
}, {
|
|
|
|
|
label: "My Second dataset",
|
|
|
|
|
fill: false,
|
|
|
|
|
backgroundColor: chartColors.blue,
|
|
|
|
|
borderColor: chartColors.blue,
|
|
|
|
|
data: [
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor(),
|
|
|
|
|
randomScalingFactor()
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
]
|
2018-12-26 21:32:39 +00:00
|
|
|
|
},
|
|
|
|
|
options: {
|
|
|
|
|
legend: { display: false },
|
|
|
|
|
title: {
|
|
|
|
|
display: true,
|
|
|
|
|
text: 'Statistics for IPV4 and IPV6'
|
2019-01-01 14:16:42 +00:00
|
|
|
|
},
|
|
|
|
|
scales: {
|
|
|
|
|
xAxes: [{
|
|
|
|
|
display: true,
|
|
|
|
|
gridLines: {
|
|
|
|
|
display: false ,
|
|
|
|
|
color: "blue"
|
|
|
|
|
},
|
|
|
|
|
scaleLabel: {
|
|
|
|
|
display: true,
|
|
|
|
|
labelString: 'Time',
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}],
|
|
|
|
|
yAxes: [{
|
|
|
|
|
display: true,
|
|
|
|
|
gridLines: {
|
|
|
|
|
display: false ,
|
|
|
|
|
color: "blue"
|
|
|
|
|
},
|
|
|
|
|
scaleLabel: {
|
|
|
|
|
display: true,
|
|
|
|
|
labelString: 'Ipv4 or Ipv6',
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}]
|
|
|
|
|
}
|
|
|
|
|
} }
|
|
|
|
|
)});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-12-26 21:32:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|