PageSourceSearch

https://www.talkable.com/wp-content/plugins/talkable-attribution/a…/js/talkable-attribution.js?ver=1790335102

js talkable.com collected 2026-10-01 10:35:54 UTC 3,319 bytes, 122 lines download raw bytes

1(function (window, document) {
2  'use strict';
3
4  var namespace = window.TalkableAttribution;
5
6  if (!namespace || !namespace.capture || !namespace.gravityForms || !namespace.consent) {
7    return;
8  }
9
10  var settings = namespace.settings || {};
11  var runtime = settings.runtime || {};
12  var maxRetries = runtime.consent_retry_count || 8;
13  var retryDelay = runtime.consent_retry_delay || 500;
14
15  function getAttributionConsentStatus() {
16    if (typeof namespace.consent.getAttributionConsentStatus === 'function') {
17      return namespace.consent.getAttributionConsentStatus();
18    }
19
20    return {
21      state: 'default_allowed',
22      initializing: false
23    };
24  }
25
26  function syncAttribution() {
27    var consentStatus = getAttributionConsentStatus();
28    var record = namespace.capture.captureCurrentVisit();
29
30    namespace.gravityForms.populateAllForms(record, true);
31    namespace.state.lastConsentSyncState = consentStatus.state;
32
33    return consentStatus;
34  }
35
36  function syncAttributionForConsentChange() {
37    var consentStatus = getAttributionConsentStatus();
38
39    if (namespace.state.lastConsentSyncState === consentStatus.state) {
40      return;
41    }
42
43    consentStatus = syncAttribution();
44    maybeRetryConsent(consentStatus);
45  }
46
47  function clearRetryTimer() {
48    if (!namespace.state.consentRetryTimer) {
49      return;
50    }
51
52    window.clearTimeout(namespace.state.consentRetryTimer);
53    namespace.state.consentRetryTimer = null;
54  }
55
56  function maybeRetryConsent(consentStatus) {
57    var currentStatus = consentStatus || getAttributionConsentStatus();
58
59    clearRetryTimer();
60
61    if (currentStatus.state !== 'initializing') {
62      return;
63    }
64
65    if (namespace.state.consentRetryCount >= maxRetries) {
66      return;
67    }
68
69    namespace.state.consentRetryTimer = window.setTimeout(function () {
70      var nextStatus;
71
72      namespace.state.consentRetryCount += 1;
73      nextStatus = syncAttribution();
74      maybeRetryConsent(nextStatus);
75    }, retryDelay);
76  }
77
78  function bindConsentChangeHandling() {
79    if (namespace.state.consentChangeHandlingBound) {
80      if (typeof namespace.consent.ensureMarketingConsentChangeObserver === 'function') {
81        namespace.consent.ensureMarketingConsentChangeObserver();
82      }
83
84      return;
85    }
86
87    namespace.state.consentChangeHandlingBound = true;
88
89    if (typeof namespace.consent.onMarketingConsentChange === 'function') {
90      namespace.consent.onMarketingConsentChange(syncAttributionForConsentChange);
91    } else if (typeof namespace.consent.ensureMarketingConsentChangeObserver === 'function') {
92      namespace.consent.ensureMarketingConsentChangeObserver();
93    }
94  }
95
96  function init() {
97    var consentStatus;
98
99    bindConsentChangeHandling();
100
101    if (namespace.state.initialized) {
102      consentStatus = syncAttribution();
103      maybeRetryConsent(consentStatus);
104      return;
105    }
106
107    namespace.state.initialized = true;
108    namespace.gravityForms.init();
109    consentStatus = syncAttribution();
110    maybeRetryConsent(consentStatus);
111    window.addEventListener('load', function () {
112      var loadStatus = syncAttribution();
113      maybeRetryConsent(loadStatus);
114    });
115  }
116
117  if (document.readyState === 'loading') {
118    document.addEventListener('DOMContentLoaded', init);
119  } else {
120    init();
121  }
122})(window, document);

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.