-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
95 lines (89 loc) · 2.64 KB
/
Copy pathindex.html
File metadata and controls
95 lines (89 loc) · 2.64 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
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home - Random Item Selector</title>
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f4f9;
color: #333;
}
h1 {
text-align: center;
color: #4A90E2;
}
.container {
max-width: 600px;
margin: auto;
background: white;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
padding: 20px;
}
button {
margin-top: 10px;
padding: 10px 15px;
border: none;
border-radius: 5px;
background-color: #4A90E2;
color: white;
cursor: pointer;
transition: background-color 0.3s ease;
}
button:hover {
background-color: #357ABD;
}
ul {
list-style-type: none;
padding: 0;
margin: 0;
}
li {
margin: 10px 0;
display: flex;
justify-content: space-between;
align-items: center;
}
strong {
font-size: 1.2em;
}
</style>
</head>
<body>
<div class="container">
<h1>Your Lists</h1>
<ul id="listContainer"></ul>
<button onclick="location.href='create_note.html'">Create New Note</button>
</div>
<script>
function updateListDisplay() {
const lists = JSON.parse(localStorage.getItem('lists')) || {};
const listContainer = document.getElementById('listContainer');
listContainer.innerHTML = '';
for (const list in lists) {
const listItem = document.createElement('li');
listItem.innerHTML = `
<strong>${list}</strong>
<div>
<button onclick="location.href='note.html?list=${encodeURIComponent(list)}'">Edit</button>
<button onclick="generateRandomItem('${list}')">Select Random Item</button>
</div>
`;
listContainer.appendChild(listItem);
}
}
function generateRandomItem(listName) {
const lists = JSON.parse(localStorage.getItem('lists')) || {};
const items = lists[listName];
const randomIndex = Math.floor(Math.random() * items.length);
const selectedItem = items[randomIndex];
alert("Selected Item: " + selectedItem);
}
window.onload = updateListDisplay;
</script>
</body>
</html>