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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
'use strict';
|
| 2 |
document.querySelectorAll('[data-password]').forEach(button => {
|
| 3 |
button.addEventListener('click', () => {
|
|
|
|
| 1 |
+
// 'use strict';
|
| 2 |
+
// document.querySelectorAll('[data-password]').forEach(button => {
|
| 3 |
+
// button.addEventListener('click', () => {
|
| 4 |
+
// const field = document.getElementById(button.dataset.password);
|
| 5 |
+
// field.type = field.type === 'password' ? 'text' : 'password';
|
| 6 |
+
// button.textContent = field.type === 'password' ? 'Show' : 'Hide';
|
| 7 |
+
// });
|
| 8 |
+
// });
|
| 9 |
+
// const dirtyForms = new Set();
|
| 10 |
+
// document.querySelectorAll('form[data-dirty]').forEach(form => {
|
| 11 |
+
// form.addEventListener('input', () => dirtyForms.add(form));
|
| 12 |
+
// form.addEventListener('change', () => dirtyForms.add(form));
|
| 13 |
+
// });
|
| 14 |
+
// document.querySelectorAll('form').forEach(form => {
|
| 15 |
+
// form.addEventListener('submit', event => {
|
| 16 |
+
// if (form.dataset.confirm && !window.confirm(form.dataset.confirm)) {
|
| 17 |
+
// event.preventDefault();
|
| 18 |
+
// return;
|
| 19 |
+
// }
|
| 20 |
+
// if ([...dirtyForms].some(dirty => dirty !== form) && !window.confirm('Another form has unsaved changes. Leave without saving those changes?')) {
|
| 21 |
+
// event.preventDefault();
|
| 22 |
+
// return;
|
| 23 |
+
// }
|
| 24 |
+
// dirtyForms.clear();
|
| 25 |
+
// });
|
| 26 |
+
// });
|
| 27 |
+
// window.addEventListener('beforeunload', event => {
|
| 28 |
+
// if (dirtyForms.size) {
|
| 29 |
+
// event.preventDefault();
|
| 30 |
+
// event.returnValue = '';
|
| 31 |
+
// }
|
| 32 |
+
// });
|
| 33 |
+
// document.querySelectorAll('.char-counter').forEach(counter => {
|
| 34 |
+
// const field = document.getElementById(counter.dataset.for);
|
| 35 |
+
// const update = () => { counter.textContent = `${field.value.length} / 3000 characters · One clear item per entry`; };
|
| 36 |
+
// field.addEventListener('input', update);
|
| 37 |
+
// update();
|
| 38 |
+
// });
|
| 39 |
+
// document.getElementById('print-report')?.addEventListener('click', () => window.print());
|
| 40 |
+
// document.querySelectorAll('form').forEach(form => {
|
| 41 |
+
// const operation = form.querySelector('input[name="operation"][value="add"]');
|
| 42 |
+
// if (!operation || form.querySelector('input[name="due_date"]')) return;
|
| 43 |
+
// const label = document.createElement('label');
|
| 44 |
+
// label.htmlFor = 'entry_mode';
|
| 45 |
+
// label.textContent = 'Update entry';
|
| 46 |
+
// const select = document.createElement('select');
|
| 47 |
+
// select.id = 'entry_mode';
|
| 48 |
+
// select.name = 'entry_mode';
|
| 49 |
+
// select.innerHTML = '<option value="single">One update</option><option value="bulk">Multiple updates (one per line)</option>';
|
| 50 |
+
// label.append(select);
|
| 51 |
+
// operation.after(label);
|
| 52 |
+
// });
|
| 53 |
+
// document.querySelectorAll('form').forEach(form => {
|
| 54 |
+
// const operation = form.querySelector('input[name="operation"][value="add"]');
|
| 55 |
+
// const body = form.querySelector('textarea[name="body"]');
|
| 56 |
+
// if (!operation || !body || form.querySelector('input[name="due_date"]')) return;
|
| 57 |
+
// const submitButton = form.querySelector('button[type="submit"], button:not([type])');
|
| 58 |
+
// form.addEventListener('submit', event => {
|
| 59 |
+
// const entries = body.value.split(/\r?\n/).map(line => line.trim()).filter(Boolean);
|
| 60 |
+
// if (entries.length < 2 || form.dataset.previewConfirmed === 'true') return;
|
| 61 |
+
// if (form.querySelector('[data-update-preview]')) {
|
| 62 |
+
// event.preventDefault();
|
| 63 |
+
// return;
|
| 64 |
+
// }
|
| 65 |
+
// event.preventDefault();
|
| 66 |
+
// const preview = document.createElement('div');
|
| 67 |
+
// preview.className = 'notice';
|
| 68 |
+
// preview.dataset.updatePreview = 'true';
|
| 69 |
+
// preview.innerHTML = '<strong>Review these updates before saving:</strong>';
|
| 70 |
+
// const list = document.createElement('ol');
|
| 71 |
+
// entries.forEach(entry => {
|
| 72 |
+
// const item = document.createElement('li');
|
| 73 |
+
// item.textContent = entry;
|
| 74 |
+
// list.append(item);
|
| 75 |
+
// });
|
| 76 |
+
// const cancel = document.createElement('button');
|
| 77 |
+
// cancel.type = 'button';
|
| 78 |
+
// cancel.className = 'button secondary';
|
| 79 |
+
// cancel.textContent = 'Cancel';
|
| 80 |
+
// cancel.addEventListener('click', () => {
|
| 81 |
+
// preview.remove();
|
| 82 |
+
// if (submitButton) submitButton.disabled = false;
|
| 83 |
+
// });
|
| 84 |
+
// const save = document.createElement('button');
|
| 85 |
+
// save.type = 'button';
|
| 86 |
+
// save.className = 'button';
|
| 87 |
+
// save.textContent = 'Save these updates';
|
| 88 |
+
// save.addEventListener('click', () => {
|
| 89 |
+
// form.dataset.previewConfirmed = 'true';
|
| 90 |
+
// preview.remove();
|
| 91 |
+
// body.disabled = true;
|
| 92 |
+
// entries.forEach(entry => {
|
| 93 |
+
// const input = document.createElement('input');
|
| 94 |
+
// input.type = 'hidden';
|
| 95 |
+
// input.name = 'body';
|
| 96 |
+
// input.value = entry;
|
| 97 |
+
// form.append(input);
|
| 98 |
+
// });
|
| 99 |
+
// form.requestSubmit();
|
| 100 |
+
// });
|
| 101 |
+
// preview.append(list, cancel, save);
|
| 102 |
+
// form.prepend(preview);
|
| 103 |
+
// if (submitButton) submitButton.disabled = true;
|
| 104 |
+
// });
|
| 105 |
+
// });
|
| 106 |
+
// document.querySelectorAll('form').forEach(form => {
|
| 107 |
+
// const operation = form.querySelector('input[name="operation"][value="add"]');
|
| 108 |
+
// const body = form.querySelector('textarea[name="body"]');
|
| 109 |
+
// const dueDate = form.querySelector('input[name="due_date"]');
|
| 110 |
+
// if (!operation || !body || !dueDate) return;
|
| 111 |
+
// const modeLabel = document.createElement('label');
|
| 112 |
+
// modeLabel.htmlFor = 'action_entry_mode';
|
| 113 |
+
// modeLabel.textContent = 'Action entry';
|
| 114 |
+
// const mode = document.createElement('select');
|
| 115 |
+
// mode.id = 'action_entry_mode';
|
| 116 |
+
// mode.name = 'action_entry_mode';
|
| 117 |
+
// mode.innerHTML = '<option value="single">One action</option><option value="bulk">Multiple actions (one per line)</option>';
|
| 118 |
+
// modeLabel.append(mode);
|
| 119 |
+
// operation.after(modeLabel);
|
| 120 |
+
// const updateActionMode = () => {
|
| 121 |
+
// dueDate.required = mode.value !== 'bulk';
|
| 122 |
+
// dueDate.disabled = mode.value === 'bulk';
|
| 123 |
+
// };
|
| 124 |
+
// mode.addEventListener('change', updateActionMode);
|
| 125 |
+
// updateActionMode();
|
| 126 |
+
// const submitButton = form.querySelector('button[type="submit"], button:not([type])');
|
| 127 |
+
// form.addEventListener('submit', event => {
|
| 128 |
+
// const entries = body.value.split(/\r?\n/).map(line => {
|
| 129 |
+
// const match = line.match(/^\s*\d+\.\s*(?:\[(.*?)\]|(.*?))\s*(?:\[(.*?)\])?\s*$/);
|
| 130 |
+
// if (!match) return null;
|
| 131 |
+
// const value = (match[3] || '').trim();
|
| 132 |
+
// const isDate = /^\d{4}-\d{2}-\d{2}$/.test(value);
|
| 133 |
+
// return { body: (match[1] || match[2]).trim(), due: isDate ? value : '', note: isDate ? '' : value };
|
| 134 |
+
// }).filter(Boolean);
|
| 135 |
+
// if ((mode.value !== 'bulk' && entries.length < 2) || form.dataset.previewConfirmed === 'true') return;
|
| 136 |
+
// event.preventDefault();
|
| 137 |
+
// if (form.querySelector('[data-action-preview]')) return;
|
| 138 |
+
// const preview = document.createElement('div');
|
| 139 |
+
// preview.className = 'notice';
|
| 140 |
+
// preview.dataset.actionPreview = 'true';
|
| 141 |
+
// preview.innerHTML = '<strong>Review these actions before saving:</strong>';
|
| 142 |
+
// const list = document.createElement('ol');
|
| 143 |
+
// entries.forEach(entry => {
|
| 144 |
+
// const item = document.createElement('li');
|
| 145 |
+
// item.textContent = `${entry.body} - ${entry.due ? `Due ${entry.due}` : entry.note || 'No due date'}`;
|
| 146 |
+
// list.append(item);
|
| 147 |
+
// });
|
| 148 |
+
// const cancel = document.createElement('button');
|
| 149 |
+
// cancel.type = 'button';
|
| 150 |
+
// cancel.className = 'button secondary';
|
| 151 |
+
// cancel.textContent = 'Cancel';
|
| 152 |
+
// cancel.addEventListener('click', () => {
|
| 153 |
+
// preview.remove();
|
| 154 |
+
// if (submitButton) submitButton.disabled = false;
|
| 155 |
+
// });
|
| 156 |
+
// const save = document.createElement('button');
|
| 157 |
+
// save.type = 'button';
|
| 158 |
+
// save.className = 'button';
|
| 159 |
+
// save.textContent = 'Save these actions';
|
| 160 |
+
// save.addEventListener('click', () => {
|
| 161 |
+
// form.dataset.previewConfirmed = 'true';
|
| 162 |
+
// preview.remove();
|
| 163 |
+
// body.disabled = true;
|
| 164 |
+
// dueDate.disabled = true;
|
| 165 |
+
// entries.forEach((entry, index) => {
|
| 166 |
+
// const bodyInput = document.createElement('input');
|
| 167 |
+
// bodyInput.type = 'hidden';
|
| 168 |
+
// bodyInput.name = 'body';
|
| 169 |
+
// bodyInput.value = `${index + 1}. ${entry.body}${entry.due ? ` [${entry.due}]` : entry.note ? ` [${entry.note}]` : ''}`;
|
| 170 |
+
// form.append(bodyInput);
|
| 171 |
+
// const dateInput = document.createElement('input');
|
| 172 |
+
// dateInput.type = 'hidden';
|
| 173 |
+
// dateInput.name = 'due_date';
|
| 174 |
+
// dateInput.value = entry.due;
|
| 175 |
+
// form.append(dateInput);
|
| 176 |
+
// const noteInput = document.createElement('input');
|
| 177 |
+
// noteInput.type = 'hidden';
|
| 178 |
+
// noteInput.name = 'due_note';
|
| 179 |
+
// noteInput.value = entry.note;
|
| 180 |
+
// form.append(noteInput);
|
| 181 |
+
// });
|
| 182 |
+
// form.requestSubmit();
|
| 183 |
+
// });
|
| 184 |
+
// preview.append(list, cancel, save);
|
| 185 |
+
// form.prepend(preview);
|
| 186 |
+
// if (submitButton) submitButton.disabled = true;
|
| 187 |
+
// });
|
| 188 |
+
// });
|
| 189 |
+
// document.querySelectorAll('input[name="due_date"]').forEach(field => {
|
| 190 |
+
// const meetingDate = new Date(`${field.min}T00:00:00`);
|
| 191 |
+
// const formatDate = value => value.toISOString().slice(0, 10);
|
| 192 |
+
// meetingDate.setDate(meetingDate.getDate() - 7);
|
| 193 |
+
// field.min = formatDate(meetingDate);
|
| 194 |
+
// meetingDate.setDate(meetingDate.getDate() + 14);
|
| 195 |
+
// field.max = formatDate(meetingDate);
|
| 196 |
+
// });
|
| 197 |
+
|
| 198 |
+
|
| 199 |
'use strict';
|
| 200 |
document.querySelectorAll('[data-password]').forEach(button => {
|
| 201 |
button.addEventListener('click', () => {
|