mirror of
https://github.com/zyqunix/tools.git
synced 2025-07-06 06:20:30 +02:00
unfinished notes
This commit is contained in:
parent
11b3210dcc
commit
96d4722500
3 changed files with 155 additions and 0 deletions
33
notes/index.js
Normal file
33
notes/index.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
const newNoteButton = document.getElementById('new-note');
|
||||
const notes = document.querySelector('div[id="notes"]');
|
||||
const editor = document.getElementById('editor-area');
|
||||
const left = document.getElementById('left');
|
||||
const editingTop = document.getElementById('editing');
|
||||
|
||||
let count = 0;
|
||||
let noteOpen = false;
|
||||
let currentNote = null;
|
||||
|
||||
newNoteButton.addEventListener('click', () => {
|
||||
const newNote = document.createElement('button');
|
||||
count++;
|
||||
newNote.className = "new-note";
|
||||
newNote.id = count;
|
||||
|
||||
let currentTime = `${new Date().getDate()}/${new Date().getMonth() + 1}/${new Date().getFullYear()}, ${new Date().getHours()}:${new Date().getMinutes()}`;
|
||||
newNote.innerHTML = `#${count} ${currentTime}`;
|
||||
|
||||
notes.appendChild(newNote);
|
||||
|
||||
newNote.addEventListener('click', () => {
|
||||
noteOpen = true;
|
||||
if (currentNote) {
|
||||
currentNote.style.backgroundColor = '';
|
||||
}
|
||||
currentNote = newNote;
|
||||
document.querySelector('h1[class="hint"]').innerHTML = `Editing #${currentNote.id}`;
|
||||
editor.style.display = "flex";
|
||||
currentNote.style.backgroundColor = '#404040';
|
||||
editingTop.innerHTML = `Editing <strong>${newNote.innerHTML}</strong>`;
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue