Skip to content

Commit dfec726

Browse files
committed
change format restriction time
1 parent 3f716d7 commit dfec726

File tree

6 files changed

+51
-11
lines changed

6 files changed

+51
-11
lines changed

scripts/activity.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,15 @@ class Activity {
3434
else return false;
3535
}
3636

37-
checkRestrictionIfAny(domain){
37+
checkRestrictionIfAny(domain, tab){
3838
if (setting_restriction_list !== undefined && setting_restriction_list.length > 0){
3939
var item = setting_restriction_list.find(o => o.domain === domain);
4040
if (item !== undefined){
41-
41+
var today = new Date().toLocaleDateString();
42+
var todayTimeUse = tab.days.find(x => x.date == today).summary;
43+
if (todayTimeUse > item.time){
44+
45+
}
4246
}
4347
}
4448
else return false;

scripts/background.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function backgroundCheck() {
3838
activity.setCurrentActiveTab(tab.url);
3939
chrome.idle.queryState(parseInt(setting_interval_inactivity), function (state) {
4040
if (state === 'active') {
41-
if (activity.checkRestrictionIfAny(activeUrl) && ){
41+
if (activity.checkRestrictionIfAny(activeUrl, tab)){
4242

4343
}
4444
if (!activity.isInBlackList(activeUrl))

scripts/common.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ function convertSummaryTimeToBadgeString(summaryTime) {
6969
}
7070
}
7171

72+
function convertShortSummaryTimeToString(summaryTime){
73+
var hours = Math.floor(summaryTime / (3600 * 60));
74+
var totalSeconds = summaryTime % 3600;
75+
var mins = Math.floor(totalSeconds / 60);
76+
77+
hours = zeroAppend(hours);
78+
mins = zeroAppend(mins);
79+
80+
return hours + 'h ' + mins + 'm';
81+
}
82+
7283
function convertSummaryTimeToString(summaryTime) {
7384
var days = Math.floor(summaryTime / 3600 / 24);
7485
var totalHours = summaryTime % (3600 * 24);

scripts/restriction.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
class Restriction {
44
constructor(domain, time) {
55
this.domain = domain;
6-
this.time = time;
6+
var timeValue = time.split(':');
7+
var hour = timeValue[0];
8+
var min = timeValue[1];
9+
var resultTimeValue;
10+
if (hour > 0)
11+
resultTimeValue = hour * 60 * 3600;
12+
resultTimeValue += min * 60;
13+
this.time = resultTimeValue;
714
}
815
};

scripts/settings.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,11 @@ function addNewRestrictionSiteClickHandler() {
133133
var newRestrictionTime = document.getElementById('addRestrictionTimeLbl').value;
134134
if (newRestrictionSite !== '' && newRestrictionTime !== '') {
135135
if (!isContainsRestrictionSite(newRestrictionSite)) {
136-
addDomainToRestrictionListBox(new Restriction(newRestrictionSite, newRestrictionTime));
136+
var restriction = new Restriction(newRestrictionSite, newRestrictionTime);
137+
addDomainToRestrictionListBox(restriction);
137138
if (restrictionList === undefined)
138139
restrictionList = [];
139-
restrictionList.push(new Restriction(newRestrictionSite, newRestrictionTime));
140+
restrictionList.push(restriction);
140141
document.getElementById('addRestrictionSiteLbl').value = '';
141142
document.getElementById('addRestrictionTimeLbl').value = '';
142143

@@ -185,8 +186,7 @@ function addDomainToRestrictionListBox(resctiction) {
185186
});
186187

187188
var timeElement = document.createElement('input');
188-
var timeArray = resctiction.time.split(':');
189-
var resultTime = timeArray[0] + 'h ' + timeArray[1] + 'm';
189+
var resultTime = convertShortSummaryTimeToString(resctiction.time);
190190
timeElement.type = 'text';
191191
timeElement.value = resultTime;
192192
timeElement.readOnly = true;

style/settings.css

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ input[type="button"]:hover {
239239

240240
.notify{
241241
width: 200px;
242-
height: 30px;
242+
height: 27px;
243243
margin: auto;
244244
background-color: rgb(118, 219, 93);
245245
color: rgb(0, 0, 0);
@@ -250,7 +250,7 @@ input[type="button"]:hover {
250250
z-index: 1;
251251
top: 10px;
252252
right: 20px;
253-
font-size: 17px;
253+
font-size: 15px;
254254
white-space: nowrap;
255255
padding: 10px;
256256
}
@@ -299,5 +299,23 @@ input[type="button"]:hover {
299299

300300
#restrictionsList{
301301
width: 430px;
302-
height: 170px;
302+
height: 250px;
303+
}
304+
305+
.inline-block{
306+
display: inline-block !important;
307+
}
308+
309+
.block{
310+
display: block;
311+
}
312+
313+
.readonly-input{
314+
cursor: default;
315+
border: 0;
316+
display: block;
317+
}
318+
319+
.restriction-item{
320+
width: 380px;
303321
}

0 commit comments

Comments
 (0)