-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodal.html
More file actions
73 lines (68 loc) · 2.53 KB
/
modal.html
File metadata and controls
73 lines (68 loc) · 2.53 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
<!DOCTYPE html>
<html>
<head>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
background: rgba(0,0,0,0.7);
height: 100vh; display: flex; align-items: center; justify-content: center;
}
.modal-container {
background: white;
border-radius: 12px;
padding: 30px;
max-width: 350px;
box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}
h3 { color: #333; margin-bottom: 20px; font-size: 20px; }
input {
width: 100%; padding: 12px; border: 2px solid #ddd; border-radius: 6px;
font-size: 16px; margin-bottom: 20px;
}
input:focus { outline: none; border-color: #007acc; }
.buttons { display: flex; gap: 12px; }
button {
flex: 1; padding: 12px; border: none; border-radius: 6px;
font-size: 16px; cursor: pointer; font-weight: 500;
}
#bookmarkSaveBtn { background: #007acc; color: white; }
#bookmarkSaveBtn:hover { background: #005a9e; }
#bookmarkCancelBtn { background: #f0f0f0; color: #666; }
#bookmarkCancelBtn:hover { background: #e0e0e0; }
</style>
</head>
<body>
<div class="modal-container">
<h3>Save Bookmark</h3>
<input id="bookmarkNameInput" type="text" placeholder="Enter bookmark name">
<div class="buttons">
<button id="bookmarkSaveBtn">Save</button>
<button id="bookmarkCancelBtn">Cancel</button>
</div>
</div>
<script>
// Parse bookmark data from URL fragment
const fragment = window.location.hash.slice(1);
const bookmarkData = fragment ? JSON.parse(decodeURIComponent(fragment)) : {};
console.log('Modal got data:', bookmarkData);
const nameInput = document.getElementById('bookmarkNameInput');
nameInput.focus();
document.getElementById('bookmarkCancelBtn').onclick = () => {
window.modalAPI.close();
};
document.getElementById('bookmarkSaveBtn').onclick = async () => {
const name = nameInput.value.trim();
if (name && bookmarkData.bookmarkType && bookmarkData.bookmarkValue) {
console.log('Saving:', name, bookmarkData.bookmarkType, bookmarkData.bookmarkValue);
await window.modalAPI.saveBookmark(name, bookmarkData.bookmarkType, bookmarkData.bookmarkValue);
}
window.modalAPI.close();
};
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape') window.modalAPI.close();
if (e.key === 'Enter' && !e.shiftKey) document.getElementById('bookmarkSaveBtn').click();
});
</script>
</body>
</html>