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: [], defaults: {}, selectedTextIndex: 0}" x-effect=" const font = settings[selectedTextIndex]?.font || defaults.font || 'Input Sans'; document.documentElement.style.setProperty('--text-area-font', font); const fontSize = settings[selectedTextIndex]?.fontSize || defaults.fontSize || '16px'; document.documentElement.style.setProperty('--text-area-font-size', fontSize); const fontWeight = settings[selectedTextIndex]?.fontWeight || defaults.fontWeight || '400'; document.documentElement.style.setProperty('--text-area-font-weight', fontWeight); const lineHeight = settings[selectedTextIndex]?.lineHeight || defaults.lineHeight || '1.4'; document.documentElement.style.setProperty('--text-area-line-height', lineHeight); if (defaults.fullWidth) { document.documentElement.style.setProperty('--app-max-width', 'none'); } else { document.documentElement.style.removeProperty('--app-max-width'); } " 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 => { if (Array.isArray(data)) { // if the data is an array, it's the old format, so set it as editor_settings settings = data; defaults = {}; } else { // otherwise, it's the new format with editor_settings and defaults settings = data.editor_settings || []; defaults = data.defaults || {}; } }); // 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
Default Settings
Full Width
Font
Font Size
Font Weight
Line Height
$refs.global_settings.close()) .catch(error => { console.error('Error:', error) error = 'Failed to save settings' }) ">Save
Cancel