-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (62 loc) · 2.61 KB
/
Copy pathscript.js
File metadata and controls
70 lines (62 loc) · 2.61 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
68
69
70
document.addEventListener('DOMContentLoaded', () => {
const today = new Date();
document.getElementById('currentDate').innerText = 'Generated on: ' +
today.toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
document.getElementById('taskList').appendChild(createTaskRow());
});
function createTaskRow() {
const row = document.createElement('div');
row.className = 'task-row';
row.innerHTML = `
<div class="form-group">
<label>Date</label>
<input type="date" required>
</div>
<div class="form-group">
<label>Theme / Topic of Work</label>
<input type="text" placeholder="Enter topic description..." required>
</div>
<div class="form-group">
<label>Deadline</label>
<input type="date" required>
</div>
<div class="form-group">
<label>Status</label>
<select>
<option value="Not Done">Not Done ⏳</option>
<option value="In Progress">In Progress 🔄</option>
<option value="Done">Done ✅</option>
</select>
</div>
<button class="btn-remove" onclick="this.parentElement.remove()" title="Remove Task">
<svg width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 24 24"><path d="M18 6L6 18M6 6l12 12"/></svg>
</button>
`;
return row;
}
function addTask() {
document.getElementById('taskList').appendChild(createTaskRow());
}
function generatePDF() {
const element = document.getElementById('pdf-content');
const inputs = element.querySelectorAll('input');
inputs.forEach(input => input.setAttribute('value', input.value));
const selects = element.querySelectorAll('select');
selects.forEach(select => {
Array.from(select.options).forEach(opt => opt.removeAttribute('selected'));
if(select.selectedIndex >= 0) {
select.options[select.selectedIndex].setAttribute('selected', 'selected');
}
});
element.classList.add('printing');
const opt = {
margin: 15,
filename: 'Work_Tracker_Report.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { scale: 2, useCORS: true },
jsPDF: { unit: 'mm', format: 'a4', orientation: 'landscape' }
};
html2pdf().set(opt).from(element).save().then(() => {
element.classList.remove('printing');
});
}