File tree Expand file tree Collapse file tree 6 files changed +51
-11
lines changed
Expand file tree Collapse file tree 6 files changed +51
-11
lines changed Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff 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 ) )
Original file line number Diff line number Diff 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+
7283function convertSummaryTimeToString ( summaryTime ) {
7384 var days = Math . floor ( summaryTime / 3600 / 24 ) ;
7485 var totalHours = summaryTime % ( 3600 * 24 ) ;
Original file line number Diff line number Diff line change 33class 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} ;
Original file line number Diff line number Diff 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 ;
Original file line number Diff line number Diff line change @@ -239,7 +239,7 @@ input[type="button"]:hover {
239239
240240 .notify {
241241 width : 200px ;
242- height : 30 px ;
242+ height : 27 px ;
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 : 17 px ;
253+ font-size : 15 px ;
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}
You can’t perform that action at this time.
0 commit comments