Skip to content

Commit c893921

Browse files
committed
Change time picker part 2
1 parent 17942ff commit c893921

File tree

4 files changed

+30
-24
lines changed

4 files changed

+30
-24
lines changed

options.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,16 @@
9292
<div class="tooltip"><img src="/icons/information.svg" height="18" />
9393
<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>
9494
</div>
95-
<div class="margin-top-10">
96-
<ul id='restrictionsList' class="listbox" size="10"></ul>
97-
</div>
9895
<div class="margin-top-10">
9996
<input type="text" placeholder="Enter site name..." id='addRestrictionSiteLbl' />
10097
<div class="inline-block clockpicker" data-placement="left" data-align="top" data-autoclose="true">
10198
<input type="text" class="clock" placeholder="Time..." readonly id="addRestrictionTimeLbl">
10299
</div>
103100
<input type="button" value="+" id='addRestrictionSiteBtn' />
104101
</div>
102+
<div class="margin-top-10">
103+
<ul id='restrictionsList' class="listbox" size="10"></ul>
104+
</div>
105105
<div class="notify warning" id='notifyForRestrictionList' hidden>
106106
The site is already in the list
107107
</div>

scripts/common.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ function convertShortSummaryTimeToString(summaryTime) {
8989
hours = zeroAppend(hours);
9090
mins = zeroAppend(mins);
9191

92-
return hours + 'h ' + mins + 'm';
92+
return hours + 'h : ' + mins + 'm';
9393
}
9494

9595
function convertSummaryTimeToString(summaryTime) {

scripts/settings.js

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function clearAllData() {
105105
storage.saveTabs(tabs, allDataDeletedSuccess);
106106
}
107107

108-
function allDataDeletedSuccess(){
108+
function allDataDeletedSuccess() {
109109
viewNotify('notify');
110110
}
111111

@@ -186,20 +186,25 @@ function addDomainToRestrictionListBox(resctiction) {
186186
deleteRestrictionSite(e);
187187
});
188188

189-
var timeElement = document.createElement('input');
190-
var resultTime = convertShortSummaryTimeToString(resctiction.time);
191-
timeElement.type = 'text';
192-
timeElement.value = resultTime;
193-
timeElement.readOnly = true;
194-
timeElement.classList.add('readonly-input', 'block', 'margin-top-5');
195-
timeElement.setAttribute('name', 'time');
189+
var bloc = document.createElement('div');
190+
bloc.classList.add('clockpicker');
191+
bloc.setAttribute('data-placement', 'left');
192+
bloc.setAttribute('data-align', 'top');
193+
bloc.setAttribute('data-autoclose', 'true');
194+
var timeInput = document.createElement('input');
195+
timeInput.type = 'text';
196+
timeInput.classList.add('clock', 'clock-li-readonly');
197+
timeInput.setAttribute('readonly', true);
198+
timeInput.setAttribute('name', 'time');
199+
timeInput.value = convertShortSummaryTimeToString(resctiction.time);
200+
bloc.appendChild(timeInput);
196201

197202
var hr = document.createElement('hr');
198203
var li = document.getElementById('restrictionsList').appendChild(li);
199204
li.appendChild(domainLbl);
200205
li.appendChild(del);
201206
li.appendChild(edit);
202-
li.appendChild(timeElement);
207+
li.appendChild(bloc);
203208
li.appendChild(hr);
204209
}
205210

@@ -223,26 +228,22 @@ function editRestrictionSite(e) {
223228
var targetElement = e.path[1];
224229
var domainElement = targetElement.querySelector('[name="domain"]');
225230
var timeElement = targetElement.querySelector('[name="time"]');
226-
if (timeElement.readOnly == true) {
227-
timeElement.classList.remove('readonly-input');
228-
timeElement.readOnly = false;
229-
var timeText = targetElement.querySelector('[name="time"]').value;
230-
var hour = timeText.split(' ')[0].slice(0, 2);
231-
var min = timeText.split(' ')[1].slice(0, 2);
232-
timeElement.type = 'time';
231+
if (timeElement.classList.contains('clock-li-readonly')) {
232+
timeElement.classList.remove('clock-li-readonly');
233+
var hour = timeElement.value.split(':')[0].slice(0, 2);
234+
var min = timeElement.value.split(':')[1].slice(1, 3);
233235
timeElement.value = hour + ':' + min;
234236
var editCmd = targetElement.querySelector('[name="editCmd"]');
235237
editCmd.src = '/icons/success.png';
238+
$('.clockpicker').clockpicker();
236239
}
237240
else {
238241
var domain = domainElement.value;
239242
var time = timeElement.value;
240243
if (domain !== '' && time !== '') {
241244
var editCmd = targetElement.querySelector('[name="editCmd"]');
242245
editCmd.src = '/icons/edit.png';
243-
timeElement.classList.add('readonly-input');
244-
timeElement.readOnly = true;
245-
timeElement.type = 'text';
246+
timeElement.classList.add('clock-li-readonly');
246247
var resultTime = convertShortSummaryTimeToString(convertTimeToSummaryTime(time));
247248
timeElement.value = resultTime;
248249

style/settings.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,16 @@ input[type="button"]:hover {
303303
}
304304

305305
.clock{
306-
width: 55px;
306+
width: 65px;
307307
height: 15px;
308308
padding: 3px;
309309
}
310310

311+
.clock-li-readonly{
312+
border: none;
313+
margin-left: -3px;
314+
}
315+
311316
.inline-block{
312317
display: inline-block !important;
313318
}

0 commit comments

Comments
 (0)