-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgfed.html
123 lines (111 loc) · 3.83 KB
/
gfed.html
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
113
114
115
116
117
118
119
120
121
122
123
<!DOCTYPE html>
<html lang="ar">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>مدير المهام</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
}
h1 {
text-align: center;
}
.task-container {
margin: 20px auto;
max-width: 600px;
background: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.task {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
border-bottom: 1px solid #eee;
}
.task:last-child {
border-bottom: none;
}
.btn {
margin-top: 10px;
padding: 10px;
background-color: #5cb85c;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
.btn-danger {
background-color: #d9534f;
}
</style>
</head>
<body>
<h1>مدير المهام</h1>
<div class="task-container">
<input type="text" id="taskName" placeholder="اسم المهمة" required>
<input type="text" id="taskDescription" placeholder="وصف المهمة">
<input type="date" id="taskDueDate">
<button class="btn" onclick="addTask()">إضافة مهمة</button>
<div id="taskList"></div>
</div>
<script>
// تحميل المهام عند تحميل الصفحة
window.onload = function() {
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
tasks.forEach(task => {
displayTask(task.name, task.description, task.dueDate);
});
};
function addTask() {
const name = document.getElementById('taskName').value;
const description = document.getElementById('taskDescription').value;
const dueDate = document.getElementById('taskDueDate').value;
if (!name) {
alert('يرجى إدخال اسم المهمة');
return;
}
const task = { name, description, dueDate };
saveTaskToLocal(task);
displayTask(name, description, dueDate);
// إعادة تعيين الحقول
document.getElementById('taskName').value = '';
document.getElementById('taskDescription').value = '';
document.getElementById('taskDueDate').value = '';
}
function displayTask(name, description, dueDate) {
const taskList = document.getElementById('taskList');
const taskDiv = document.createElement('div');
taskDiv.className = 'task';
taskDiv.innerHTML = `
<div>
<strong>${name}</strong><br>
<span>${description || 'لا يوجد وصف'}</span><br>
<span>${dueDate ? 'تاريخ الاستحقاق: ' + dueDate : 'بدون تاريخ استحقاق'}</span>
</div>
<button class="btn btn-danger" onclick="removeTask(this)">حذف</button>
`;
taskList.appendChild(taskDiv);
}
function saveTaskToLocal(task) {
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
tasks.push(task);
localStorage.setItem('tasks', JSON.stringify(tasks));
}
function removeTask(button) {
const taskDiv = button.parentElement;
const name = taskDiv.querySelector('strong').innerText;
const tasks = JSON.parse(localStorage.getItem('tasks')) || [];
const updatedTasks = tasks.filter(task => task.name !== name);
localStorage.setItem('tasks', JSON.stringify(updatedTasks));
taskDiv.remove();
}
</script>
</body>
</html>