-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
35 lines (28 loc) · 1002 Bytes
/
Copy pathscript.js
File metadata and controls
35 lines (28 loc) · 1002 Bytes
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
// script.js
document.getElementById('taskForm').addEventListener('submit', async function (e) {
e.preventDefault();
const task = document.getElementById('taskInput').value;
// Send task to the backend
const response = await fetch('/api/generate-steps', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ task })
});
const data = await response.json();
const steps = data.steps;
const stepsContainer = document.getElementById('stepsContainer');
stepsContainer.innerHTML = ''; // Clear previous steps
steps.forEach(step => {
const stepItem = document.createElement('div');
stepItem.classList.add('step-item');
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
const stepText = document.createElement('span');
stepText.textContent = step;
stepItem.appendChild(checkbox);
stepItem.appendChild(stepText);
stepsContainer.appendChild(stepItem);
});
});