-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
38 lines (28 loc) · 991 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
var $checkbox = document.getElementsByClassName('show_completed');
if ($checkbox.length) {
$checkbox[0].addEventListener('change', function (event) {
var is_checked = +event.target.checked;
var searchParams = new URLSearchParams(window.location.search);
searchParams.set('show_completed', is_checked);
window.location = '/index.php?' + searchParams.toString();
});
}
var $taskCheckboxes = document.getElementsByClassName('tasks');
if ($taskCheckboxes.length) {
$taskCheckboxes[0].addEventListener('change', function (event) {
// if (event.target.classList.contains('task__checkbox')) {
console.log(event.target);
var el = event.target;
var is_checked = el.checked ? 0 : 1;
var task_id = el.getAttribute('value');
var url = '/index.php?task_id=' + task_id + '&check=' + is_checked;
window.location = url;
// }
});
}
flatpickr('#date', {
enableTime: false,
dateFormat: "Y-m-d",
locale: "ru"
});