Skip to content

Commit 0851d08

Browse files
committed
add total time
1 parent 0326a28 commit 0851d08

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

index.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
11
<!DOCTYPE html>
22
<html>
3+
34
<head>
4-
<meta charset="utf-8">
5+
<meta charset="utf-8">
56
<title>WebActivity Time Tracker</title>
6-
<link href="style/webact.css" rel="stylesheet"/>
7+
<link href="style/webact.css" rel="stylesheet" />
78
<script src="scripts/storage.js"></script>
89
<script src="scripts/common.js"></script>
910
<script src="scripts/webact.js"></script>
1011
</head>
12+
1113
<body>
12-
<div id="resultTable">
14+
<hr>
15+
<div id="resultTable"></div>
16+
<hr>
17+
<div class="inline-flex">
18+
<span class="span-total">Total</span>
19+
<span class="span-time" id="totalTime"></span>
1320
</div>
1421
</body>
22+
1523
</html>

scripts/webact.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function getDataFromStorage() {
1111
function getTabsFromStorage(tabs) {
1212
var table = document.getElementById('resultTable');
1313
table.innerHTML = null;
14-
tabs = tabs.sort(function(a, b){
14+
tabs = tabs.sort(function (a, b) {
1515
return b.summaryTime - a.summaryTime;
1616
});
1717
for (var i = 0; i < tabs.length; i++) {
@@ -36,4 +36,12 @@ function getTabsFromStorage(tabs) {
3636
div.appendChild(spanTime);
3737
table.appendChild(div);
3838
}
39+
40+
setTotalTime(tabs);
41+
}
42+
43+
function setTotalTime(tabs) {
44+
var summaryTimeList = tabs.map(function (a) { return a.summaryTime; });
45+
var total = summaryTimeList.reduce(function (a, b) { return a + b; })
46+
document.getElementById('totalTime').innerText = convertSummaryTimeToString(total);
3947
}

style/webact.css

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,27 @@ body {
1919
color: rgb(107, 107, 107);
2020
}
2121

22+
.span-total{
23+
width: 220px;
24+
text-decoration: none;
25+
color: rgb(0, 0, 0);
26+
font-size: 12px;
27+
font-weight: 600;
28+
cursor: pointer;
29+
}
30+
2231
.span-time{
2332
margin-left: 10px;
2433
width: 70px;
34+
font-weight: 500;
2535
}
2636

2737
.favicon{
2838
margin-right:5px;
29-
}
39+
}
40+
41+
hr {
42+
border: none;
43+
background-color: rgb(187, 187, 187);
44+
height: 2px;
45+
}

0 commit comments

Comments
 (0)