Skip to content

Commit e4d16ec

Browse files
committed
Add feature of visits
1 parent da7cb81 commit e4d16ec

File tree

5 files changed

+43
-9
lines changed

5 files changed

+43
-9
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"name": "Web Activity Time Tracker",
55
"short_name": "Web Activity",
6-
"version": "0.8.1",
6+
"version": "0.8.2",
77
"minimum_chrome_version": "26",
88

99
"description": "Track your activity in the browser.",

scripts/chart/chart-core.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ function donutChart() {
144144
var value = (!isNaN(parseFloat(data.data[key]))) ? percentFormat(data.data[key]) : data.data[key];
145145
if (key === 'summary')
146146
value = convertSummaryTimeToString(data.data[key]);
147+
if (key === 'visits' && data.data[key] !== undefined)
148+
value = data.data[key] + ' visits';
147149
var className = '';
148150
if (key === 'percentage')
149151
className = 'class="percentageValue"';

scripts/ui.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ class UI {
118118
var div = document.createElement('div');
119119
div.classList.add('inline-flex');
120120

121+
if (tab.url == currentTab) {
122+
div.classList.add('span-active-url');
123+
}
124+
121125
var divForImg = document.createElement('div');
122126
var img = document.createElement('img');
123127
img.setAttribute('height', 17);
@@ -130,9 +134,6 @@ class UI {
130134
var spanUrl = document.createElement('span');
131135
spanUrl.classList.add('span-url');
132136
spanUrl.innerText = tab.url;
133-
if (tab.url == currentTab) {
134-
spanUrl.classList.add('span-active-url');
135-
}
136137

137138
if (typeOfList !== undefined && typeOfList === TypeListEnum.ToDay) {
138139
if (restrictionList !== undefined && restrictionList.length > 0) {
@@ -154,6 +155,16 @@ class UI {
154155
}
155156
}
156157

158+
var spanVisits = document.createElement('span');
159+
spanVisits.classList.add('span-visits', 'tooltip', 'visits');
160+
spanVisits.innerText = tab.counter !== undefined ? tab.counter : 0;
161+
162+
var visitsTooltip = document.createElement('span');
163+
visitsTooltip.classList.add('tooltiptext');
164+
visitsTooltip.innerText = 'Count of visits';
165+
166+
spanVisits.appendChild(visitsTooltip);
167+
157168
var spanPercentage = document.createElement('span');
158169
spanPercentage.classList.add('span-percentage');
159170
spanPercentage.innerText = getPercentage(summaryTime);
@@ -164,6 +175,7 @@ class UI {
164175

165176
div.appendChild(divForImg);
166177
div.appendChild(spanUrl);
178+
div.appendChild(spanVisits);
167179
div.appendChild(spanPercentage);
168180
div.appendChild(spanTime);
169181
if (blockName !== undefined)

scripts/webact.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function getTabsFromStorage(tabs) {
124124
ui.addLineToTableOfSite(targetTabs[i], currentTab, summaryTime, currentTypeOfList);
125125

126126
if (i <= 8)
127-
addTabForChart(tabsForChart, targetTabs[i].url, summaryTime);
127+
addTabForChart(tabsForChart, targetTabs[i].url, summaryTime, targetTabs[i].counter);
128128
else addTabOthersForChart(tabsForChart, summaryTime);
129129
}
130130

@@ -166,12 +166,13 @@ function getCurrentTab() {
166166
return chrome.extension.getBackgroundPage().currentTab;
167167
}
168168

169-
function addTabForChart(tabsForChart, url, time) {
169+
function addTabForChart(tabsForChart, url, time, counter) {
170170
tabsForChart.push(
171171
{
172172
'url': url,
173173
'percentage': getPercentageForChart(time),
174-
'summary': time
174+
'summary': time,
175+
'visits': counter
175176
}
176177
);
177178
}

style/webact.css

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ body {
1818
}
1919

2020
.span-url{
21-
width: 312px;
21+
width: 282px;
2222
text-decoration: none;
2323
color: rgb(0, 0, 0);
2424
font-size: 13px;
2525
cursor: pointer;
2626
}
2727

2828
.span-active-url{
29-
font-weight: 700;
29+
font-size: 13px;
30+
font-weight: 650;
3031
}
3132

3233
.span-total{
@@ -39,6 +40,19 @@ body {
3940
cursor: pointer;
4041
}
4142

43+
.span-visits{
44+
width: 30px;
45+
/* padding: 0 10px 0 10px; */
46+
color: rgb(137, 154, 190);
47+
font-size: 11px;
48+
}
49+
50+
.visits{
51+
text-decoration: underline;
52+
text-decoration-style: solid;
53+
/* border-bottom: 1px dotted #ccc; */
54+
}
55+
4256
.span-percentage{
4357
width: 70px;
4458
color: rgb(78, 78, 78);
@@ -268,6 +282,11 @@ p.table-header{
268282
opacity: 0;
269283
transition: opacity 0.3s;
270284
}
285+
286+
.visits.tooltip .tooltiptext{
287+
width: 120px;
288+
transform: translateX(-50%) translateY(-120%);
289+
}
271290

272291
/* Show the tooltip text when you mouse over the tooltip container */
273292
.tooltip:hover .tooltiptext {

0 commit comments

Comments
 (0)