Skip to content

Commit 76b3c9c

Browse files
Merge pull request #12 from Rounak-chauhan/main
to do list separate file
2 parents 0b85cdb + 4035228 commit 76b3c9c

File tree

4 files changed

+125
-0
lines changed

4 files changed

+125
-0
lines changed

To-Do List/.gitkeep

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

To-Do List/HTML

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
9+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
10+
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
11+
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
12+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
13+
<script src="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.10.2/js/all.js"></script>
14+
15+
<script defer src="script.js"></script>
16+
<link rel="stylesheet" href="style.css">
17+
18+
</head>
19+
<body>
20+
21+
<div class="container">
22+
<h1 align="center">Todo List</h1>
23+
24+
<div class="row">
25+
<!-- Input box -->
26+
<div class="col-md-7">
27+
28+
<div class="form-group">
29+
<label for="inpNewTask">New Task</label>
30+
<input type="text" class="form-control" id="inpNewTask"
31+
aria-describedby="newTaskHelp"
32+
placeholder="Enter the name of the task">
33+
<small id="newTaskHelp" class="form-text text-muted">A short one line description of your task</small>
34+
</div>
35+
</div>
36+
37+
<!-- Buttons -->
38+
<div class="col-md-5">
39+
<div class="row">
40+
<div class="col-6 col-sm-3 col-md-6 p-1">
41+
<button class="btn btn-success col" disabled id="btnAdd">
42+
<i class="fas fa-plus-square"></i> Add
43+
</button>
44+
</div>
45+
<div class="col-6 col-sm-3 col-md-6 p-1">
46+
<button class="btn btn-danger col" disabled id="btnReset">
47+
<i class="fas fa-backspace"></i> Reset
48+
</button>
49+
</div>
50+
<div class="col-6 col-sm-3 col-md-6 p-1">
51+
<button class="btn btn-info col" disabled id="btnSort">
52+
<i class="fas fa-sort-amount-down"></i> Sort
53+
</button>
54+
</div>
55+
<div class="col-6 col-sm-3 col-md-6 p-1">
56+
<button class="btn btn-warning col" disabled id="btnCleanup">
57+
<i class="fas fa-trash-alt"></i> Cleanup
58+
</button>
59+
</div>
60+
</div>
61+
62+
</div>
63+
</div>
64+
65+
<!-- Task List -->
66+
67+
<ul class="row list-group m-2" id="ulTasks">
68+
</ul>
69+
</div>
70+
71+
</body>
72+
</html>

To-Do List/css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ulTasks li.done {
2+
color: #6c757d;
3+
text-decoration: line-through;
4+
}

To-Do List/javascript

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
let ulTasks = $('#ulTasks')
2+
let btnAdd = $('#btnAdd')
3+
let btnReset = $('#btnReset')
4+
let btnSort = $('#btnSort')
5+
let btnCleanup = $('#btnCleanup')
6+
let inpNewTask = $('#inpNewTask')
7+
8+
function addItem() {
9+
let listItem = $('<li>', {
10+
'class': 'list-group-item',
11+
text: inpNewTask.val()
12+
})
13+
listItem.click(() => {
14+
listItem.toggleClass('done')
15+
})
16+
ulTasks.append(listItem)
17+
inpNewTask.val('')
18+
toggleInputButtons()
19+
}
20+
21+
function clearDone() {
22+
$('#ulTasks .done').remove()
23+
toggleInputButtons()
24+
}
25+
26+
function sortTasks() {
27+
$('#ulTasks .done').appendTo(ulTasks)
28+
}
29+
30+
function toggleInputButtons() {
31+
btnReset.prop('disabled', inpNewTask.val() == '')
32+
btnAdd.prop('disabled', inpNewTask.val() == '')
33+
btnSort.prop('disabled', ulTasks.children().length < 1)
34+
btnCleanup.prop('disabled', ulTasks.children().length < 1)
35+
}
36+
37+
inpNewTask.keypress((e) => {
38+
if (e.which == 13) addItem()
39+
})
40+
inpNewTask.on('input', toggleInputButtons)
41+
42+
btnAdd.click(addItem)
43+
btnReset.click(() => {
44+
inpNewTask.val('')
45+
toggleInputButtons()
46+
})
47+
btnCleanup.click(clearDone)
48+
btnSort.click(sortTasks)

0 commit comments

Comments
 (0)