Skip to content

Commit db472e9

Browse files
committed
Edit restriction site
1 parent e716571 commit db472e9

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

options.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
</div>
8181
</div>
8282
<div id='restrictionsBlock' hidden>
83-
<label>Access restrictions for websites: </label>
83+
<label>Access daily restrictions for websites: </label>
8484
<div class="tooltip"><img src="/icons/information.svg" height="18" />
8585
<span class="tooltiptext">Set the time you can spend on the site during the day. After this time, access to the site will be blocked.</span>
8686
</div>

scripts/settings.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,10 @@ function addDomainToListBox(domain) {
135135

136136
function addDomainToRestrictionListBox(domain, time) {
137137
var li = document.createElement('li');
138-
li.innerText = domain;
138+
var domainLbl = document.createElement('div');
139+
domainLbl.classList.add('inline-block');
140+
domainLbl.innerText = domain;
141+
domainLbl.setAttribute('name', 'domain');
139142
var edit = document.createElement('img');
140143
edit.height = 14;
141144
edit.src = '/icons/edit.png';
@@ -153,10 +156,14 @@ function addDomainToRestrictionListBox(domain, time) {
153156
var timeArray = time.split(':');
154157
var resultTime = timeArray[0] + 'h ' + timeArray[1] + 'm';
155158
timeElement.innerText = resultTime;
159+
timeElement.setAttribute('name', 'time');
160+
var hr = document.createElement('hr');
156161
var li = document.getElementById('restrictionsList').appendChild(li);
162+
li.appendChild(domainLbl);
157163
li.appendChild(del);
158164
li.appendChild(edit);
159165
li.appendChild(timeElement);
166+
li.appendChild(hr);
160167
}
161168

162169
function deleteBlackSite(e) {
@@ -174,7 +181,12 @@ function deleteRestrictionSite(e) {
174181
}
175182

176183
function editRestrictionSite(e){
177-
184+
var targetElement = e.path[1];
185+
document.getElementById('addRestrictionSiteLbl').value = targetElement.querySelector('[name="domain"]').innerText;
186+
var timeText = targetElement.querySelector('[name="time"]').innerText;
187+
var hour = timeText.split(' ')[0].slice(0, 2);
188+
var min = timeText.split(' ')[1].slice(0, 2);
189+
document.getElementById('addRestrictionTimeLbl').value = hour + ':' + min;
178190
}
179191

180192
function updateBlackList() {

style/settings.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,9 @@ 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;
303307
}

0 commit comments

Comments
 (0)