-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
43 lines (37 loc) · 1.25 KB
/
renderer.js
File metadata and controls
43 lines (37 loc) · 1.25 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
const { ipcRenderer } = require('electron');
const noteContent = document.getElementById('note-content');
const closeBtn = document.getElementById('close-btn');
const addBtn = document.getElementById('add-btn');
// Get Note ID from URL
const params = new URLSearchParams(window.location.search);
const noteId = params.get('id');
const storageKey = `sticky-note-${noteId}`;
// Load saved note
window.addEventListener('DOMContentLoaded', () => {
if (noteId) {
const savedNote = localStorage.getItem(storageKey);
if (savedNote) {
noteContent.value = savedNote;
}
}
});
// Auto-save on input
noteContent.addEventListener('input', () => {
if (noteId) {
localStorage.setItem(storageKey, noteContent.value);
}
});
// Close/Delete functionality
closeBtn.addEventListener('click', () => {
// Optional: Confirm before delete?
// For a sticky note, usually clicking X just kills it.
// Maybe we can wipe the storage too to keep it clean,
// but keeping it might be safe for undo later (though we remove the ID from main list).
// Let's remove data to be clean.
localStorage.removeItem(storageKey);
ipcRenderer.send('delete-note');
});
// Add New functionality
addBtn.addEventListener('click', () => {
ipcRenderer.send('create-new-note');
});