// Shared "Button actions" card (models.FrameButtonAction, // _widget_button_fields.html) -- present on every widget type's dialog // that supports any actions at all (the card renders nothing for // tasks/static/text/battery, whose ACTIONS is empty), so this is one // shared init function each widget_dialog_.js's initDialog() // calls, rather than N copies of the same save wiring -- same pattern as // widget_dialog_border.js. Not a page-load script by itself -- // frame_layout.js loads it unconditionally (like every other // widget_dialog_*.js) since which dialog is open varies. function initButtonActionFields() { const form = document.getElementById('button-actions-form'); if (!form) return; // this widget type has no actions -- card didn't render form.addEventListener('submit', async (e) => { e.preventDefault(); const body = JSON.stringify({ next_button_action: document.getElementById('next_button_action').value, back_button_action: document.getElementById('back_button_action').value, }); try { const resp = await fetch(`${window.FRAME_API}/button-actions`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body, }); if (!resp.ok) throw new Error(await apiError(resp)); showStatus(true, 'Button actions saved.'); } catch (err) { showStatus(false, err.message); } }); }