Password
{ fetch(`text.php?text=${i + 1}`, { method: 'POST', headers: { 'x-scratchpad-pw': pw }, body: JSON.stringify({text}) }) .then(resp => { if (!resp.ok) { console.error('Failed to save text'); error = 'Failed to save text'; } }) .catch(error => { console.error('Error:', error); error = 'Failed to save text'; }); }); } " class="scratchpad" x-data="{texts: [], settings: [], selectedTextIndex: 0}" x-effect=" const font = settings[selectedTextIndex]?.font ?? 'Input Sans'; document.documentElement.style.setProperty('--text-area-font', font); const fontSize = settings[selectedTextIndex]?.fontSize ?? '16px'; document.documentElement.style.setProperty('--text-area-font-size', fontSize); const fontWeight = settings[selectedTextIndex]?.fontWeight ?? '400'; document.documentElement.style.setProperty('--text-area-font-weight', fontWeight); const lineHeight = settings[selectedTextIndex]?.lineHeight ?? '1.4'; document.documentElement.style.setProperty('--text-area-line-height', lineHeight); " x-init=" // get all texts fetch('text.php', { headers: { 'x-scratchpad-pw': pw } }) .then(response => response.json()) .then( data => texts = data ); // get settings fetch('text.php?settings=1', { headers: { 'x-scratchpad-pw': pw } }) .then(response => response.json()) .then(data => settings = data); // watch for tab change and refetch text $watch('selectedTextIndex', () => { const currentIndex = selectedTextIndex; fetch(`text.php?text=${currentIndex + 1}`, { headers: { 'x-scratchpad-pw': pw } }) .then(response => response.text()) .then(data => texts[currentIndex] = data); }) " >
{ if (!resp.ok) { console.error('Failed to save text'); error = 'Failed to save text'; } $dispatch('show-saved'); }) .catch(error => { console.error('Error:', error); error = 'Failed to save text'; }) " >
Saved
Font
Font Size
Font Weight
Line Height
$refs.settings.close()) .catch(error => { console.error('Error:', error) error = 'Failed to save settings' }) ">Save
Cancel