Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a more minimalistic to-do-list #402

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions To-do-list/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Minimalistic To-Do List</title>
</head>
<body>
<div class="container">
<h1>Minimalistic To-Do List</h1>
<div class="input-section">
<input type="text" id="taskInput" placeholder="Add a new task...">
<button id="addTask">Add</button>
</div>
<ul id="taskList"></ul>
</div>
<script src="script.js"></script>
</body>
</html>
25 changes: 25 additions & 0 deletions To-do-list/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
document.addEventListener("DOMContentLoaded", function () {
const taskInput = document.getElementById("taskInput");
const addTaskButton = document.getElementById("addTask");
const taskList = document.getElementById("taskList");

addTaskButton.addEventListener("click", function () {
const taskText = taskInput.value.trim();

if (taskText !== "") {
const taskItem = document.createElement("li");
taskItem.innerHTML = `
${taskText}
<button class="delete">Delete</button>
`;
Comment on lines +11 to +14

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML

[DOM text](1) is reinterpreted as HTML without escaping meta-characters.

taskList.appendChild(taskItem);

taskInput.value = "";

taskItem.querySelector(".delete").addEventListener("click", function () {
taskItem.remove();
});
}
});
});
65 changes: 65 additions & 0 deletions To-do-list/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
text-align: center;
}

.container {
max-width: 400px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
color: #333;
}

.input-section {
display: flex;
margin-top: 10px;
}

input[type="text"] {
flex: 1;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
}

button {
background-color: #4caf50;
color: white;
border: none;
border-radius: 5px;
padding: 10px 20px;
cursor: pointer;
}

ul {
list-style-type: none;
padding: 0;
}

li {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10px;
border: 1px solid #ddd;
margin: 5px 0;
border-radius: 5px;
background-color: #fff;
}

.delete {
background-color: #f44336;
color: white;
border: none;
border-radius: 5px;
padding: 5px 10px;
cursor: pointer;
margin-left: 5px;
}