-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtaskhunt.js
103 lines (88 loc) · 4.06 KB
/
taskhunt.js
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
document.addEventListener('DOMContentLoaded', function() {
const signupPage = document.getElementById('signupPage');
const loginPage = document.getElementById('loginPage');
const taskManagementPage = document.getElementById('taskManagementPage');
const createTaskBtn = document.getElementById('createTaskBtn');
const taskList = document.getElementById('taskList');
let tasks = [];
document.addEventListener('DOMContentLoaded', function() {
const signupPage = document.getElementById('signupPage');
const loginPage = document.getElementById('loginPage');
const taskPage = document.getElementById('taskPage');
// Initially hide task and login pages
taskPage.style.display = 'none';
loginPage.style.display = 'none';
// Simulated user login logic (Replace with your actual login logic)
const loginForm = document.getElementById('loginForm');
loginForm.addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
// Simulated login check (Replace with your actual login check)
if (username === 'user' && password === 'password') {
// Show the task page and hide others
taskPage.style.display = 'block';
loginPage.style.display = 'none';
signupPage.style.display = 'none';
} else {
alert('Invalid username or password. Please try again.');
}
});
// Other code for your tasks, signup, etc. can go here
});
// Mocked task data (replace with actual data logic)
function showLoginPage() {
signupPage.style.display = 'none';
loginPage.style.display = 'block';
}
function showTaskManagement() {
loginPage.style.display = 'none';
taskManagementPage.style.display = 'block';
displayTasks();
}
function displayTasks() {
taskList.innerHTML = '';
tasks.forEach(task => {
const taskElement = document.createElement('div');
taskElement.classList.add('task');
taskElement.innerHTML = `
<h3>${task.name}</h3>
<p><strong>Assignee:</strong> ${task.assignee}</p>
<p><strong>Due Date:</strong> ${task.dueDate}</p>
<button class="viewTask" data-taskid="${task.id}">View Task</button>
`;
taskList.appendChild(taskElement);
});
}
function generateId() {
return '_' + Math.random().toString(36).substr(2, 9);
}
// Event listener for create task button
createTaskBtn.addEventListener('click', function() {
taskManagementPage.style.display = 'none';
taskDetailPage.style.display = 'block';
});
// Event listener for login form
const loginForm = document.getElementById('loginForm');
loginForm.addEventListener('submit', function(event) {
event.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
// Your login validation logic here
// For simplicity, let's assume login is successful if both fields are not empty
if (username.trim() !== '' && password.trim() !== '') {
// Redirect to task management page
showTaskManagement();
} else {
alert('Invalid username or password. Please try again.');
}
});
// Initially display signup page
signupPage.style.display = 'block';
loginPage.style.display = 'none';
taskManagementPage.style.display = 'none';
// Simulate a user signing up (You should replace this with your actual signup/login logic)
setTimeout(() => {
showLoginPage();
}, 2000); // Simulating 2 seconds delay after page load
});