sticky-notes-plus / index.html
afarouk79's picture
Add 3 files
8ae3fcd verified
Raw History Blame Contribute Delete
29.3 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sticky Notes+</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
from { transform: translateX(20px); opacity: 0; }
to { transform: translateX(0); opacity: 1; }
}
.note {
animation: fadeIn 0.3s ease-out forwards;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease;
}
.note:hover {
box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
transform: translateY(-2px);
}
.ruled-lines {
background-image: linear-gradient(to bottom, rgba(0,0,0,0.1) 1px, transparent 1px);
background-size: 100% 28px;
line-height: 28px;
}
.color-picker {
animation: slideIn 0.2s ease-out forwards;
}
.page-indicator {
transition: all 0.2s ease;
}
.handwriting-canvas {
touch-action: none;
}
/* Note color themes */
.note-yellow { background-color: rgba(255, 253, 161, 0.9); }
.note-mint { background-color: rgba(179, 255, 210, 0.9); }
.note-blue { background-color: rgba(179, 224, 255, 0.9); }
.note-pink { background-color: rgba(255, 200, 221, 0.9); }
.note-lavender { background-color: rgba(224, 200, 255, 0.9); }
.note-gray { background-color: rgba(235, 235, 235, 0.9); }
</style>
</head>
<body class="bg-gray-100 min-h-screen font-sans">
<div class="container mx-auto px-4 py-8">
<!-- Header -->
<header class="flex justify-between items-center mb-8">
<h1 class="text-3xl font-bold text-gray-800 flex items-center">
<i class="fas fa-sticky-note text-yellow-400 mr-3"></i>
Sticky Notes+
</h1>
<button id="new-note-btn" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-full flex items-center shadow-md transition">
<i class="fas fa-plus mr-2"></i> New Note
</button>
</header>
<!-- Notes Grid -->
<div id="notes-container" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6">
<!-- Notes will be dynamically added here -->
</div>
<!-- Empty State -->
<div id="empty-state" class="text-center py-20">
<i class="fas fa-sticky-note text-gray-300 text-6xl mb-4"></i>
<h2 class="text-2xl text-gray-500 mb-2">No notes yet</h2>
<p class="text-gray-400 mb-4">Click the "New Note" button to create your first sticky note</p>
</div>
</div>
<!-- Note Editor Modal (hidden by default) -->
<div id="note-editor" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50 hidden">
<div class="note note-yellow rounded-xl w-full max-w-2xl h-96 flex flex-col overflow-hidden shadow-xl">
<!-- Toolbar -->
<div class="bg-white bg-opacity-70 p-3 flex justify-between items-center border-b border-gray-200">
<div class="flex space-x-2">
<button id="color-btn" class="p-2 rounded-full hover:bg-gray-100">
<i class="fas fa-palette text-gray-700"></i>
</button>
<button id="ruled-btn" class="p-2 rounded-full hover:bg-gray-100">
<i class="fas fa-ruler-combined text-gray-700"></i>
</button>
<button id="handwriting-btn" class="p-2 rounded-full hover:bg-gray-100">
<i class="fas fa-pen-fancy text-gray-700"></i>
</button>
<button id="add-page-btn" class="p-2 rounded-full hover:bg-gray-100">
<i class="fas fa-plus-circle text-gray-700"></i>
</button>
</div>
<div class="flex space-x-2">
<button id="export-btn" class="p-2 rounded-full hover:bg-gray-100">
<i class="fas fa-share-alt text-gray-700"></i>
</button>
<button id="delete-btn" class="p-2 rounded-full hover:bg-gray-100 text-red-500">
<i class="fas fa-trash-alt"></i>
</button>
<button id="close-editor" class="p-2 rounded-full hover:bg-gray-100">
<i class="fas fa-times text-gray-700"></i>
</button>
</div>
</div>
<!-- Color Picker (hidden by default) -->
<div id="color-picker" class="color-picker bg-white p-3 shadow-md rounded-lg absolute hidden mt-12 ml-2 z-10">
<div class="grid grid-cols-3 gap-2">
<button data-color="yellow" class="w-8 h-8 rounded-full bg-yellow-200 hover:ring-2 ring-yellow-400"></button>
<button data-color="mint" class="w-8 h-8 rounded-full bg-green-200 hover:ring-2 ring-green-400"></button>
<button data-color="blue" class="w-8 h-8 rounded-full bg-blue-200 hover:ring-2 ring-blue-400"></button>
<button data-color="pink" class="w-8 h-8 rounded-full bg-pink-200 hover:ring-2 ring-pink-400"></button>
<button data-color="lavender" class="w-8 h-8 rounded-full bg-purple-200 hover:ring-2 ring-purple-400"></button>
<button data-color="gray" class="w-8 h-8 rounded-full bg-gray-200 hover:ring-2 ring-gray-400"></button>
</div>
</div>
<!-- Note Content Area -->
<div class="flex-1 overflow-hidden relative">
<!-- Pages container -->
<div id="pages-container" class="h-full w-full overflow-hidden relative">
<!-- Pages will be dynamically added here -->
</div>
<!-- Page Navigation -->
<div id="page-nav" class="absolute bottom-2 left-0 right-0 flex justify-center items-center space-x-2 hidden">
<button id="prev-page" class="p-1 rounded-full hover:bg-gray-100 bg-white bg-opacity-70">
<i class="fas fa-chevron-left text-gray-700"></i>
</button>
<div id="page-indicators" class="flex space-x-1">
<!-- Page indicators will be added here -->
</div>
<button id="next-page" class="p-1 rounded-full hover:bg-gray-100 bg-white bg-opacity-70">
<i class="fas fa-chevron-right text-gray-700"></i>
</button>
</div>
</div>
</div>
</div>
<!-- Export Options Modal (hidden by default) -->
<div id="export-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center p-4 z-50 hidden">
<div class="bg-white rounded-xl p-6 w-full max-w-md">
<div class="flex justify-between items-center mb-4">
<h3 class="text-xl font-semibold">Export Note</h3>
<button id="close-export" class="text-gray-500 hover:text-gray-700">
<i class="fas fa-times"></i>
</button>
</div>
<div class="space-y-4">
<button id="export-text" class="w-full py-3 px-4 bg-blue-100 hover:bg-blue-200 text-blue-800 rounded-lg flex items-center justify-between">
<span>Export as Text</span>
<i class="fas fa-file-alt"></i>
</button>
<button id="export-image" class="w-full py-3 px-4 bg-green-100 hover:bg-green-200 text-green-800 rounded-lg flex items-center justify-between">
<span>Export as Image</span>
<i class="fas fa-image"></i>
</button>
<button id="share-note" class="w-full py-3 px-4 bg-purple-100 hover:bg-purple-200 text-purple-800 rounded-lg flex items-center justify-between">
<span>Share Note</span>
<i class="fas fa-share"></i>
</button>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// DOM Elements
const notesContainer = document.getElementById('notes-container');
const emptyState = document.getElementById('empty-state');
const newNoteBtn = document.getElementById('new-note-btn');
const noteEditor = document.getElementById('note-editor');
const closeEditor = document.getElementById('close-editor');
const colorBtn = document.getElementById('color-btn');
const colorPicker = document.getElementById('color-picker');
const ruledBtn = document.getElementById('ruled-btn');
const handwritingBtn = document.getElementById('handwriting-btn');
const addPageBtn = document.getElementById('add-page-btn');
const exportBtn = document.getElementById('export-btn');
const deleteBtn = document.getElementById('delete-btn');
const pagesContainer = document.getElementById('pages-container');
const pageNav = document.getElementById('page-nav');
const prevPage = document.getElementById('prev-page');
const nextPage = document.getElementById('next-page');
const pageIndicators = document.getElementById('page-indicators');
const exportModal = document.getElementById('export-modal');
const closeExport = document.getElementById('close-export');
const exportText = document.getElementById('export-text');
const exportImage = document.getElementById('export-image');
const shareNote = document.getElementById('share-note');
// App State
let notes = JSON.parse(localStorage.getItem('sticky-notes')) || [];
let currentNoteId = null;
let currentPageIndex = 0;
let isRuled = false;
let isHandwriting = false;
let currentColor = 'yellow';
let isDrawing = false;
let lastX = 0;
let lastY = 0;
// Initialize the app
function init() {
renderNotes();
updateEmptyState();
// Event Listeners
newNoteBtn.addEventListener('click', createNewNote);
closeEditor.addEventListener('click', closeNoteEditor);
colorBtn.addEventListener('click', toggleColorPicker);
ruledBtn.addEventListener('click', toggleRuledLines);
handwritingBtn.addEventListener('click', toggleHandwriting);
addPageBtn.addEventListener('click', addNewPage);
exportBtn.addEventListener('click', showExportModal);
deleteBtn.addEventListener('click', deleteCurrentNote);
prevPage.addEventListener('click', goToPrevPage);
nextPage.addEventListener('click', goToNextPage);
closeExport.addEventListener('click', closeExportModal);
exportText.addEventListener('click', exportAsText);
exportImage.addEventListener('click', exportAsImage);
shareNote.addEventListener('click', shareCurrentNote);
// Close color picker when clicking outside
document.addEventListener('click', function(e) {
if (!colorPicker.contains(e.target) && e.target !== colorBtn) {
colorPicker.classList.add('hidden');
}
});
// Add event listeners to color picker buttons
document.querySelectorAll('#color-picker button').forEach(btn => {
btn.addEventListener('click', function() {
changeNoteColor(this.dataset.color);
});
});
}
// Render all notes
function renderNotes() {
notesContainer.innerHTML = '';
notes.forEach(note => {
const noteEl = document.createElement('div');
noteEl.className = `note note-${note.color || 'yellow'} rounded-xl p-5 cursor-pointer relative`;
noteEl.innerHTML = `
<h3 class="font-semibold mb-2 truncate">${note.title || 'Untitled Note'}</h3>
<p class="text-gray-700 text-sm line-clamp-4">${note.pages[0]?.content || ''}</p>
<div class="absolute bottom-2 right-2 text-xs text-gray-500">
${note.pages.length > 1 ? `<i class="fas fa-copy mr-1"></i>${note.pages.length}` : ''}
</div>
`;
noteEl.addEventListener('click', () => openNoteEditor(note.id));
notesContainer.appendChild(noteEl);
});
}
// Update empty state visibility
function updateEmptyState() {
emptyState.style.display = notes.length === 0 ? 'block' : 'none';
}
// Create a new note
function createNewNote() {
const newNote = {
id: Date.now().toString(),
title: 'Untitled Note',
color: 'yellow',
pages: [{ content: '' }],
createdAt: new Date().toISOString()
};
notes.unshift(newNote);
saveNotes();
renderNotes();
updateEmptyState();
openNoteEditor(newNote.id);
}
// Open note editor
function openNoteEditor(noteId) {
const note = notes.find(n => n.id === noteId);
if (!note) return;
currentNoteId = noteId;
currentColor = note.color;
isRuled = false;
isHandwriting = false;
currentPageIndex = 0;
// Update editor appearance
const editorNote = noteEditor.querySelector('.note');
editorNote.className = `note note-${note.color} rounded-xl w-full max-w-2xl h-96 flex flex-col overflow-hidden shadow-xl`;
// Load pages
pagesContainer.innerHTML = '';
note.pages.forEach((page, index) => {
addPageToEditor(page.content, index);
});
// Update page navigation
updatePageNavigation(note.pages.length);
// Show editor
noteEditor.classList.remove('hidden');
}
// Add page to editor
function addPageToEditor(content, index) {
const pageEl = document.createElement('div');
pageEl.className = `absolute top-0 left-0 w-full h-full p-5 ${isRuled ? 'ruled-lines' : ''} ${index === currentPageIndex ? 'block' : 'hidden'}`;
pageEl.dataset.index = index;
if (isHandwriting) {
const canvas = document.createElement('canvas');
canvas.className = 'handwriting-canvas absolute top-0 left-0 w-full h-full';
canvas.width = pageEl.offsetWidth;
canvas.height = pageEl.offsetHeight;
const ctx = canvas.getContext('2d');
ctx.lineWidth = 2;
ctx.lineCap = 'round';
ctx.strokeStyle = '#333';
// Drawing functionality
canvas.addEventListener('mousedown', startDrawing);
canvas.addEventListener('mousemove', draw);
canvas.addEventListener('mouseup', stopDrawing);
canvas.addEventListener('mouseout', stopDrawing);
// Touch support
canvas.addEventListener('touchstart', handleTouchStart);
canvas.addEventListener('touchmove', handleTouchMove);
canvas.addEventListener('touchend', stopDrawing);
pageEl.appendChild(canvas);
} else {
const textarea = document.createElement('textarea');
textarea.className = 'w-full h-full bg-transparent resize-none outline-none';
textarea.value = content || '';
textarea.placeholder = 'Start writing...';
textarea.addEventListener('input', () => {
saveCurrentPage(textarea.value);
});
pageEl.appendChild(textarea);
}
pagesContainer.appendChild(pageEl);
}
// Drawing functions
function startDrawing(e) {
isDrawing = true;
const canvas = e.target;
const rect = canvas.getBoundingClientRect();
lastX = e.clientX - rect.left;
lastY = e.clientY - rect.top;
}
function draw(e) {
if (!isDrawing) return;
const canvas = e.target;
const ctx = canvas.getContext('2d');
const rect = canvas.getBoundingClientRect();
const currentX = e.clientX - rect.left;
const currentY = e.clientY - rect.top;
ctx.beginPath();
ctx.moveTo(lastX, lastY);
ctx.lineTo(currentX, currentY);
ctx.stroke();
lastX = currentX;
lastY = currentY;
}
function stopDrawing() {
isDrawing = false;
}
// Touch support for drawing
function handleTouchStart(e) {
e.preventDefault();
const touch = e.touches[0];
const mouseEvent = new MouseEvent('mousedown', {
clientX: touch.clientX,
clientY: touch.clientY
});
e.target.dispatchEvent(mouseEvent);
}
function handleTouchMove(e) {
e.preventDefault();
const touch = e.touches[0];
const mouseEvent = new MouseEvent('mousemove', {
clientX: touch.clientX,
clientY: touch.clientY
});
e.target.dispatchEvent(mouseEvent);
}
// Update page navigation
function updatePageNavigation(pageCount) {
pageIndicators.innerHTML = '';
if (pageCount > 1) {
pageNav.classList.remove('hidden');
for (let i = 0; i < pageCount; i++) {
const indicator = document.createElement('button');
indicator.className = `page-indicator w-2 h-2 rounded-full ${i === currentPageIndex ? 'bg-gray-700' : 'bg-gray-300'}`;
indicator.dataset.index = i;
indicator.addEventListener('click', () => goToPage(i));
pageIndicators.appendChild(indicator);
}
} else {
pageNav.classList.add('hidden');
}
}
// Navigate between pages
function goToPage(index) {
const pages = document.querySelectorAll('#pages-container > div');
pages.forEach(page => {
page.classList.add('hidden');
});
pages[index].classList.remove('hidden');
currentPageIndex = index;
// Update indicators
document.querySelectorAll('.page-indicator').forEach((indicator, i) => {
indicator.className = `page-indicator w-2 h-2 rounded-full ${i === index ? 'bg-gray-700' : 'bg-gray-300'}`;
});
}
function goToPrevPage() {
if (currentPageIndex > 0) {
goToPage(currentPageIndex - 1);
}
}
function goToNextPage() {
const note = notes.find(n => n.id === currentNoteId);
if (note && currentPageIndex < note.pages.length - 1) {
goToPage(currentPageIndex + 1);
}
}
// Add new page
function addNewPage() {
const note = notes.find(n => n.id === currentNoteId);
if (!note) return;
note.pages.push({ content: '' });
saveNotes();
addPageToEditor('', note.pages.length - 1);
updatePageNavigation(note.pages.length);
goToPage(note.pages.length - 1);
}
// Save current page content
function saveCurrentPage(content) {
const note = notes.find(n => n.id === currentNoteId);
if (!note) return;
note.pages[currentPageIndex].content = content;
// Update title if it's the first page
if (currentPageIndex === 0) {
const firstLine = content.split('\n')[0];
if (firstLine && firstLine.trim().length > 0) {
note.title = firstLine.trim().substring(0, 30);
} else {
note.title = 'Untitled Note';
}
}
saveNotes();
renderNotes();
}
// Toggle color picker
function toggleColorPicker() {
colorPicker.classList.toggle('hidden');
}
// Change note color
function changeNoteColor(color) {
currentColor = color;
const editorNote = noteEditor.querySelector('.note');
editorNote.className = `note note-${color} rounded-xl w-full max-w-2xl h-96 flex flex-col overflow-hidden shadow-xl`;
const note = notes.find(n => n.id === currentNoteId);
if (note) {
note.color = color;
saveNotes();
renderNotes();
}
colorPicker.classList.add('hidden');
}
// Toggle ruled lines
function toggleRuledLines() {
isRuled = !isRuled;
ruledBtn.className = `p-2 rounded-full ${isRuled ? 'bg-gray-100 text-blue-500' : 'hover:bg-gray-100 text-gray-700'}`;
const pages = document.querySelectorAll('#pages-container > div');
pages.forEach(page => {
if (isRuled) {
page.classList.add('ruled-lines');
} else {
page.classList.remove('ruled-lines');
}
});
}
// Toggle handwriting mode
function toggleHandwriting() {
isHandwriting = !isHandwriting;
handwritingBtn.className = `p-2 rounded-full ${isHandwriting ? 'bg-gray-100 text-blue-500' : 'hover:bg-gray-100 text-gray-700'}`;
// Re-render current page with the new mode
const note = notes.find(n => n.id === currentNoteId);
if (note) {
const currentContent = note.pages[currentPageIndex].content;
const currentPage = document.querySelector(`#pages-container > div[data-index="${currentPageIndex}"]`);
if (currentPage) {
currentPage.remove();
addPageToEditor(currentContent, currentPageIndex);
}
}
}
// Show export modal
function showExportModal() {
exportModal.classList.remove('hidden');
}
// Close export modal
function closeExportModal() {
exportModal.classList.add('hidden');
}
// Export as text
function exportAsText() {
const note = notes.find(n => n.id === currentNoteId);
if (!note) return;
let textContent = `${note.title}\n\n`;
note.pages.forEach((page, index) => {
textContent += `Page ${index + 1}:\n${page.content}\n\n`;
});
const blob = new Blob([textContent], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `${note.title.replace(/\s+/g, '_')}.txt`;
a.click();
URL.revokeObjectURL(url);
closeExportModal();
}
// Export as image (simplified - would need more complex canvas handling for real implementation)
function exportAsImage() {
alert('In a real implementation, this would export the note as an image. This is a simplified demo.');
closeExportModal();
}
// Share note
function shareCurrentNote() {
const note = notes.find(n => n.id === currentNoteId);
if (!note) return;
if (navigator.share) {
navigator.share({
title: note.title,
text: note.pages.map(p => p.content).join('\n\n---\n\n'),
url: window.location.href
}).catch(err => {
console.log('Error sharing:', err);
});
} else {
alert('Web Share API not supported in your browser. Try exporting instead.');
}
closeExportModal();
}
// Delete current note
function deleteCurrentNote() {
if (confirm('Are you sure you want to delete this note?')) {
notes = notes.filter(n => n.id !== currentNoteId);
saveNotes();
renderNotes();
updateEmptyState();
closeNoteEditor();
}
}
// Close note editor
function closeNoteEditor() {
noteEditor.classList.add('hidden');
currentNoteId = null;
}
// Save notes to localStorage
function saveNotes() {
localStorage.setItem('sticky-notes', JSON.stringify(notes));
}
// Initialize the app
init();
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=afarouk79/sticky-notes-plus" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>