Insights
Quotes
Stats
Quote Content
Remember too that your time is your one finite resource, and when you say “yes” to one thing you are inevitably saying “no” to another.
Author Name
Tags
Andy Grove
Intel
High Output Management
Time Management
Management
Add Tags
Press Enter or comma to add tags
Cancel
function handleTagInput(event) { if (event.key === 'Enter' || event.key === ',') { event.preventDefault(); const input = event.target; const tags = input.value.split(',').map(tag => tag.trim()).filter(tag => tag.length > 0); if (tags.length > 0) { updateTags(tags); input.value = ''; } } } function removeTag(button) { const tag = button.dataset.tag; updateTags([], [tag]); } function updateTags(tagsToAdd = [], tagsToRemove = []) { const currentTags = Array.from(document.querySelectorAll('#tags-container span')) .map(span => span.textContent.trim()) .filter(tag => !tagsToRemove.includes(tag)); const newTags = [...new Set([...currentTags, ...tagsToAdd])]; fetch('/quotes/2/update_tags', { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content }, body: JSON.stringify({ quote: { tag_list: newTags.join(', ') } }) }) .then(response => response.json()) .then(data => { if (data.tags) { const tagsContainer = document.getElementById('tags-container'); tagsContainer.innerHTML = data.tags.map(tag => `
${tag.name}
` ).join(''); } }) .catch(error => console.error('Error:', error)); }