Skip to content

Commit f21b587

Browse files
authored
Merge pull request Stigmatoz#88 from nilshah98/85-edit_limits
[FIX] Edit limits in options page
2 parents 1dd6ab2 + 24ef0b1 commit f21b587

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

src/block.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
<div class="description">You've reached your limit today on <span id="site" class="current-site"></span></div>
1818
<div class="description margin-top-10">Your current daily limit is <span id="limit" class="current-limit"></span></div>
1919

20+
<div class="description margin-top-10">You have already been here
21+
<span id="deferredCount" class="deferred-metrics"></span> times for a total duration of
22+
<span id="deferredTime" class="deferred-metrics"></span> today !
23+
</div>
2024
<div class="margin-top-10"><a id="deffererBtn" class="defferer-link">Set aside for 5 minutes</a></div>
2125
</div>
2226
<p class="product-title">Web Activity Time Tracker</p>

src/scripts/background.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function backgroundCheck() {
6666

6767
function mainTRacker(activeUrl, tab, activeTab) {
6868
if (activity.isLimitExceeded(activeUrl, tab) && !activity.wasDeferred(activeUrl)) {
69-
setBlockPageToCurrent(activeTab.url);
69+
setBlockPageToCurrent(activeTab.url, tab.days.at(-1).summary, tab.days.at(-1).counter);
7070
}
7171
if (!activity.isInBlackList(activeUrl)) {
7272
if (activity.isNeedNotifyView(activeUrl, tab)) {
@@ -131,8 +131,10 @@ function notificationAction(activeUrl, tab) {
131131
});
132132
}
133133

134-
function setBlockPageToCurrent(currentUrl) {
135-
var blockUrl = chrome.runtime.getURL("block.html") + '?url=' + currentUrl;
134+
function setBlockPageToCurrent(currentUrl, summaryTime, counter) {
135+
var blockUrl = chrome.runtime.getURL("block.html") + '?url=' + currentUrl
136+
+ '&summaryTime=' + summaryTime
137+
+ '&counter=' + counter;
136138
chrome.tabs.query({ currentWindow: true, active: true }, function(tab) {
137139
chrome.tabs.update(tab.id, { url: blockUrl });
138140
});

src/scripts/block.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22

33
var storage = new LocalStorage();
44
var blockSiteUrl;
5+
var blockSiteTime;
6+
var blockSiteCounter;
57
var restrictionList = [];
68

79
document.addEventListener("DOMContentLoaded", function () {
810
var url = new URL(document.URL);
911
blockSiteUrl = url.searchParams.get("url");
12+
blockSiteTime = url.searchParams.get("summaryTime");
13+
blockSiteCounter = url.searchParams.get("counter");
1014
document.getElementById("site").innerText = extractHostname(blockSiteUrl);
15+
document.getElementById("deferredTime").innerText = convertShortSummaryTimeToString(blockSiteTime);
16+
document.getElementById("deferredCount").innerText = blockSiteCounter;
1117

1218
storage.getValue(STORAGE_RESTRICTION_LIST, function (items) {
1319
restrictionList = items;

src/scripts/settings.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,14 +444,14 @@ function addDomainToEditableListBox(entity, elementId, actionEdit, actionDelete,
444444
}
445445

446446
function deleteBlackSite(e) {
447-
var targetElement = e.path[1];
447+
var targetElement = e.composedPath()[1];
448448
blackList.splice(blackList.indexOf(targetElement.innerText), 1);
449449
document.getElementById('blackList').removeChild(targetElement);
450450
updateBlackList();
451451
}
452452

453453
function deleteRestrictionSite(e) {
454-
var targetElement = e.path[1];
454+
var targetElement = e.composedPath()[1];
455455
var itemValue = targetElement.querySelector("[name='domain']").value;
456456
var item = restrictionList.find(x => x.domain == itemValue);
457457
restrictionList.splice(restrictionList.indexOf(item), 1);
@@ -460,7 +460,7 @@ function deleteRestrictionSite(e) {
460460
}
461461

462462
function deleteNotificationSite(e) {
463-
var targetElement = e.path[1];
463+
var targetElement = e.composedPath()[1];
464464
var itemValue = targetElement.querySelector("[name='domain']").value;
465465
var item = notifyList.find(x => x.domain == itemValue);
466466
notifyList.splice(notifyList.indexOf(item), 1);
@@ -469,7 +469,7 @@ function deleteNotificationSite(e) {
469469
}
470470

471471
function actionEditSite(e, actionUpdateTimeFromList, actionUpdateList) {
472-
var targetElement = e.path[1];
472+
var targetElement = e.composedPath()[1];
473473
var domainElement = targetElement.querySelector('[name="domain"]');
474474
var timeElement = targetElement.querySelector('[name="time"]');
475475
if (timeElement.classList.contains('clock-li-readonly')) {

src/style/block.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,10 @@ body{
4141
color: gray;
4242
text-decoration: underline;
4343
cursor: pointer;
44+
}
45+
46+
.deferred-metrics{
47+
font-weight: 500;
48+
font-size: 1.2rem;
49+
color: rgb(202, 48, 48);
4450
}

0 commit comments

Comments
 (0)