PageSourceSearch

https://fp-gesundbewegen.de/wp-content/plugins/fp-selfcheck/assets/js/bridge.js?ver=1776349633

js fp-gesundbewegen.de collected 2026-10-06 04:21:14 UTC 2,664 bytes, 69 lines download raw bytes

1(() => {
2  /**
3   * Bridge: listens to fp-selfcheck events and pre-fills Avada/Fusion form inputs.
4   * Usage: add data attributes to your form fields:
5   * - data-fp-field="name" | "email" | "phone" | "score" | "score_percent" | "details"
6   * The bridge never sends PII to OpenAI; it only writes to form fields on the page.
7   */
8
9  function toNumeric(value) {
10    if (typeof value === 'number' && Number.isFinite(value)) {
11      return value;
12    }
13    if (typeof value === 'string') {
14      const parsed = Number(value.replace(',', '.').trim());
15      return Number.isFinite(parsed) ? parsed : null;
16    }
17    return null;
18  }
19
20  function mapToFields(detail) {
21    detail = detail || {};
22    const result = detail.result || {};
23    const score = result.score || detail.score || {};
24    const meta = result.meta || detail.meta || {};
25    const contact = detail.contact || {};
26    const answers = detail.answers || {};
27    const scoreValue = toNumeric(score.score ?? score.value);
28    const scorePercent = toNumeric(score.score_percent ?? score.percent);
29    const scoreMax = toNumeric(score.score_max ?? score.max);
30    const scoreBand = `${meta.score_band || score.score_band || score.band || ''}`.trim();
31    return {
32      name: contact.name || '',
33      email: contact.email || '',
34      phone: contact.phone || '',
35      insurance_status: contact.insurance_status || '',
36      insurance_name: contact.insurance_name || '',
37      score: scoreValue !== null ? scoreValue : '',
38      score_value: scoreValue !== null ? scoreValue : '',
39      score_percent: scorePercent !== null ? scorePercent : '',
40      score_max: scoreMax !== null ? scoreMax : '',
41      score_band: scoreBand,
42      details: JSON.stringify(answers),
43      summary: result.text || '',
44    };
45  }
46
47  function fillForm(detail) {
48    const data = mapToFields(detail);
49    const inputs = document.querySelectorAll('[data-fp-field]');
50    const scoreKeys = new Set(['score', 'score_value', 'score_percent', 'score_max', 'score_band']);
51    inputs.forEach((input) => {
52      const key = input.getAttribute('data-fp-field');
53      if (!Object.prototype.hasOwnProperty.call(data, key)) return;
54      if (scoreKeys.has(key) && data[key] === '') return;
55      input.value = data[key];
56      input.dispatchEvent(new Event('input', { bubbles: true }));
57      input.dispatchEvent(new Event('change', { bubbles: true }));
58    });
59  }
60
61  document.addEventListener('fp-selfcheck-ready', (evt) => {
62    fillForm(evt.detail);
63  });
64
65  // On change, keep score fields updated even before final submit.
66  document.addEventListener('fp-selfcheck-change', (evt) => {
67    fillForm(evt.detail || {});
68  });
69})();

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.