mirror of
https://github.com/zyqunix/tools.git
synced 2025-07-05 14:00:31 +02:00
morse && -notes
This commit is contained in:
parent
b5d4387c95
commit
b2150a6161
5 changed files with 5 additions and 359 deletions
|
@ -8,7 +8,7 @@
|
||||||
<link rel="stylesheet" href="style.css">
|
<link rel="stylesheet" href="style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="card shadow">
|
<div class="cards shadow">
|
||||||
<h1>Morse Translator</h1>
|
<h1>Morse Translator</h1>
|
||||||
<textarea id="textInput" placeholder="Enter text..." rows="5"></textarea>
|
<textarea id="textInput" placeholder="Enter text..." rows="5"></textarea>
|
||||||
<button id="translate-to-morse">Translate to Morse</button>
|
<button id="translate-to-morse">Translate to Morse</button>
|
||||||
|
|
|
@ -13,8 +13,8 @@ textarea, input, button {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
border: none;
|
border: none;
|
||||||
background-color: #333;
|
background-color: var(--surface0);
|
||||||
color: #f0f0f0;
|
color: var(--text);
|
||||||
}
|
}
|
||||||
|
|
||||||
textarea {
|
textarea {
|
||||||
|
@ -24,10 +24,10 @@ textarea {
|
||||||
|
|
||||||
button {
|
button {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
background-color: #444;
|
background-color: var(--surface0);
|
||||||
}
|
}
|
||||||
|
|
||||||
button:hover {
|
button:hover {
|
||||||
background-color: #555;
|
background-color: var(--surface1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,31 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Notes</title>
|
|
||||||
<link rel="stylesheet" href="style.css">
|
|
||||||
<link rel="shortcut icon" href="https://rimgo.pussthecat.org/RFbdMMB.png" type="image/x-icon">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="top">
|
|
||||||
<button id="new-note">New Note</button>
|
|
||||||
<button id="stop-note">Stop Editing</button>
|
|
||||||
<button id="export">Export JSON</button>
|
|
||||||
<label for="import">Import JSON</label>
|
|
||||||
<input type="file" id="import" accept="application/json">
|
|
||||||
<span id="editing"></span>
|
|
||||||
</div>
|
|
||||||
<div class="main">
|
|
||||||
<div class="left" id="left" title="SHIFT+LMB to RENAME a Note; SHIFT+RMB to DELETE a Note">
|
|
||||||
<div id="notes"></div>
|
|
||||||
</div>
|
|
||||||
<div class="editor" id="editor">
|
|
||||||
<textarea name="editor" id="editor-area" placeholder="Enter Text Here..."></textarea>
|
|
||||||
<h2 class="hint">Click on "New Note" and click on the new note to open it!</h2>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="index.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
177
notes/index.js
177
notes/index.js
|
@ -1,177 +0,0 @@
|
||||||
const newNoteButton = document.getElementById('new-note');
|
|
||||||
const stopNote = document.getElementById('stop-note');
|
|
||||||
const notes = document.querySelector('div[id="notes"]');
|
|
||||||
const editor = document.getElementById('editor-area');
|
|
||||||
const editingTop = document.getElementById('editing');
|
|
||||||
const exportButton = document.getElementById('export');
|
|
||||||
const importButton = document.getElementById('import');
|
|
||||||
|
|
||||||
let count = 0;
|
|
||||||
let noteOpen = false;
|
|
||||||
let currentNote = null;
|
|
||||||
|
|
||||||
function getNotesFromCookies() {
|
|
||||||
const notesCookie = document.cookie.split('; ').find(row => row.startsWith('notes='));
|
|
||||||
return notesCookie ? JSON.parse(notesCookie.split('=')[1]) : [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveNotesToCookies(notesArray) {
|
|
||||||
document.cookie = `notes=${JSON.stringify(notesArray)}; path=/; max-age=31536000`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createNoteElement(note) {
|
|
||||||
const newNote = document.createElement('button');
|
|
||||||
newNote.className = "new-note";
|
|
||||||
newNote.id = note.id;
|
|
||||||
newNote.innerHTML = `#${note.id} ${note.time}`;
|
|
||||||
|
|
||||||
newNote.addEventListener('click', () => {
|
|
||||||
if (currentNote) {
|
|
||||||
saveCurrentNoteContent();
|
|
||||||
currentNote.style.backgroundColor = '';
|
|
||||||
}
|
|
||||||
document.querySelector('h2[class="hint"]').style.opacity = "0";
|
|
||||||
noteOpen = true;
|
|
||||||
currentNote = newNote;
|
|
||||||
editor.style.display = "flex";
|
|
||||||
editor.value = note.content;
|
|
||||||
currentNote.style.backgroundColor = '#404040';
|
|
||||||
editingTop.innerHTML = `Editing <strong>${newNote.innerHTML}</strong>`;
|
|
||||||
});
|
|
||||||
|
|
||||||
newNote.addEventListener('mousedown', (e) => {
|
|
||||||
if (e.shiftKey && e.button === 0) {
|
|
||||||
renameCurrentNote();
|
|
||||||
} else if (e.shiftKey && e.button === 2) {
|
|
||||||
deleteNote(note.id);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
newNote.addEventListener('contextmenu', (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
return newNote;
|
|
||||||
}
|
|
||||||
|
|
||||||
function deleteNote(noteId) {
|
|
||||||
if (confirm("Are you sure you want to delete this note?")) {
|
|
||||||
let savedNotes = getNotesFromCookies();
|
|
||||||
savedNotes = savedNotes.filter(note => note.id !== noteId);
|
|
||||||
saveNotesToCookies(savedNotes);
|
|
||||||
updateNotesList();
|
|
||||||
|
|
||||||
if (currentNote && parseInt(currentNote.id) === noteId) {
|
|
||||||
editor.style.display = 'none';
|
|
||||||
document.querySelector('h2[class="hint"]').style.opacity = "1";
|
|
||||||
currentNote = null;
|
|
||||||
noteOpen = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function updateNotesList() {
|
|
||||||
const savedNotes = getNotesFromCookies();
|
|
||||||
notes.innerHTML = '';
|
|
||||||
savedNotes.forEach(note => {
|
|
||||||
const noteElement = createNoteElement(note);
|
|
||||||
notes.appendChild(noteElement);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveCurrentNoteContent() {
|
|
||||||
if (currentNote) {
|
|
||||||
const savedNotes = getNotesFromCookies();
|
|
||||||
const noteIndex = savedNotes.findIndex(note => note.id === parseInt(currentNote.id));
|
|
||||||
if (noteIndex !== -1) {
|
|
||||||
savedNotes[noteIndex].content = editor.value;
|
|
||||||
saveNotesToCookies(savedNotes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function renameCurrentNote() {
|
|
||||||
const newTitle = prompt("Enter new title:");
|
|
||||||
if (newTitle && currentNote) {
|
|
||||||
const savedNotes = getNotesFromCookies();
|
|
||||||
const noteIndex = savedNotes.findIndex(note => note.id === parseInt(currentNote.id));
|
|
||||||
if (noteIndex !== -1) {
|
|
||||||
savedNotes[noteIndex].time = newTitle;
|
|
||||||
saveNotesToCookies(savedNotes);
|
|
||||||
currentNote.innerHTML = `#${savedNotes[noteIndex].id} ${newTitle}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function exportNotes() {
|
|
||||||
const savedNotes = getNotesFromCookies();
|
|
||||||
const json = JSON.stringify(savedNotes, null, 2);
|
|
||||||
const blob = new Blob([json], { type: 'application/json' });
|
|
||||||
const url = URL.createObjectURL(blob);
|
|
||||||
const a = document.createElement('a');
|
|
||||||
a.href = url;
|
|
||||||
a.download = `${new Date().getDate()}_${new Date().getMonth() + 1}_${new Date().getFullYear()} ${new Date().getHours()}_${new Date().getMinutes()}-notes.json`;
|
|
||||||
a.click();
|
|
||||||
URL.revokeObjectURL(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
function importNotes(event) {
|
|
||||||
const file = event.target.files[0];
|
|
||||||
if (file && file.type === 'application/json') {
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = () => {
|
|
||||||
try {
|
|
||||||
const importedNotes = JSON.parse(reader.result);
|
|
||||||
console.log(importedNotes);
|
|
||||||
if (Array.isArray(importedNotes)) {
|
|
||||||
saveNotesToCookies(importedNotes);
|
|
||||||
updateNotesList();
|
|
||||||
} else {
|
|
||||||
alert('Invalid JSON structure');
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
alert('Failed to parse JSON');
|
|
||||||
console.error('Error parsing JSON:', e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
reader.readAsText(file);
|
|
||||||
} else {
|
|
||||||
alert('Please select a valid JSON file');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
newNoteButton.addEventListener('click', () => {
|
|
||||||
const currentTime = `${new Date().getDate()}/${new Date().getMonth() + 1}/${new Date().getFullYear()}, ${new Date().getHours()}:${new Date().getMinutes()}`;
|
|
||||||
const newNote = {
|
|
||||||
id: count + 1,
|
|
||||||
time: currentTime,
|
|
||||||
content: '',
|
|
||||||
};
|
|
||||||
count++;
|
|
||||||
const newNoteElement = createNoteElement(newNote);
|
|
||||||
notes.appendChild(newNoteElement);
|
|
||||||
|
|
||||||
const savedNotes = getNotesFromCookies();
|
|
||||||
savedNotes.push(newNote);
|
|
||||||
saveNotesToCookies(savedNotes);
|
|
||||||
updateNotesList();
|
|
||||||
|
|
||||||
newNoteElement.click();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
stopNote.addEventListener('click', () => {
|
|
||||||
document.querySelector('h2[class="hint"]').style.opacity = "1";
|
|
||||||
noteOpen = false;
|
|
||||||
if (currentNote) {
|
|
||||||
currentNote.style.backgroundColor = '#303030';
|
|
||||||
saveCurrentNoteContent();
|
|
||||||
}
|
|
||||||
editor.style.display = 'none';
|
|
||||||
});
|
|
||||||
|
|
||||||
exportButton.addEventListener('click', exportNotes);
|
|
||||||
importButton.addEventListener('change', importNotes);
|
|
||||||
|
|
||||||
updateNotesList();
|
|
146
notes/style.css
146
notes/style.css
|
@ -1,146 +0,0 @@
|
||||||
@import url(/global.css);
|
|
||||||
|
|
||||||
textarea::selection {
|
|
||||||
background: Highlight;
|
|
||||||
color: HighlightText;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.top {
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
position: fixed;
|
|
||||||
background-color: #242424dd;
|
|
||||||
backdrop-filter: blur(5px);
|
|
||||||
-webkit-backdrop-filter: blur(5px);
|
|
||||||
user-select: none;
|
|
||||||
z-index: 9999;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.top div#editing {
|
|
||||||
width: max-content;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.top > button,
|
|
||||||
div.top > label {
|
|
||||||
padding: 8px;
|
|
||||||
margin: 10px 4px 10px 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
background-color: #242424;
|
|
||||||
color: white;
|
|
||||||
border: 2px solid #242424;
|
|
||||||
border-radius: 5px;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.top > input {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.top > button:not(:nth-child(1)),
|
|
||||||
div.top > label:not(:nth-child(1)) {
|
|
||||||
margin: 10px 4px 10px 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.top > button:hover,
|
|
||||||
div.top > label:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
background-color: rgb(42, 42, 42);
|
|
||||||
color: white;
|
|
||||||
border: 2px solid #282828;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.left {
|
|
||||||
left: 0;
|
|
||||||
top: 55px;
|
|
||||||
position: absolute;
|
|
||||||
background-color: #242424;
|
|
||||||
height: 100%;
|
|
||||||
max-width: 35%;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
#notes {
|
|
||||||
display: grid;
|
|
||||||
scroll-behavior: smooth;
|
|
||||||
}
|
|
||||||
|
|
||||||
#notes > button {
|
|
||||||
cursor: pointer;
|
|
||||||
user-select: none;
|
|
||||||
padding: 4px 4px;
|
|
||||||
margin: 4px 7px;
|
|
||||||
background-color: #303030;
|
|
||||||
color: white;
|
|
||||||
border: 2px solid transparent;
|
|
||||||
text-align: left;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
button[class="new-note open"] {
|
|
||||||
background-color: #353535;
|
|
||||||
}
|
|
||||||
|
|
||||||
#notes > button:hover {
|
|
||||||
background-color: #343434;
|
|
||||||
}
|
|
||||||
|
|
||||||
#editor-area {
|
|
||||||
width: calc(100% - 190px);
|
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
|
||||||
top: 55px;
|
|
||||||
left: 190px;
|
|
||||||
background-color: #2a2a2a;
|
|
||||||
color: white;
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
overflow-wrap: break-word;
|
|
||||||
word-break: break-word;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
overflow: hidden;
|
|
||||||
padding: 10px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
resize: none;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 1024px) {
|
|
||||||
div.left {
|
|
||||||
max-width: 50%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#editor-area {
|
|
||||||
width: calc(100% - 150px);
|
|
||||||
left: 150px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
div.left {
|
|
||||||
max-width: 60%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#editor-area {
|
|
||||||
width: calc(100% - 120px);
|
|
||||||
left: 120px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 480px) {
|
|
||||||
div.left {
|
|
||||||
max-width: 100%;
|
|
||||||
height: auto;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
#editor-area {
|
|
||||||
width: 100%;
|
|
||||||
left: 0;
|
|
||||||
top: auto;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
div.top {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue