-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-ai.html
More file actions
112 lines (105 loc) · 3.69 KB
/
Copy pathtest-ai.html
File metadata and controls
112 lines (105 loc) · 3.69 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Task Generator Test</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.container {
display: flex;
flex-direction: column;
gap: 20px;
}
textarea {
width: 100%;
height: 100px;
padding: 10px;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
padding: 15px;
border: 1px solid #ddd;
border-radius: 4px;
min-height: 100px;
white-space: pre-wrap;
background-color: #f9f9f9;
}
.loading {
display: none;
color: #666;
font-style: italic;
}
</style>
</head>
<body>
<div class="container">
<h1>AI Task Generator Test</h1>
<div>
<h3>Enter Project Description:</h3>
<textarea id="project-desc" placeholder="E.g., Plan a birthday party for next Friday with 20 guests"></textarea>
</div>
<button id="generate-btn">Generate Tasks</button>
<div id="loading" class="loading">Generating tasks, please wait...</div>
<div>
<h3>Generated Tasks:</h3>
<div id="result">Generated tasks will appear here...</div>
</div>
</div>
<!-- Include the AI client -->
<script src="scripts/ai-client.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
const generateBtn = document.getElementById('generate-btn');
const projectDesc = document.getElementById('project-desc');
const resultDiv = document.getElementById('result');
const loadingDiv = document.getElementById('loading');
generateBtn.addEventListener('click', async () => {
const description = projectDesc.value.trim();
if (!description) {
resultDiv.textContent = 'Please enter a project description';
return;
}
try {
// Show loading state
loadingDiv.style.display = 'block';
resultDiv.textContent = '';
// Initialize the AI generator
const aiGenerator = new AITaskGenerator();
// Generate tasks
const tasks = await aiGenerator.generateTasks(description);
// Display results
if (tasks && tasks.length > 0) {
resultDiv.textContent = JSON.stringify(tasks, null, 2);
} else {
resultDiv.textContent = 'No tasks were generated. Please try again with a different description.';
}
} catch (error) {
console.error('Error:', error);
resultDiv.textContent = `Error: ${error.message || 'Failed to generate tasks'}`;
} finally {
// Hide loading state
loadingDiv.style.display = 'none';
}
});
});
</script>
</body>
</html>