Skip to content

Commit b68a2d3

Browse files
first commit
0 parents  commit b68a2d3

File tree

5 files changed

+189
-0
lines changed

5 files changed

+189
-0
lines changed

background.js

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
const form = document.querySelector("#itemForm");
2+
const itemInput = document.querySelector("#itemInput");
3+
const itemList = document.querySelector("#itemList");
4+
const messageDiv = document.querySelector("#message");
5+
const clearButton = document.querySelector("#clearBtn");
6+
const filters = document.querySelectorAll(".nav-item");
7+
8+
let todoItems = [];
9+
10+
function handleitem(itemData)
11+
{
12+
const items = document.querySelectorAll(".list-group-item")
13+
items.forEach((item)=>{
14+
console.log("aisi");
15+
console.log(item.querySelector(".title").getAttribute("data-time"))
16+
console.log(itemData.addat)
17+
if(item.querySelector(".title").getAttribute("data-time") == itemData.addat)
18+
{
19+
console.log("aisi1");
20+
item.querySelector("[data-done]").addEventListener("click", function (e) {
21+
e.preventDefault();
22+
const itemIndex = todoItems.indexOf(itemData);
23+
const currentItem = todoItems[itemIndex];
24+
currentItem.isdone = currentItem.isdone ? false:true;
25+
todoItems.splice(itemIndex,1,currentItem);
26+
setlocalstorage(todoItems);
27+
});
28+
//delete
29+
item
30+
.querySelector("[data-delete]")
31+
.addEventListener("click", function (e) {
32+
e.preventDefault();
33+
itemList.removeChild(item);
34+
const removeIndex = todoItems.indexOf(item);
35+
todoItems.splice(removeIndex, 1);
36+
setlocalstorage(todoItems);
37+
});
38+
}
39+
})
40+
}
41+
42+
function getList(todoItems) {
43+
itemList.innerHTML = "";
44+
console.log(todoItems.length)
45+
if (todoItems.length > 0) {
46+
todoItems.forEach((item) => {
47+
if(item.isdone==true)
48+
{
49+
itemN = `<del>${item.name}</del>`
50+
}
51+
else
52+
{
53+
itemN = `${item.name}`
54+
}
55+
itemList.insertAdjacentHTML(
56+
"beforeend",
57+
`<li class="list-group-item d-flex justify-content-between align-items-center">
58+
<span class="title" data-time="${item.addat}">${itemN}</span>
59+
<span>
60+
<a href="#" data-done><i class="bi bi-check-circle green"></i></a>
61+
<a href="#" data-delete><i class="bi bi-x-circle red"></i></a>
62+
</span>
63+
</li>`
64+
65+
);
66+
handleitem(item);
67+
});
68+
}
69+
else
70+
{
71+
console.log("nai")
72+
}
73+
};
74+
75+
function setlocalstorage(todoItems)
76+
{
77+
localStorage.setItem("todoItems",JSON.stringify(todoItems));
78+
getlocalstorage();
79+
}
80+
81+
function getlocalstorage()
82+
{
83+
todostorage= localStorage.getItem("todoItems")
84+
if(todostorage=="undefine" || todostorage==null)
85+
{
86+
todoItems=[];
87+
}
88+
else
89+
{
90+
todoItems=JSON.parse(todostorage);
91+
}
92+
console.log(todoItems)
93+
getList(todoItems);
94+
}
95+
96+
document.addEventListener('DOMContentLoaded',()=>{
97+
form.addEventListener("submit",(e)=>{
98+
e.preventDefault();
99+
const itemname=itemInput.value.trim();
100+
if(itemname.length == 0)
101+
{
102+
103+
}
104+
else
105+
{
106+
const itemobj = {
107+
name: itemname,
108+
isdone: false,
109+
addat: new Date().getTime(),
110+
};
111+
console.log(itemname)
112+
todoItems.push(itemobj)
113+
setlocalstorage(todoItems)
114+
//showAlert("New item has been added.", "alert-success");
115+
}
116+
console.log(itemname)
117+
});
118+
getlocalstorage();
119+
});

manifest.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "TODO list",
4+
"version": "1.0.0",
5+
"description": "A simple todo-list develop by Ashiqur Rahman Anik",
6+
"action": {
7+
"default_popup": "popup.html",
8+
"default_icon": "to-do-list.png"
9+
},
10+
"icons": {
11+
"16": "to-do-list.png",
12+
"32": "to-do-list.png",
13+
"48": "to-do-list.png",
14+
"128": "to-do-list.png"
15+
}
16+
}

popup.html

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
7+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
8+
<title>Todo List</title>
9+
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
10+
integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
11+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.3.0/font/bootstrap-icons.css">
12+
</head>
13+
14+
<body style="width: 400px;">
15+
<div class="container">
16+
<div class="row">
17+
<div class="col col-md-8 mt-3 text-center">
18+
<div class="align-items-center" id="message"></div>
19+
<form id="itemForm">
20+
<h6 class=""> TO DO LIST</h6>
21+
<div class="input-group mb-3">
22+
<input type="text" class="form-control" id="itemInput" value=""
23+
placeholder="Enter Your Todo Works">
24+
<button class="btn btn-outline-primary">ADD ITEM</button>
25+
</div>
26+
</form>
27+
<!-- list items -->
28+
<ul class="list-group list-group-flush" id="itemList"></ul>
29+
<input type="hidden" id="filterType" value="all">
30+
<input type="hidden" id="citem" value="">
31+
</div>
32+
</div>
33+
34+
</div>
35+
<script src="background.js"></script>
36+
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/js/bootstrap.bundle.min.js"
37+
integrity="sha384-w76AqPfDkMBDXo30jS1Sgez6pr3x5MlQ1ZAGC+nuZB+EYdgRZgiwxhTBTkF7CXvN"
38+
crossorigin="anonymous"></script>
39+
</body>
40+
41+
</html>

readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Instillation Steps
2+
1. Download Folder
3+
2. Goto chrome://extensions/
4+
3. On Developer Mode
5+
4. Click On Load Unpacked
6+
5. Then Select Folder
7+
8+
### Screen Shots
9+
10+
![1](https://user-images.githubusercontent.com/38730778/219474387-ded2e8d3-e51a-493a-a9a5-fd8489ac9c2e.JPG)
11+
![2](https://user-images.githubusercontent.com/38730778/219474358-799f2672-b907-475a-87ae-e305c9da60ec.JPG)
12+
![3](https://user-images.githubusercontent.com/38730778/219474375-6ffb3d83-806c-465e-9ed2-7a17943a78d4.JPG)
13+
![4](https://user-images.githubusercontent.com/38730778/219474382-86c4207a-faa9-4400-948e-a3432196bf26.JPG)

to-do-list.png

24.8 KB
Loading

0 commit comments

Comments
 (0)