Commit ca6e40db authored by vertighel's avatar vertighel
Browse files

Fase 5 JS punto 1: actions.js/webcam.js a ES modules



- actions.js, webcam.js: import { showToast } from './ui.js' invece
  del global, rimosse le 5 guardie typeof showToast === 'function'.
- 4 <script> aggiornati a type="module" (base.html, init.html,
  webcam.html, control.html).
- Con questi due erano gli ultimi due script non-modulo di pagina
  (esclusi i bundle vendor) -- window.showToast in ui.js era rimasto
  solo per loro, ora morto e rimosso (verificato zero consumer
  rimasti). window.noctuaUpdateFromRest resta, tocca all'item 8
  (serve rimuovere anche la funzione, non solo lo shim).
- Verificato con node --check sui file JS toccati e parsing Jinja
  sulle pagine toccate.
- PLAN.md aggiornato.

Co-Authored-By: default avatarClaude Sonnet 5 <noreply@anthropic.com>
parent be2c75f1
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -438,8 +438,24 @@ deferred to its own pass, per the blast-radius warning already in

### 5. JavaScript

- [ ] Convert `actions.js`/`webcam.js` to ES modules, import
      `showToast` directly instead of the global.
Working point by point per the user's request, checking in after each
(not batching the whole phase like phases 3/4).

- [x] Convert `actions.js`/`webcam.js` to ES modules, import
      `showToast` directly instead of the global. Added `import {
      showToast } from './ui.js'` to both, dropped the 5 `typeof
      showToast === 'function'` guards (3 in `actions.js`, 2 in
      `webcam.js`), added `type="module"` to their 4 `<script>` tags
      (`base.html`, `init.html`, `webcam.html`, `control.html`).
      With these two converted, no plain non-module page script is
      left (only the vendor bundles, which stay as-is). As a direct
      consequence, `ui.js`'s `window.showToast = showToast` shim
      became dead (confirmed zero remaining consumers — grepped every
      `.js` file and every page's inline markup) and was removed;
      `window.noctuaUpdateFromRest` stays for now, its own removal is
      item 8 below (needs the function itself deleted too, not just
      the shim). Verified with `node --check` on all 3 touched JS
      files and a Jinja parse check on all 4 touched HTML pages.
- [ ] Extract `withBusyButton(btn, fn)` helper (dedupe the 3 existing
      copies), apply to the confirmed-unprotected click/change
      handlers (Expose, Loop toggle, stage relative, select-universal,
+1 −2
Original line number Diff line number Diff line
@@ -208,8 +208,7 @@
    <script type="module" src="{{ url_for('web.static', filename='js/dependency-guard.js') }}"></script>
    <script type="module" src="{{ url_for('web.static', filename='js/toggle.js') }}"></script>

    <!-- Gli altri script di pagina tradizionali -->
    <script src="{{ url_for('web.static', filename='js/actions.js') }}"></script>
    <script type="module" src="{{ url_for('web.static', filename='js/actions.js') }}"></script>

    {% block scripts %}{% endblock %}
</body>
+1 −1
Original line number Diff line number Diff line
@@ -350,7 +350,7 @@
        })
        .catch(err => console.warn('cameras fetch failed:', err));
    </script>
    <script src="{{ url_for('web.static', filename='js/webcam.js') }}"></script>
    <script type="module" src="{{ url_for('web.static', filename='js/webcam.js') }}"></script>
    <script>window.SYNOPTIC_SVG_URL = "{{ url_for('web.static', filename='img/synoptic.svg') }}";</script>
    <script type="module" src="{{ url_for('web.static', filename='js/synoptic.js') }}"></script>
{% endblock %}
+1 −1
Original line number Diff line number Diff line
@@ -301,7 +301,7 @@
{% endblock %}

{% block scripts %}
<script src="{{ url_for('web.static', filename='js/webcam.js') }}"></script>
<script type="module" src="{{ url_for('web.static', filename='js/webcam.js') }}"></script>
<script>window.SYNOPTIC_SVG_URL = "{{ url_for('web.static', filename='img/synoptic.svg') }}";</script>
<script type="module" src="{{ url_for('web.static', filename='js/synoptic.js') }}"></script>
{% endblock %}
+1 −1
Original line number Diff line number Diff line
@@ -10,5 +10,5 @@
{% endblock %}

{% block scripts %}
<script src="{{ url_for('web.static', filename='js/webcam.js') }}"></script>
<script type="module" src="{{ url_for('web.static', filename='js/webcam.js') }}"></script>
{% endblock %}
Loading