-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew-note.html
More file actions
89 lines (87 loc) · 2.68 KB
/
new-note.html
File metadata and controls
89 lines (87 loc) · 2.68 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>New Note</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f0f0f0;
}
.container {
max-width: 800px;
margin: 0 auto;
background: white;
padding: 20px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 5px;
}
input, textarea {
width: 100%;
border: 1px solid #ccc;
padding: 10px;
font-size: 16px;
border-radius: 5px;
box-sizing: border-box;
margin-bottom: 10px;
}
.buttons {
margin-top: 10px;
text-align: right;
}
button {
padding: 10px 20px;
font-size: 16px;
margin-left: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
}
button.save {
background-color: #070807;
color: white;
}
button.cancel {
background-color: #474545;
color: white;
}
</style>
</head>
<body>
<div class="container">
<h1>New Note</h1>
<input type="text" id="title" placeholder="Title">
<textarea id="note" placeholder="Note"></textarea>
<input type="text" id="tags" placeholder="Tags (comma-separated)">
<div class="buttons">
<button class="save" onclick="saveNote()">save</button>
<button class="cancel" onclick="window.location.href='index.html'">cancel</button>
</div>
</div>
<script>
function saveNote() {
const title = document.getElementById('title').value;
const note = document.getElementById('note').value;
const tags = document.getElementById('tags').value.split(',').map(tag => tag.trim()).filter(tag => tag !== '');
const date = new Date().toLocaleString();
if (title.trim() === '' || note.trim() === '') {
alert('Title and Note cannot be empty!');
return;
}
const notes = JSON.parse(localStorage.getItem('notes')) || [];
const noteData = {
title: title,
note: note,
tags: tags,
date: date
};
notes.push(noteData);
localStorage.setItem('notes', JSON.stringify(notes));
window.location.href = 'index.html';
}
</script>
</body>
</html>