-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_task.js
More file actions
32 lines (26 loc) · 963 Bytes
/
Copy pathsave_task.js
File metadata and controls
32 lines (26 loc) · 963 Bytes
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
var table = document.getElementsByTagName('tbody')[1];
var rows = table.getElementsByTagName('tr');
console.log(rows);
var fullLength = rows[0].children.length;
var indexOfTimeSpent = fullLength - 3;
var output = '\
<html>\
<head>\
<meta charset="utf-8">\
<title>Отчет</title>\
</head>\
<body>\
<table>';
var hoursTotal = 0;
for (var i = 0; i < rows.length; i++) {
if (rows[i].children.length < fullLength) continue;
var fullTaskText = rows[i].children[3].innerText;
var taskName = fullTaskText.substr(0,fullTaskText.indexOf(' '));
var taskDesc =fullTaskText.substr(fullTaskText.indexOf(' ')+1);
var timeSpent = rows[i].children[indexOfTimeSpent].innerText;
hoursTotal += parseFloat(timeSpent);
output += '<tr><td>' + taskName + '</td><td>' + taskDesc + '</td><td>' + timeSpent + '</td></tr>';
}
output += '<tr><td colspan="2">Всего</td><td>'+ hoursTotal +'h</td></tr>';
output += '</table></body></html>';
console.log(output);