Skip to content

Commit 1271864

Browse files
committed
set from current tab bold url of page
1 parent 77af1e7 commit 1271864

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

scripts/activity.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Activity {
66
if (tab.id && (tab.id != 0)) {
77
tabs = tabs || [];
88
var domain = this.extractHostname(tab.url);
9+
this.setCurrentActiveTab(domain);
910
if (this.isNewUrl(domain)) {
1011
var favicon = tab.favIconUrl;
1112
if (favicon === undefined){
@@ -16,6 +17,7 @@ class Activity {
1617
}
1718
}
1819
}
20+
else this.clearCurrentActiveTab();
1921
}
2022

2123
isValidPage(tab) {
@@ -65,4 +67,12 @@ class Activity {
6567
}
6668
}
6769
}
70+
71+
setCurrentActiveTab(domain){
72+
currentTab = domain;
73+
}
74+
75+
clearCurrentActiveTab(){
76+
currentTab = '';
77+
}
6878
};

scripts/background.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
var tabs = [];
4+
var currentTab;
45
var activity = new Activity();
56
var storage = new LocalStorage();
67

scripts/webact.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ function getTabsFromStorage(tabs) {
1818

1919
totalTime = setTotalTime(tabs);
2020

21+
var currentTab = getCurrentTab();
22+
2123
for (var i = 0; i < tabs.length; i++) {
2224
var div = document.createElement('div');
2325
div.classList.add('inline-flex');
@@ -30,6 +32,9 @@ function getTabsFromStorage(tabs) {
3032
var spanUrl = document.createElement('span');
3133
spanUrl.classList.add('span-url');
3234
spanUrl.innerText = tabs[i].url;
35+
if (tabs[i].url == currentTab){
36+
spanUrl.classList.add('span-active-url');
37+
}
3338

3439
var spanPercentage = document.createElement('span');
3540
spanPercentage.classList.add('span-percentage');
@@ -57,4 +62,8 @@ function setTotalTime(tabs) {
5762

5863
function setPercentage(time){
5964
return ((time / totalTime) * 100).toFixed(2) + '%';
65+
}
66+
67+
function getCurrentTab(){
68+
return chrome.extension.getBackgroundPage().currentTab;
6069
}

style/webact.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ body {
2020
cursor: pointer;
2121
}
2222

23+
.span-active-url{
24+
font-weight: 700;
25+
}
26+
2327
.span-url:hover{
2428
color: rgb(107, 107, 107);
2529
}

0 commit comments

Comments
 (0)