Skip to content

Commit 68bf25a

Browse files
authored
Merge pull request #881 from malivinayak/NoteTakingApp/malivinayak
Projet : NoteTakingApp
2 parents c44c30b + 29ae36a commit 68bf25a

File tree

3 files changed

+136
-0
lines changed

3 files changed

+136
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
<link rel="stylesheet" href="styles.css">
7+
<title>Note-taking App</title>
8+
</head>
9+
<body>
10+
<div class="note-container">
11+
<h2>Note-taking App</h2>
12+
<div id="noteList"></div>
13+
<div id="noteDetails"></div>
14+
<button onclick="showAddNoteForm()">Add Note</button>
15+
<div id="addNoteForm" style="display: none;">
16+
<h3>Add New Note</h3>
17+
<label for="noteTitle">Title:</label>
18+
<input type="text" id="noteTitle">
19+
<label for="noteContent">Content:</label>
20+
<textarea id="noteContent"></textarea>
21+
<button onclick="addNote()">Save Note</button>
22+
</div>
23+
</div>
24+
<script src="script.js"></script>
25+
</body>
26+
</html>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
let notes = [];
2+
3+
function showNotes() {
4+
const noteList = document.getElementById('noteList');
5+
noteList.innerHTML = '<h3>Notes</h3>';
6+
7+
for (let i = 0; i < notes.length; i++) {
8+
const noteItem = document.createElement('div');
9+
noteItem.classList.add('note-item');
10+
noteItem.innerHTML = `
11+
<p><a href="#" onclick="showNoteDetails(${i})">${notes[i].title}</a></p>
12+
<button onclick="deleteNote(${i})">Delete</button>
13+
`;
14+
noteList.appendChild(noteItem);
15+
}
16+
}
17+
18+
function showNoteDetails(index) {
19+
const noteDetails = document.getElementById('noteDetails');
20+
const selectedNote = notes[index];
21+
22+
if (selectedNote) {
23+
noteDetails.innerHTML = `
24+
<h3>${selectedNote.title}</h3>
25+
<p>${selectedNote.content}</p>
26+
`;
27+
}
28+
}
29+
30+
function showAddNoteForm() {
31+
const addNoteForm = document.getElementById('addNoteForm');
32+
addNoteForm.style.display = 'block';
33+
}
34+
35+
function addNote() {
36+
const noteTitle = document.getElementById('noteTitle').value;
37+
const noteContent = document.getElementById('noteContent').value;
38+
39+
if (noteTitle && noteContent) {
40+
notes.push({ title: noteTitle, content: noteContent });
41+
showNotes();
42+
resetAddNoteForm();
43+
}
44+
}
45+
46+
function resetAddNoteForm() {
47+
document.getElementById('noteTitle').value = '';
48+
document.getElementById('noteContent').value = '';
49+
document.getElementById('addNoteForm').style.display = 'none';
50+
}
51+
52+
function deleteNote(index) {
53+
notes.splice(index, 1);
54+
showNotes();
55+
}
56+
57+
showNotes();
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
body {
2+
font-family: 'Arial', sans-serif;
3+
display: flex;
4+
align-items: center;
5+
justify-content: center;
6+
height: 100vh;
7+
margin: 0;
8+
background-color: #3498db;
9+
}
10+
11+
.note-container {
12+
text-align: center;
13+
border: 1px solid #ccc;
14+
padding: 20px;
15+
border-radius: 8px;
16+
background: white;
17+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
18+
color: #3498db;
19+
}
20+
21+
button {
22+
padding: 10px;
23+
background-color: #2ecc71;
24+
color: white;
25+
border: none;
26+
border-radius: 4px;
27+
cursor: pointer;
28+
margin-top: 10px;
29+
}
30+
31+
button:hover {
32+
background-color: #27ae60;
33+
}
34+
35+
#addNoteForm {
36+
margin-top: 20px;
37+
display: none;
38+
}
39+
40+
label {
41+
display: block;
42+
margin-top: 10px;
43+
}
44+
45+
input, textarea {
46+
width: 100%;
47+
padding: 10px;
48+
margin-top: 5px;
49+
margin-bottom: 10px;
50+
border: 1px solid #ddd;
51+
border-radius: 4px;
52+
box-sizing: border-box;
53+
}

0 commit comments

Comments
 (0)