-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
67 lines (57 loc) · 2.29 KB
/
Copy pathmain.js
File metadata and controls
67 lines (57 loc) · 2.29 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Function to open the date picker modal
function openDatePicker(itemid,notes) {
const modal = document.getElementById('datePickerModal');
modal.style.display = 'flex'; // Show the modal
const dateItemId = document.getElementById('dateItemId');
dateItemId.value = itemid;
const noteDiv = document.getElementById('multiple-notes');
if (notes) {
noteDiv.style.display = 'block';
const noteText = document.getElementById('notes-text');
noteText.innerText = notes;
}
else noteDiv.style.display = 'none';
document.getElementById('userNote').value = '';
}
// Function to open the item modal
function openItemWindow(itemid, recurring) {
const modal = document.getElementById('itemModal');
modal.style.display = 'flex'; // Show the modal
desc = '';
link = '';
if (itemid) {
desc = document.getElementById('item'+itemid).children[0].innerHTML;
const linkElements = document.getElementById('item'+itemid).getElementsByTagName('a');
if (linkElements.length > 0) link = linkElements[0].href;
}
document.getElementById('editItemId').value = itemid;
document.getElementById('desc').value = desc;
document.getElementById('link').value = link;
document.getElementById('recurring').checked = recurring;
}
function closeItemModal() {
const modal = document.getElementById('itemModal');
modal.style.display = 'none'; // Hide the modal
}
function closeDateModal() {
const modal = document.getElementById('datePickerModal');
modal.style.display = 'none'; // Hide the modal
}
// add close event to item modal close button
const itemCloseButton = document.getElementById('closeItemForm');
itemCloseButton.addEventListener('click', function(event) {
event.preventDefault(); // Prevent the form's default submit behavior
closeItemModal();
});
// add close event to date modal close button
const dateCloseButton = document.getElementById('closeDateForm');
dateCloseButton.addEventListener('click', function(event) {
event.preventDefault(); // Prevent the form's default submit behavior
closeDateModal();
});
document.addEventListener('keydown', function(event) {
if (event.key === 'Escape') { // Check if the Escape key was pressed
closeDateModal();
closeItemModal();
}
});