PageSourceSearch

https://notify-me.io/js/form-handler.js

js notify-me.io collected 2026-10-02 06:20:32 UTC 3,169 bytes, 79 lines download raw bytes

1(function () {
2  var GOOGLE_SCRIPT_URL = 'https://script.google.com/macros/s/AKfycbzwIxu9aS5QCzpHYmYUF2lgCkP7aNzTIjohgLPR61_J4MRWmUwq02WH9Oik6pUya_9K/exec';
3
4  window.__FORM_HANDLER_URL = GOOGLE_SCRIPT_URL !== 'PASTE_YOUR_GOOGLE_APPS_SCRIPT_URL_HERE' ? GOOGLE_SCRIPT_URL : null;
5
6  if (!window.__FORM_HANDLER_URL) {
7    console.warn('[form-handler] Google Apps Script URL not configured. Forms will not submit.');
8    return;
9  }
10
11  document.addEventListener('DOMContentLoaded', function () {
12    var forms = document.querySelectorAll('form[data-wf-page-id], form[data-name]');
13
14    forms.forEach(function (form) {
15      // ⛔ LEGACY PATH — Google Sheets. Brevo is the only approved form
16      // backend (see CLAUDE.md → Forms); this file is deleted once every
17      // form is migrated. Any form already on Brevo stands this handler down,
18      // otherwise it would double-submit to both backends.
19      if (form.hasAttribute('data-brevo-form')) return;
20      if (form.id === 'sib-form') return;
21      if (form.id === 'agency-partner-form') return;
22      if (form.id === 'partner-application-form') return;
23      if (form.getAttribute('action') === '/.wf_auth') return;
24
25      form.removeAttribute('data-wf-page-id');
26      form.removeAttribute('data-wf-element-id');
27
28      form.addEventListener('submit', function (e) {
29        e.preventDefault();
30        e.stopPropagation();
31
32        var submitBtn = form.querySelector('[type="submit"]');
33        var originalText = submitBtn ? submitBtn.value : '';
34        var waitText = submitBtn ? (submitBtn.getAttribute('data-wait') || 'Submitting...') : '';
35        if (submitBtn) {
36          submitBtn.value = waitText;
37          submitBtn.disabled = true;
38        }
39
40        var formData = new FormData(form);
41        var data = {
42          _form_name: form.getAttribute('data-form-label') || form.getAttribute('data-name') || form.name || form.id || 'Unknown Form',
43          _page_url: window.location.href,
44          _submitted_at: new Date().toISOString()
45        };
46
47        formData.forEach(function (value, key) {
48          if (data[key]) {
49            data[key] = data[key] + ', ' + value;
50          } else {
51            data[key] = value;
52          }
53        });
54
55        fetch(GOOGLE_SCRIPT_URL, {
56          method: 'POST',
57          mode: 'no-cors',
58          headers: { 'Content-Type': 'application/json' },
59          body: JSON.stringify(data)
60        })
61          .then(function () {
62            var successEl = form.parentElement.querySelector('.w-form-done, .success-message');
63            var errorEl = form.parentElement.querySelector('.w-form-fail, .error-message');
64            form.style.display = 'none';
65            if (successEl) successEl.style.display = 'block';
66            if (errorEl) errorEl.style.display = 'none';
67          })
68          .catch(function () {
69            var errorEl = form.parentElement.querySelector('.w-form-fail, .error-message');
70            if (errorEl) errorEl.style.display = 'block';
71            if (submitBtn) {
72              submitBtn.value = originalText;
73              submitBtn.disabled = false;
74            }
75          });
76      });
77    });
78  });
79})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.