-
Notifications
You must be signed in to change notification settings - Fork 1
/
renderer.js
35 lines (32 loc) · 1.11 KB
/
renderer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var speed = require('./speedtest');
const wifiName = require('wifi-name');
var remote = require('electron').remote;
wifiName()
.then(name => {
return name;
})
.then((wifi_name) => {
speed.startLoop( { time: 1000 * 60, network: wifi_name, user: remote.getGlobal('user') });
speed.getResults()
.then((rows) => {
var table = document.getElementById('table_tests');
var sumDown = 0;
var sumUp = 0;
var averageDown = 0;
var averageUp = 0;
var length = 0;
document.getElementById('network_name').innerHTML = 'SSID (Network): ' + wifi_name;
var cells = "<tr><td>Date</td><td>Download</td><td>Upload</td><tr>";
for (var i in rows) {
length++;
sumDown += rows[i].result.speeds.download;
sumUp += rows[i].result.speeds.upload;
cells += "<tr><td>"+rows[i].result.date+"</td><td>"+rows[i].result.speeds.download+"</td><td>"+rows[i].result.speeds.upload+"</td><tr>";
table.innerHTML = cells;
};
averageDown = (sumDown / length).toFixed();
averageUp = (sumUp / length).toFixed();
document.getElementById('avgdown').innerHTML = averageDown;
document.getElementById('avgup').innerHTML = averageUp;
});
});