PageSourceSearch

https://ispeedtolead.com/wp-content/uploads/custom-css-js/3111.js?v=8644

js ispeedtolead.com collected 2026-10-02 06:47:37 UTC 7,525 bytes, 242 lines download raw bytes

1/******* Do not edit this file *******
2Simple Custom CSS and JS - by Silkypress.com
3Saved: Dec 19 2025 | 07:11:14 */
4// ============================================
5// Sign In / Create Account Modal Logic
6// ============================================
7
8document.addEventListener('DOMContentLoaded', function() {
9  
10  console.log('=== Auth Modal Script Loaded ===');
11  
12  // URL configuration for different auth flows
13  const authUrls = {
14    'sign-in': {
15      'seller-leads': 'https://app.ispeedtolead.com/auth/login',
16      'roofing-leads': 'https://roofing.ispeedtolead.com/auth/login'
17    },
18    'create-account': {
19      'seller-leads': 'https://app.ispeedtolead.com/auth/signup',
20      'roofing-leads': 'https://roofing.ispeedtolead.com/auth/signup'
21    }
22  };
23
24  // Track current auth mode (sign-in or create-account)
25  let currentAuthMode = null;
26
27  // Cache DOM elements
28  const signInBtn = document.querySelector('a[data-modal-open="sign-in-account-modal"]');
29  const createAccountBtn = document.querySelector('a[data-modal-open="create-account-modal"]');
30  const nicheModal = document.querySelector('.select-niche-button-modal');
31  const nicheModalText = document.querySelector('.select-niche-button-modal__text');
32  const sellerLeadsBtn = document.getElementById('seller-leads-modal-button');
33  const roofingLeadsBtn = document.getElementById('roofing-leads-modal-button');
34
35  // Debug: Check if elements exist
36  console.log('signInBtn:', signInBtn);
37  console.log('createAccountBtn:', createAccountBtn);
38  console.log('nicheModal:', nicheModal);
39  console.log('nicheModalText:', nicheModalText);
40  console.log('sellerLeadsBtn:', sellerLeadsBtn);
41  console.log('roofingLeadsBtn:', roofingLeadsBtn);
42
43  // Modal text configuration
44  const modalTexts = {
45    'sign-in': 'To sign in, select your lead type:',
46    'create-account': 'To create account, select your lead type:'
47  };
48
49  /**
50   * Show the niche selection modal
51   */
52  function showNicheModal(authMode) {
53    console.log('showNicheModal called with:', authMode);
54    if (!nicheModal) {
55      console.log('ERROR: nicheModal not found!');
56      return;
57    }
58    
59    currentAuthMode = authMode;
60    
61    if (nicheModalText && modalTexts[authMode]) {
62      nicheModalText.textContent = modalTexts[authMode];
63    }
64    
65    if (authMode === 'sign-in') {
66      nicheModal.style.left = '0';
67      nicheModal.style.right = 'auto';
68    } else if (authMode === 'create-account') {
69      nicheModal.style.right = '0';
70      nicheModal.style.left = 'auto';
71    }
72    
73    nicheModal.classList.add('active');
74    console.log('Modal should be visible now');
75  }
76
77  /**
78   * Hide the niche selection modal
79   */
80  function hideNicheModal() {
81    console.log('hideNicheModal called');
82    if (!nicheModal) return;
83    
84    nicheModal.classList.remove('active');
85    currentAuthMode = null;
86  }
87
88  /**
89   * Toggle the niche selection modal
90   */
91  function toggleNicheModal(authMode) {
92    console.log('toggleNicheModal called with:', authMode);
93    if (!nicheModal) {
94      console.log('ERROR: nicheModal not found!');
95      return;
96    }
97    
98    if (nicheModal.classList.contains('active') && currentAuthMode === authMode) {
99      hideNicheModal();
100    } else {
101      showNicheModal(authMode);
102    }
103  }
104
105  /**
106   * Build URL with UTM parameters and promocode
107   */
108  function buildUrlWithParams(baseUrl) {
109    try {
110      const url = new URL(baseUrl);
111      const urlParams = new URLSearchParams(url.search);
112      
113      const storedQuery = localStorage.getItem('utm_query') || '';
114      
115      if (storedQuery) {
116        const inputParams = new URLSearchParams(storedQuery);
117        const utmKeys = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'gclid', 'fbclid', 'yclid', 'msclkid'];
118        
119        for (const [key, val] of inputParams) {
120          if (utmKeys.includes(key) && val.trim() && !urlParams.has(key)) {
121            urlParams.set(key, val);
122          }
123        }
124      }
125      
126      // Check if Cookies library exists
127      if (typeof Cookies !== 'undefined') {
128        const istlAff = Cookies.get('istl-code-affwwssww');
129        if (istlAff && istlAff !== 'wp-content/themes/i-speed-to-lead/assets/libs/swiper-bundle.min.js.map') {
130          urlParams.set('code', istlAff);
131        }
132      }
133      
134      url.search = urlParams.toString();
135      return url.toString();
136    } catch (err) {
137      console.log('buildUrlWithParams error:', err);
138      return baseUrl;
139    }
140  }
141
142  /**
143   * Navigate to the appropriate URL
144   */
145  function navigateToAuth(leadType, authMode) {
146    const mode = authMode || currentAuthMode;
147    console.log('navigateToAuth:', { leadType, mode });
148    
149    if (!mode || !authUrls[mode]) {
150      console.log('Mode invalid');
151      return;
152    }
153    
154    const baseUrl = authUrls[mode][leadType];
155    
156    if (baseUrl) {
157      const targetUrl = buildUrlWithParams(baseUrl);
158      console.log('Navigating to:', targetUrl);
159      
160      if (typeof Cookies !== 'undefined') {
161        Cookies.remove('istl-code-affwwssww');
162      }
163      localStorage.removeItem('utm_query');
164      
165      window.location.href = targetUrl;
166    }
167  }
168
169  // Event listeners
170  if (signInBtn) {
171    console.log('Adding click listener to signInBtn');
172    signInBtn.addEventListener('click', function(e) {
173      console.log('Sign In clicked!');
174      e.preventDefault();
175      e.stopPropagation();
176      toggleNicheModal('sign-in');
177    });
178  } else {
179    console.log('WARNING: signInBtn not found!');
180  }
181
182  if (createAccountBtn) {
183    console.log('Adding click listener to createAccountBtn');
184    createAccountBtn.addEventListener('click', function(e) {
185      console.log('Create Account clicked!');
186      e.preventDefault();
187      e.stopPropagation();
188      toggleNicheModal('create-account');
189    });
190  } else {
191    console.log('WARNING: createAccountBtn not found!');
192  }
193
194  if (sellerLeadsBtn) {
195    console.log('Adding click listener to sellerLeadsBtn');
196    sellerLeadsBtn.addEventListener('click', function(e) {
197      console.log('Seller Leads clicked!');
198      e.stopPropagation();
199      const authMode = currentAuthMode;
200      hideNicheModal();
201      navigateToAuth('seller-leads', authMode);
202    });
203  } else {
204    console.log('WARNING: sellerLeadsBtn not found!');
205  }
206
207  if (roofingLeadsBtn) {
208    console.log('Adding click listener to roofingLeadsBtn');
209    roofingLeadsBtn.addEventListener('click', function(e) {
210      console.log('Roofing Leads clicked!');
211      e.stopPropagation();
212      const authMode = currentAuthMode;
213      hideNicheModal();
214      navigateToAuth('roofing-leads', authMode);
215    });
216  } else {
217    console.log('WARNING: roofingLeadsBtn not found!');
218  }
219
220  // Close modal when clicking outside
221  document.addEventListener('click', function(e) {
222    if (!nicheModal) return;
223    
224    const target = e.target;
225    const isButton = target.closest('.create-account') !== null;
226    const isModal = target.closest('.select-niche-button-modal') !== null;
227    
228    if (!isButton && !isModal) {
229      hideNicheModal();
230    }
231  });
232
233  // Close modal on Escape key
234  document.addEventListener('keydown', function(e) {
235    if (e.key === 'Escape') {
236      hideNicheModal();
237    }
238  });
239
240  console.log('=== Auth Modal Script Initialization Complete ===');
241
242});

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.