PageSourceSearch

https://www.heraldstandard.com/wp-content/plugins/ogden-paywall-sc/js/header_nav_login_links.js?v=2&ver=1.0

js heraldstandard.com collected 2026-09-24 09:39:48 UTC 50,811 bytes, 912 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2    /* log paywall settings for debugging */
3
4
5    /* set subscriber cookie based on login status */
6    function setSubscriberCookie(isLoggedIn) {
7        const value = isLoggedIn ? '1' : '0';
8        /* create domain (e.g., .lakeplacidnews.com for subdomains) to include subdomains */
9        const hostname = window.location.hostname;
10        const domainParts = hostname.split('.');
11        const domain = domainParts.length > 2 ? `.${domainParts.slice(-2).join('.')}` : hostname;
12        document.cookie = `subscriber=${value}; path=/; domain=${domain}; max-age=86400; SameSite=Lax`;
13    }
14
15
16        /* session management */
17    const isAuthenticated = () => {
18        /* get the current session (if it exists) */
19        const session = localStorage.getItem('paywallSession');
20        /* if session does not exist - return */
21        if (!session) {
22            setSubscriberCookie(false);
23            return false; 
24        } 
25        try {
26            /* calculate how long the session has been alive */
27            const { timestamp } = JSON.parse(session);
28            const now = new Date().getTime();
29            /* check to see if the session is less than 30 days old */
30            const sessionValid = now <= timestamp + (30 * 24 * 60 * 60 * 1000);
31            //console.log('Session check:', { timestamp, sessionValid });
32            return sessionValid;
33        } catch (error) {
34            console.error('Invalid session data:', error);
35            return false;
36        }
37    };
38
39    /* create paywall overlay */
40    const showPaywall = ( default_view = 'subscribe' ) => {
41        //console.log('Showing paywall overlay.');
42        /* dsable scrolling */
43
44        function printObject(o) {
45            var out = '';
46            for (var p in o) {
47                out += p + ': ' + o[p] + '\n';
48            }
49            console.log("%c" + out , "color:green");
50        }
51
52
53        /* create overlay */
54        const overlayLogin = document.createElement('div');
55        overlayLogin.id = 'login-overlay';
56        overlayLogin.style.position = 'fixed';
57        overlayLogin.style.top = '0';
58        overlayLogin.style.left = '0';
59        overlayLogin.style.width = '100%'; 
60        overlayLogin.style.height = '100%';
61        overlayLogin.style.backgroundColor = 'rgba(0, 0, 0, 0.8)';
62        overlayLogin.style.zIndex = '2147483649';
63        overlayLogin.style.display = 'flex';
64        overlayLogin.style.alignItems = 'center';
65        overlayLogin.style.justifyContent = 'center';
66        overlayLogin.style.padding = '20px';
67        overlayLogin.style.boxSizing = 'border-box';
68
69        /* create the modal content */
70        overlayLogin.innerHTML = `
71        <style>
72            .products {text-align:center; margin:0 auto; padding:0 20px 40px 20px; display:grid; grid-auto-columns:25%; grid-gap:20px; justify-content:center; grid-auto-flow:column;}
73            .products li {margin-top:20px; box-sizing:border-box; padding:20px; background:#fff; border-radius:6px; -webkit-box-shadow:0 0 7px 0 rgba(0, 0, 0, 0.25);
74                -moz-box-shadow:0 0 7px 0 rgba(0, 0, 0, 0.25); box-shadow:0 0 7px 0 rgba(0, 0, 0, 0.25);}
75            .products h2 {text-align:center; padding:10px 0; border-bottom:solid 1px #dbdbdb; margin:0 0 10px 0;}
76            .products img {width:100%; height:auto; border-radius:5px}
77            .woocommerce-product-gallery img {border-radius:5px;}
78            .woocommerce ul.product_list_widget li img {border-radius:3px;}
79            .add_to_cart_button {padding:10px 20px; margin:0 auto 10px auto; width:100%; background:#000; color:#fff; border-radius:5px;}
80            .products span.price {color:#1c7554; font-size:27px; font-weight:600; text-align:center;}
81            span.woocommerce-Price-amount {display:none}
82            .weekly_price {font-size:36px; font-weight:bold;}
83            .weekly_price:before {content:'$'; font-size:.6em; vertical-align:top; line-height:1.8em;}
84            .weekly_price:after {content:'. '; opacity:0;}
85            .per_week {color:#999; font-size:13px; font-weight:normal; line-height:13px}
86            .products h2 {font-size:20px}
87            .product-type-simple, .product-type-variable {position:relative;}
88            .best_deal {position:absolute; top:10px; background:#ea0800; color:#fff; width:100px; border-radius:3px; padding:4px 0; text-align:center; margin-left:-50px; left:50%; z-index:9999999999}
89            .add_to_cart_button {background:#ff6619; color:#fff; padding:8px 10px 8px 10px; border-radius:18px; width:140px; display:block}
90            .single_add_to_cart_button {background:#ff6619; color:#fff; padding:12px 15px 11px 15px; border-radius:18px; width:160px; margin:0 auto; display:block; border:unset; text-transform:uppercase; font-size:14px !important; font-weight:bold}
91            .products span.price {display:none !important;}
92            #ecommerce_content .screen-reader-text {display:none !important;}
93            .variations th.label {display:none}
94            .variations {display:grid; grid-template-columns:20px 1fr; grid-column-gap:7px; grid-row-gap:10px; margin-bottom:30px; width:100%;}
95            .variations tbody {grid-column:1/-1; width:100%; display:block}
96            .variations input {width:15px !important; padding:0 !important; margin:0 0 0 5px !important;}
97            .variations label {text-transform:unset !important;
97 color:#222 !important; font-size:14px !important; font-weight:normal !important; margin-right:unset !important; text-align:left}
98            .reset_variations {display:none}
99            .products img {width:100% !important; height:auto !important;}
100            .woocommerce-LoopProduct-link {pointer-events:none; cursor:default;}
101            .single_add_to_cart_button {cursor:pointer}
102            .as_low_as {color:#999; font-size:13px; font-weight:normal; margin-top:10px; line-height:13px; font-style:italic}
103            .variations {display:block; margin:20px 0}
104            .variations .value {width:100%;}
105            .variations select {width:220px; display:block; padding:6px 5px; }
106            .variations tr {width:100%; display:block}
107            .products h2 {height:80px}
108            .reset_variations {display:none !important;}
109            .variations_form {width:100%;}
110            .variations td {display:block}
111            .variations #subscription {border:solid 1px #dbdbdb; border-radius:3px; border-color:#dbdbdb; background:#fff !important;}
112            @media screen and (max-width:1300px) {
113                .variations select {width:100% !important;}
114            }
115            @media screen and (max-width:1050px) {
116                #subscriptions_wrap {height:100%; overflow:scroll;}
117                .products {grid-auto-columns:unset; grid-auto-flow:unset; grid-template-columns:1fr; justify-content:center}
118                .products li {width:100%; max-width:500px; justify-content:center; margin:0 auto;}
119            }
120            @media screen and (max-width:1050px) {
121                #overlay_login_prompt {width:100% !important;}
122            }
123            @media screen and (max-width:500px) {
124                #subscriptions_wrap {width:calc(100% - 20px) !important; padding:35px 17px 10px 17px !important;}
125                #subscription_site_logo {width:100% !important; height:auto !important;}
126            
127                #account_login {font-size:17px !important;}
128                #account_subscribe {font-size:17px !important;}
129               
130            }
131        </style>
132        <section id="subscriptions_wrap" style="max-width:1200px; width:calc(100% - 80px); margin:0 auto; background:#f2f2f2; box-sizing:border-box; padding:40px 30px 10px 30px; border-radius:8px; -webkit-box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.35); -moz-box-shadow: 0 0 9px 0 rgba(0,0,0,0.65); box-shadow: 0 0 9px 0 rgba(0, 0, 0, 0.65);">
133            <span style="float:right; margin-top:-10px; margin-right:20px;"><img id="login_overlay_close" style="cursor:pointer;" title="Close..." src="${paywallSettings.closeButton}" width="35"></span><span style="clear:both;"/>
134            <a href="/"><img id="subscription_site_logo" style="width:330px; display:block; height:auto; margin:0 auto;" src="${paywallSettings.newspaperLogo}" border="0" alt="homepage logo"></a>
135
136            <!-- login prompt -->
137            <div id="login_overlay" style="padding:30px 0; max-width:1080px; width:100%; margin:0 auto; justify-content:center">
138                <p id="account_login" style="font-size:18px; text-align:center; padding-bottom:20px">Already have an account? <a id="overlay_login_link" style="font-weight:bold; color:#106ba2; font-size:18px; cursor:pointer;">Log in</a></p>
139                <p id="account_subscribe" style="font-size:18px; text-align:center; padding-bottom:20px">Don't have an account? <a id="overlay_subscribe_link" style="font-weight:bold; color:#106ba2; font-size:18px; cursor:pointer;">Subscribe now</a></p>
140                <p style="color:#222; font-size:15px; text-align:center; padding-bottom:15px">Get award winning reporting from a source you trust</p>
141                
142                <div id="overlay_login_prompt" style="background:#fff; display:none; padding:35px 30px; border-radius:8px; width:50%; margin-left:auto; margin-right:auto; box-sizing: border-box; border:1px solid #ddd;-webkit-box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.15); -moz-box-shadow: 0 0 7px 0 rgba(0,0,0,0.15); box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.15);">
143                    <h2 style="text-align:center; text-transform:uppercase; font-size:18px; letter-spacing:1px; color:#333;padding-bottom:30px; border-bottom:dotted 1px #d6d6d6">Customer Login</h2>
144                   
145
146                    <div id="paywall-error" style="color: red; display: none;"></div>
147                    
148                    <input type="email" id="paywall-email" placeholder="Email" style="width:100%; margin-bottom:10px; padding:8px; box-sizing:border-box; border-radius:4px; border:solid 1px #d8d8d8;">
149                    <div style="position: relative; margin-bottom: 10px;">
150                        <input type="password" id="paywall-password" placeholder="Password" style="width: 100%; padding: 8px; padding-right: 80px; box-sizing: border-box; border-radius:4px; border:solid 1px #d8d8d8;">
151                        <button id="toggle-password" style="position: absolute; right: 8px; top: 50%; transform: translateY(-50%); padding: 4px 8px; font-size: 12px; background: #ddd; border: none; border-radius: 4px; cursor: pointer;"><i class="fas fa-eye"></i></button>
152                    </div>                    
153                    <button id="paywall-login" style="padding: 10px 20px; background: #007BFF; color: white; border: none; border-radius: 4px; width: 100%; box-sizing: border-box; cursor:pointer;">
154                        <span class="btn-text">Log In</span>
155                        <i class="fa-solid fa-spinner fa-spin" style="display: none;"></i>
156                    </button>
157
158                    <p style="text-align:center; margin:30px 0; font-size:16px; color:#9f000c;"><a href="${paywallSettings.forgotPasswordUrl}" target="_top">Forgot Password?</a></p>
159                   
160                </div>
161
162                <!-- display subscriptions -->
163                <iframe id="overlay_subscribe_iframe" style="display:none;" src="${paywallSettings.iframeUrl}" width="100%" height="560px" style="border: none;"></iframe>
164            </div>
165        </section>
166        `;
167        document.body.appendChild(overlayLogin);
168
169        /* determine if the SUBSCRIBE box or the LOGIN box should be shown onload */
170        if ( default_view === 'subscribe' ) {
171            document.getElementById('overlay_login_prompt').style.display = 'none';
172            document.getElementById('overlay_subscribe_iframe').style.display = '';
173
174            document.getElementById('account_login').style.display = '';
175            document.getElementById('account_subscribe').style.display = 'none';
176
177
178        } else {
179            document.getElementById('overlay_login_prompt').style.display = '';
180            document.getElementById('overlay_subscribe_iframe').style.display = 'none';
181
182            document.getElementById('account_login').style.display = 'none';
183            document.getElementById('account_subscribe').style.display = '';
184        }
185
186
187
188        /* close the overlay if the CLOSE button is clicked */
189        document.getElementById('login_overlay_close').addEventListener('click', async () => {
190            document.body.removeChild(overlayLogin);
191        });
192
193
194
195        /* handle switching between LOGIN and SUBCRIBE on the overlay */
196            /* LOGIN was clicked - show the login box and hide the subscriptions */
197            document.getElementById('overlay_login_link').addEventListener('click', async () => {
198                document.getElementById('overlay_login_prompt').style.display = '';
199                document.getElementById('overlay_subscribe_iframe').style.display = 'none';
200
201                document.getElementById('account_login').style.display = 'none';
202                document.getElementById('account_subscribe').style.display = '';
203            });
204
205            /* SUBSCRIBE was clicked - show the subscribe box and hide the login box */
206            document.getElementById('overlay_subscribe_link').addEventListener('click', async () => {
207                if ( paywallSettings.authenticator == 'onecount' ) {
208
209                    window.location.href = '/subscribe';
210                    
211                } else {
212
213
214                    document.getElementById('overlay_login_prompt').style.display = 'none';
215                    document.getElementById('overlay_subscribe_iframe').style.display = '';
216
217                    document.getElementById('account_login').style.display = '';
218                    document.getElementById('account_subscribe').style.display = 'none';
219
220                }
221            });
222
223
224
225        /* the LOGIN button was clicked - verify if user can continue */
226        document.getElementById('paywall-login').addEventListener('click', async () => {
227            const email = document.getElementById('paywall-email').value;
228            const password = document.getElementById('paywall-password').value;
229            const errorDiv = document.getElementById('paywall-error');
230
231            /* if both the USERNAME and PASSWORD were not provided - stop now */
232            if (!email || !password) {
233                errorDiv.style.display = 'block';
234                errorDiv.textContent = 'Please enter both email and password.';
235                return;
236            }
237
238            /* show the spinner and hide the button text to let user know something is happening */
239            const spinner = document.getElementById('paywall-login').querySelector('i');
240            const btnText = document.getElementById('paywall-login').querySelector('.btn-text');
241            spinner.style.display = 'inline-block';
242            btnText.style.display = 'none';
243            document.getElementById('paywall-login').disabled = true;
244
245            try {
246                /* check the Auth API to see if the user credentials are valid */
247                const response = await fetch(paywallSettings.pluginPath + 'api-auth.php', {
248                    method: 'POST',
249                    headers: {
250                        'Content-Type': 'application/json'
251                    },
252                    body: JSON.stringify({
253                        email,
254                        password,
255                        domain: window.location.hostname //'www.lakeplacidnews.com'
256                    })
257                });
258                const data = await response.json();
259
260                /* if valid - log the user in and remove the overlay */
261                if (data.user && data.user.success) {
262                    /* store the session */
263                    localStorage.setItem('paywallSession', JSON.stringify({ timestamp: new Date().getTime(), name:data.user.userAttributes.given_name }));
264                    localStorage.removeItem('articleCount');
265                    setSubscriberCookie(true);
266                    //console.log('Session Created:', localStorage.getItem('paywallSession'));
267                    document.body.removeChild(overlayLogin);
268                    document.body.style.overflow = 'auto';
269                    window.location.reload();
270                /* otherwise - show the user an error message */
271                } else {
272                    errorDiv.style.display = 'block';
273                    errorDiv.textContent = data.message || 'Invalid credentials.';
274                    /* return the button text and remove the spinner */
275                    spinner.style.display = 'none';
276                    btnText.style.display = '';
277                    document.getElementById('paywall-login').disabled = false;
278
279                }
280            } catch (error) {
281                //console.log(error);
282                errorDiv.style.display = 'block';
283                errorDiv.textContent = error;
284            }
285        });
286
287
288        /* show/hide password field */
289        const passwordInput = document.getElementById('paywall-password');
290        const toggleButton = document.getElementById('toggle-password');
291        const toggleIcon = toggleButton.querySelector('i');
292        toggleButton.addEventListener('click', () => {
293            const isPasswordVisible = passwordInput.type === 'text';
294            passwordInput.type = isPasswordVisible ? 'password' : 'text';
295            toggleIcon.className = isPasswordVisible ? 'fas fa-eye' : 'fas fa-eye-slash';
296        });
297
298    };
299
300
301
302
303    
304    const session = localStorage.getItem('paywallSession');
305
306    /* if the user is not logged in - lets append the LOGIN option in the nav */
307    if ( !session ) {
308
309        /* if we are using a theme with the mobile UL */
310        if ( $('.login_mobile').length > 0 ) {
311            /* the mobile nav has a CLASS - but the main header nav does not */
312            /* we'll use jQuery to find the main header nav */
313            console.log('found it!');
314
315            let found_header_nav = null;
316
317            /* this function will check all previos child elements to find the header nav UL that is directly above it */
318            $('.login_mobile').prevAll().each(function() {
319            /* check if the element itself is a <ul> */
320            if ($(this).is('ul')) {
321                found_header_nav = $(this);
322                return false; /* break out of loop */
323            }
324
325            /* if the previos element is not a <UL>, look for a <ul> inside it */
326            /* this extra looping is necessary because the previos <ul> might be nested inside another tag (in this case - something <aside>) */
327            /* this way it will look through the previous element's child elements to find that <ul> that is just above the mobile */
328            const innerUl = $(this).find('ul').first();
329            if (innerUl.length) {
330                found_header_nav = innerUl;
331                return false; /* break out of loop */
332            }
333            });
334
335            /* append the login prompt */
336            if (found_header_nav) {
337
338                if ( paywallSettings.cherryroadEnabled == 1 ) {
339                    found_header_nav.append(`
340                        <style>
341                            #todays_date {position:relative !important; display:flex; width:auto !important; justify-content: center;}
342                            #todays_date li {display:inline !important; margin:0 3px !important; font-family:Georgia, serif !important; font-size:14px !important; color:#333 !important;}
343                            .login_dropdown_toggle {cursor:pointer; color:blue; }
344
345                            .login_dropdown_menu {display:none; position:absolute; background-color:#fff; border:1px solid #ccc; min-width:230px; padding:15px 0; box-shadow:0 4px 8px rgba(0,0,0,0.3); z-index:100; margin-top:10px; right:0}
346                            .login_dropdown_menu a {display:block; padding:0 15px; text-decoration:none; color:#333;}
347
348                            /* Show menu when .show class added */
349                            .show {display:grid; grid-template-columns:1fr; grid-row-gap:15px;}
350                            .login_dropdown_link {border:solid 1px #dbdbdb; padding:10px 4px; text-align:center; transition:.8s}
351                            .login_dropdown_link:hover {background:#000; border:solid 1px #000; color:#fff; transition:.8s}
352
353                            .login_dropdown_toggle_arrow {width:10px; height:8px; padding:2px 0 0 2px;}
354                            .login_dropdown_toggle::before {content:'Login';}
355                            #todays_date li:last-of-type {position:relative}
356                            @media screen and (max-width: 740px) {#todays_date {display: none;}}
357                        </style>
358                        <li>|</li>
359                        <li>
360                            <a class="login_dropdown_toggle" style="cursor:pointer;">
361                                <svg class="login_dropdown_toggle_arrow" viewB
361ox="0 0 10 6"><path d="M5 3.35L8.64 0 10 1.4 5 6 0 1.4 1.36 0z"></path></svg>
362                            </a>
363                            <div class="login_dropdown_menu">
364                                <a style="cursor:pointer;">
365                                    <div id="header_nav_login" class="login_dropdown_link">Login</div>
366                                </a>
367                                <a href="` + paywallSettings.storeUrl + `my-account/bill-pay">
368                                    <div class="login_dropdown_link">Activate Bill Pay</div>
369                                </a>
370                                <a href="` + paywallSettings.storeUrl + `my-account/bill-pay?login">
371                                    <div class="login_dropdown_link">Manage Subscription</div>
372                                </a>
373                            </div>
374                        </li>
375                        <script>
376                            // Toggle dropdown when clicking the link
377                            document.querySelector(".login_dropdown_toggle").addEventListener("click", function (event) {
378                                event.stopPropagation();
379                                document.querySelector(".login_dropdown_menu").classList.toggle("show");
380                            });
381
382                            // Close dropdown when clicking outside
383                            document.addEventListener("click", function (event) {
384                                const dropdown = document.querySelector("#todays_date");
385                                if (!dropdown.contains(event.target)) {
386                                    document.querySelector(".login_dropdown_menu").classList.remove("show");
387                                }
388                            });
389                        </script>
390
391                    `);
392                } else {
393
394                    found_header_nav.append(`
395                        <li>|</li>
396                        <li><a style="cursor:pointer;" id="header_nav_login">Login</a></li>
397                    `);
398                }
399
400                document.getElementById('header_nav_login').addEventListener('click', async () => {
401                    showPaywall('login');
402                });
403            } 
404
405            if ( paywallSettings.cherryroadEnabled == 1 ) {
406
407                $('.login_mobile').append(`
408                        <style>
409                            #todays_date {position:relative !important; display:flex; width:auto !important; justify-content: center;}
410                            #todays_date li {display:inline !important; margin:0 3px !important; font-family:Georgia, serif !important; font-size:14px !important; color:#333 !important;}
411                            .login_dropdown_mobile_toggle {cursor:pointer; color:blue; }
412
413                            .login_dropdown_mobile_menu {display:none; position:absolute; background-color:#fff; border:1px solid #ccc; min-width:230px; padding:15px 0; box-shadow:0 4px 8px rgba(0,0,0,0.3); z-index:100; margin-top:10px; right:0}
414                            .login_dropdown_mobile_menu a {display:block; padding:0 15px; text-decoration:none; color:#333;}
415
416                            /* Show menu when .show class added */
417                            .show {display:grid; grid-template-columns:1fr; grid-row-gap:15px;}
418                            .login_dropdown_mobile_link {border:solid 1px #dbdbdb; padding:10px 4px; text-align:center; transition:.8s}
419                            .login_dropdown_mobile_link:hover {background:#000; border:solid 1px #000; color:#fff; transition:.8s}
420
421                            .login_dropdown_mobile_toggle_arrow {width:10px; height:8px; padding:2px 0 0 2px;}
422                            .login_dropdown_mobile_toggle::before {content:'Login';}
423                            #todays_date li:last-of-type {position:relative}
424                            @media screen and (max-width: 740px) {#todays_date {display: none;}}
425                        </style>
426                        <li>|</li>
427                        <li>
428                            <a class="login_dropdown_mobile_toggle" style="cursor:pointer;">
429                                <svg class="login_dropdown_mobile_toggle_arrow" viewB
429ox="0 0 10 6"><path d="M5 3.35L8.64 0 10 1.4 5 6 0 1.4 1.36 0z"></path></svg>
430                            </a>
431                            <div class="login_dropdown_mobile_menu">
432                                <a style="cursor:pointer;">
433                                    <div id="mobile_nav_login" class="login_dropdown_mobile_link">Login</div>
434                                </a>
435                                <a href="` + paywallSettings.storeUrl + `my-account/bill-pay">
436                                    <div class="login_dropdown_mobile_link">Activate Bill Pay</div>
437                                </a>
438                                <a href="` + paywallSettings.storeUrl + `my-account/bill-pay?login">
439                                    <div class="login_dropdown_mobile_link">Manage Subscription</div>
440                                </a>
441                            </div>
442                        </li>
443                        <script>
444                            // Toggle dropdown when clicking the link
445                            document.querySelector(".login_dropdown_mobile_toggle").addEventListener("click", function (event) {
446                                event.stopPropagation();
447                                document.querySelector(".login_dropdown_mobile_menu").classList.toggle("show");
448                            });
449
450                            // Close dropdown when clicking outside
451                            document.addEventListener("click", function (event) {
452                                const dropdown = document.querySelector("#todays_date");
453                                if (!dropdown.contains(event.target)) {
454                                    document.querySelector(".login_dropdown_mobile_menu").classList.remove("show");
455                                }
456                            });
457                        </script>
458                `);
459
460
461
462            } else {
463
464                $('.login_mobile').append(`
465                    <li>|</li>
466                    <li><a style="cursor:pointer;" id="mobile_nav_login">Login</a></li>
467                `);
468            }
469            document.getElementById('mobile_nav_login').addEventListener('click', async () => {
470                showPaywall('login');
471            });
472
473        /* if we are using the newer 'weekly' theme */
474        } else if ( $('#login_status').length > 0 ){
475
476            $('#login_status').html(`
477                <span style="cursor:pointer;" id="header_nav_login">Login</span>
478            `);
479            document.getElementById('header_nav_login').addEventListener('click', async (e) => {
480                e.preventDefault();
481                showPaywall('login');
482            });
483
484        /* if we are using the new Shared Core Theme */
485        } else if ( $('#under_logo_links').length > 0 ){
486
487
488            if ( paywallSettings.cherryroadEnabled == 1 ) {
489
490
491                document
492                .getElementById('under_logo_links')
493                .querySelector('ul')
494                .insertAdjacentHTML(
495                    'beforeend',
496                    `<li>
497                        <a class="login_dropdown_mobile_toggle" style="cursor:pointer;">
498                            <svg class="login_dropdown_mobile_toggle_arrow" viewBox="0 0 10 6"><path d="M5 3.35L8.64 0 10 1.4 5 6 0 1.4 1.36 0z"></path></svg>
499                        </a>
500                        <div class="login_dropdown_mobile_menu">
501                            <a style="cursor:pointer;">
502                                <div id="mobile_nav_login" class="login_dropdown_mobile_link">Login</div>
503                            </a>
504                            <a href="` + paywallSettings.storeUrl + `my-account/bill-pay">
505                                <div class="login_dropdown_mobile_link">Activate Bill Pay</div>
506                            </a>
507                            <a href="` + paywallSettings.storeUrl + `my-account/bill-pay?login">
508                                <div class="login_dropdown_mobile_link">Manage Subscription</div>
509                            </a>
510                        </div>
511                    </li>`
512                );
513
514                    if (!document.getElementById('login-dropdown-style')) {
515                        document.head.insertAdjacentHTML(
516                            'beforeend',
517                            `
518                            <style id="login-dropdown-style">
519                                #under_logo_links {position:relative !important; display:flex; width:auto !important; justify-content: center;}
520                                .login_dropdown_mobile_toggle {cursor:pointer; color:blue; }
521
522                                .login_dropdown_mobile_menu {display:none; position:absolute; background-color:#fff; border:1px solid #ccc; min-width:230px; padding:15px 0; box-shadow:0 4px 8px rgba(0,0,0,0.3); z-index:100; margin-top:10px; right:0}
523                                .login_dropdown_mobile_menu a {display:block; padding:0 15px; text-decoration:none; color:#333;}
524
525                                /* Show menu when .show class added */
526                                .show {display:grid; grid-template-columns:1fr; grid-row-gap:15px;}
527                                .login_dropdown_mobile_link {border:solid 1px #dbdbdb; padding:10px 4px; text-align:center; transition:.8s}
528                                .login_dropdown_mobile_link:hover {background:#000; border:solid 1px #000; color:#fff; transition:.8s}
529
530                                .login_dropdown_mobile_toggle_arrow {width:10px; height:8px; padding:2px 0 0 2px;}
531                                .login_dropdown_mobile_toggle::before {content:'Login';}
532                                #under_logo_links li:last-of-type {position:relative}
533                                @media screen and (max-width: 740px) {#under_logo_links {display: none;}}
534                            </style>
535                            `
536                        );
537                    }        
538
539                    // Toggle dropdown when clicking the link
540                    document.querySelector(".login_dropdown_mobile_toggle").addEventListener("click", function (event) {
541                        event.stopPropagation();
542                        document.querySelector(".login_dropdown_mobile_menu").classList.toggle("show");
543                    });
544
545                    // Close dropdown when clicking outside
546                    document.addEventListener("click", function (event) {
547                        const dropdown = document.querySelector("#under_logo_links");
548                        if (!dropdown.contains(event.target)) {
549                            document.querySelector(".login_dropdown_mobile_menu").classList.remove("show");
550                        }
551                    });
552
553
554
555
556
557
558
559            } else {
560
561                document
562                    .getElementById('under_logo_links')
563                    .querySelector('ul')
564                    .insertAdjacentHTML(
565                        'beforeend',
566                        `<li><a style="cursor:pointer;" id="mobile_nav_login">Login</a></li>`
567                    );
568
569
570            }
571
572            document.getElementById('header_nav_login').innerHTML = 'Login';
573
574            document.getElementById('header_nav_login').classList.remove('login_toggle');
575
576            document.getElementById('mobile_nav_login').addEventListener('click', async () => {
577                showPaywall('login');
578            });
579            document.getElementById('header_nav_login').addEventListener('click', async () => {
580                showPaywall('login');
581            });
582
583
584
585
586
587        }
588
589
590
591
592    } else {
593
594        /* if we are using a theme with the mobile UL */
595        if ( $('.login_mobile').length > 0 ) {
596
597            /* the mobile nav has a CLASS - but the main header nav does not */
598            /* we'll use jQuery to find the main header nav */
599
600            let found_header_nav = null;
601
602            /* this function will check all previos child elements to find the header nav UL that is directly above it */
603            $('.login_mobile').prevAll().each(function() {
604            /* check if the element itself is a <ul> */
605            if ($(this).is('ul')) {
606                found_header_nav = $(this);
607                return false; /* break out of loop */
608            }
609
610            /* if the previos element is not a <UL>, look for a <ul> inside it */
611            /* this extra looping is necessary because the previos <ul> might be nested inside another tag (in this case - something <aside>) */
612            /* this way it will look through the previous element's child elements to find that <ul> that is just above the mobile */
613            const innerUl = $(this).find('ul').first();
614            if (innerUl.length) {
615                found_header_nav = innerUl;
616                return false; /* break out of loop */
617            }
618            });
619
620            json_session = JSON.parse(session);
621            //console.log(json_session);
622
623            
624            /* append the login prompt */
625            if (found_header_nav) {
626                if ( paywallSettings.cherryroadEnabled == 1 ) {
627                    found_header_nav.append(`
628                        <style>
629                            #todays_date {position:relative !important; display:flex; width:auto !important; justify-content: center;}
630                            #todays_date li {display:inline !important; margin:0 3px !important; font-family:Georgia, serif !important; font-size:14px !important; color:#333 !important;}
631                            .login_dropdown_toggle {cursor:pointer; color:blue; }
632
633                            .login_dropdown_menu {display:none; position:absolute; background-color:#fff; border:1px solid #ccc; min-width:230px; padding:15px 0; box-shadow:0 4px 8px rgba(0,0,0,0.3); z-index:100; margin-top:10px; right:0}
634                            .login_dropdown_menu a {display:block; padding:0 15px; text-decoration:none; color:#333;}
635
636                            /* Show menu when .show class added */
637                            .show {display:grid; grid-template-columns:1fr; grid-row-gap:15px;}
638                            .login_dropdown_link {border:solid 1px #dbdbdb; padding:10px 4px; text-align:center; transition:.8s}
639                            .login_dropdown_link:hover {background:#000; border:solid 1px #000; color:#fff; transition:.8s}
640
641                            .login_dropdown_toggle_arrow {width:10px; height:8px; padding:2px 0 0 2px;}
642                            .login_dropdown_toggle::before {content:'Welcome: ${json_session['name']}';}
643                            #todays_date li:last-of-type {position:relative}
644                            @media screen and (max-width: 740px) {#todays_date {display: none;}}
645                        </style>
646                        <li>|</li>
647                        <li>
648                            <a class="login_dropdown_toggle" style="cursor:pointer;">
649                                <svg class="login_dropdown_toggle_arrow" viewB
649ox="0 0 10 6"><path d="M5 3.35L8.64 0 10 1.4 5 6 0 1.4 1.36 0z"></path></svg>
650                            </a>
651                            <div class="login_dropdown_menu">
652                                <a style="cursor:pointer;">
653                                    <div id="header_nav_logout" class="login_dropdown_link">Logout</div>
654                                </a>
655                                <a href="` + paywallSettings.storeUrl + `my-account/bill-pay">
656                                    <div class="login_dropdown_link">Activate Bill Pay</div>
657                                </a>
658                                <a href="` + paywallSettings.storeUrl + `my-account/bill-pay?login">
659                                    <div class="login_dropdown_link">Manage Subscription</div>
660                                </a>
661                            </div>
662                        </li>
663                        <script>
664                            // Toggle dropdown when clicking the link
665                            document.querySelector(".login_dropdown_toggle").addEventListener("click", function (event) {
666                                event.stopPropagation();
667                                document.querySelector(".login_dropdown_menu").classList.toggle("show");
668                            });
669
670                            // Close dropdown when clicking outside
671                            document.addEventListener("click", function (event) {
672                                const dropdown = document.querySelector("#todays_date");
673                                if (!dropdown.contains(event.target)) {
674                                    document.querySelector(".login_dropdown_menu").classList.remove("show");
675                                }
676                            });
677                        </script>
678
679                    `);
680                } else {
681
682                    found_header_nav.append(`
683                        <li>|</li>
684                        <li>Welcome: <strong><a class="subscriber_name" href="${paywallSettings.manageAccountUrl}" title="View Profile">${json_session['name']}</a></strong> - <span id="header_nav_logout" style="cursor:pointer;">Logout</span></li>
685                    `);
686                }
687
688                document.getElementById('header_nav_logout').addEventListener('click', async () => {
689                    localStorage.removeItem('paywallSession');
690                    setSubscriberCookie(false);
691                    window.location.reload();
692                });
693                
694
695            } 
696
697            if ( paywallSettings.cherryroadEnabled == 1 ) {
698
699                $('.login_mobile').append(`
700                        <style>
701                            #todays_date {position:relative !important; display:flex; width:auto !important; justify-content: center;}
702                            #todays_date li {display:inline !important; margin:0 3px !important; font-family:Georgia, serif !important; font-size:14px !important; color:#333 !important;}
703                            .login_dropdown_mobile_toggle {cursor:pointer; color:blue; }
704
705                            .login_dropdown_mobile_menu {display:none; position:absolute; background-color:#fff; border:1px solid #ccc; min-width:230px; padding:15px 0; box-shadow:0 4px 8px rgba(0,0,0,0.3); z-index:100; margin-top:10px; right:0}
706                            .login_dropdown_mobile_menu a {display:block; padding:0 15px; text-decoration:none; color:#333;}
707
708                            /* Show menu when .show class added */
709                            .show {display:grid; grid-template-columns:1fr; grid-row-gap:15px;}
710                            .login_dropdown_mobile_link {border:solid 1px #dbdbdb; padding:10px 4px; text-align:center; transition:.8s}
711                            .login_dropdown_mobile_link:hover {background:#000; border:solid 1px #000; color:#fff; transition:.8s}
712
713                            .login_dropdown_mobile_toggle_arrow {width:10px; height:8px; padding:2px 0 0 2px;}
714                            .login_dropdown_mobile_toggle::before {content:'Welcome: ${json_session['name']}';}
715                            #todays_date li:last-of-type {position:relative}
716                            @media screen and (max-width: 740px) {#todays_date {display: none;}}
717                        </style>
718                        <li>|</li>
719                        <li>
720                            <a class="login_dropdown_mobile_toggle" style="cursor:pointer;">
721                                <svg class="login_dropdown_mobile_toggle_arrow" viewB
721ox="0 0 10 6"><path d="M5 3.35L8.64 0 10 1.4 5 6 0 1.4 1.36 0z"></path></svg>
722                            </a>
723                            <div class="login_dropdown_mobile_menu">
724                                <a style="cursor:pointer;">
725                                    <div id="mobile_nav_logout" class="login_dropdown_mobile_link">Logout</div>
726                                </a>
727                                <a href="` + paywallSettings.storeUrl + `my-account/bill-pay">
728                                    <div class="login_dropdown_mobile_link">Activate Bill Pay</div>
729                                </a>
730                                <a href="` + paywallSettings.storeUrl + `my-account/bill-pay?login">
731                                    <div class="login_dropdown_mobile_link">Manage Subscription</div>
732                                </a>
733                            </div>
734                        </li>
735                        <script>
736                            // Toggle dropdown when clicking the link
737                            document.querySelector(".login_dropdown_mobile_toggle").addEventListener("click", function (event) {
738                                event.stopPropagation();
739                                document.querySelector(".login_dropdown_mobile_menu").classList.toggle("show");
740                            });
741
742                            // Close dropdown when clicking outside
743                            document.addEventListener("click", function (event) {
744                                const dropdown = document.querySelector("#todays_date");
745                                if (!dropdown.contains(event.target)) {
746                                    document.querySelector(".login_dropdown_mobile_menu").classList.remove("show");
747                                }
748                            });
749                        </script>
750                `);
751
752
753
754            } else {
755
756                $('.login_mobile').append(`
757                    <li>|</li>
758                    <li>Welcome: <strong><a class="subscriber_name" href="${paywallSettings.manageAccountUrl}" title="View Profile">${json_session['name']}</a></strong> - <span id="mobile_nav_logout" style="cursor:pointer;">Logout</span></li>
759                `);
760            }
761        
762            document.getElementById('mobile_nav_logout').addEventListener('click', async () => {
763                localStorage.removeItem('paywallSession');
764                setSubscriberCookie(false);
765                window.location.reload();
766            });
767
768        /* if we are using the newer 'weekly' theme */
769        } else if ( $('#login_status').length > 0 ){
770
771
772            json_session = JSON.parse(session);
773            //console.log(json_session);
774
775            $('#login_status').html(`
776                Welcome: <strong><a class="subscriber_name" href="${paywallSettings.manageAccountUrl}" title="View Profile">${json_session['name']}</a></strong> - <span id="header_nav_logout" style="cursor:pointer;">Logout</span>
777            `);
778            document.getElementById('header_nav_logout').addEventListener('click', async (e) => {
779                e.preventDefault();
780                localStorage.removeItem('paywallSession');
781                setSubscriberCookie(false);
782                window.location.reload();
783            });
784
785        /* if we are using the new Shared Core Theme */
786        } else if ( $('#under_logo_links').length > 0 ){
787
788            json_session = JSON.parse(session);
789
790
791            if ( paywallSettings.cherryroadEnabled == 1 ) {
792
793
794                document
795                .getElementById('under_logo_links')
796                .querySelector('ul')
797                .insertAdjacentHTML(
798                    'beforeend',
799                    `<li>
800                        <a class="login_dropdown_mobile_toggle" style="cursor:pointer;">
801                            <svg class="login_dropdown_mobile_toggle_arrow" viewBox="0 0 10 6"><path d="M5 3.35L8.64 0 10 1.4 5 6 0 1.4 1.36 0z"></path></svg>
802                        </a>
803                        <div class="login_dropdown_mobile_menu">
804                            <a style="cursor:pointer;">
805                                <div id="mobile_nav_logout" class="login_dropdown_mobile_link">Logout</div>
806                            </a>
807                            <a href="` + paywallSettings.storeUrl + `my-account/bill-pay">
808                                <div class="login_dropdown_mobile_link">Activate Bill Pay</div>
809                            </a>
810                            <a href="` + paywallSettings.storeUrl + `my-account/bill-pay?login">
811                                <div class="login_dropdown_mobile_link">Manage Subscription</div>
812                            </a>
813                        </div>
814                    </li>`
815                );
816
817                    if (!document.getElementById('login-dropdown-style')) {
818                        document.head.insertAdjacentHTML(
819                            'beforeend',
820                            `
821                            <style>
822                            #under_logo_links {position:relative !important; display:flex; width:auto !important; justify-content: center;}
823                            #under_logo_links li {display:inline !important;}
824                            .login_dropdown_mobile_toggle {cursor:pointer; color:blue; }
825
826                            .login_dropdown_mobile_menu {display:none; position:absolute; background-color:#fff; border:1px solid #ccc; min-width:230px; padding:15px 0; box-shadow:0 4px 8px rgba(0,0,0,0.3); z-index:100; margin-top:10px; right:0}
827                            .login_dropdown_mobile_menu a {display:block; padding:0 15px; text-decoration:none; color:#333;}
828
829                            /* Show menu when .show class added */
830                            .show {display:grid; grid-template-columns:1fr; grid-row-gap:15px;}
831                            .login_dropdown_mobile_link {border:solid 1px #dbdbdb; padding:10px 4px; text-align:center; transition:.8s}
832                            .login_dropdown_mobile_link:hover {background:#000; border:solid 1px #000; color:#fff; transition:.8s}
833
834                            .login_dropdown_mobile_toggle_arrow {width:10px; height:8px; padding:2px 0 0 2px;}
835                            .login_dropdown_mobile_toggle::before {content:'Welcome: ${json_session['name']}';}
836                            #under_logo_links li:last-of-type {position:relative}
837                            @media screen and (max-width: 740px) {#under_logo_links {display: none;}}
838                        </style>
839                            `
840                        );
841                    }        
842
843                // Toggle dropdown when clicking the link
844                document.querySelector(".login_dropdown_mobile_toggle").addEventListener("click", function (event) {
845                    event.stopPropagation();
846                    document.querySelector(".login_dropdown_mobile_menu").classList.toggle("show");
847                });
848
849                // Close dropdown when clicking outside
850                document.addEventListener("click", function (event) {
851                    const dropdown = document.querySelector("#under_logo_links");
852                    if (!dropdown.contains(event.target)) {
853                        document.querySelector(".login_dropdown_mobile_menu").classList.remove("show");
854                    }
855                });
856
857
858
859
860
861
862
863            } else {
864
865                document
866                    .getElementById('under_logo_links')
867                    .querySelector('ul')
868                    .insertAdjacentHTML(
869                        'beforeend',
870                        `<li>Welcome: <strong><a class="subscriber_name" href="${paywallSettings.manageAccountUrl}" title="View Profile">${json_session['name']}</a></strong> - <span id="mobile_nav_logout" style="cursor:pointer;">Logout</span></li>`
871                    );
872
873
874            }
875
876            
877            document.getElementById('mobile_nav_logout').addEventListener('click', async () => {
878                localStorage.removeItem('paywallSession');
879                setSubscriberCookie(false);
880                window.location.reload();
881            });
882
883
884            document.getElementById('header_nav_login').innerHTML = 'Logout';
885
886            document.getElementById('header_nav_login').classList.remove('login_toggle');
887
888            document.querySelector('.submit_news_link').classList.add('hide');
889
890            document.getElementById('header_nav_login').addEventListener('click', async () => {
891                localStorage.removeItem('paywallSession');
892                setSubscriberCookie(false);
893                window.location.reload();
894            });
895
896
897
898
899
900        }
901
902
903
904
905    }
906
907    
908
909
910
911
912});

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.