PageSourceSearch

https://therolladailynews.com/wp-content/plugins/jnews-paywall/assets/js/frontend.js?ver=12.0.1

js therolladailynews.com collected 2026-10-02 07:10:22 UTC 11,689 bytes, 268 lines download raw bytes

1(function ($) {
2
3    'use strict'
4
5    /**
6     * Ajax send request for unlocking post
7     */
8    function main(e, data) {
9        window.jnews.paywall = window.jnews.paywall || {}
10
11        window.jnews.paywall = {
12            init: function () {
13                var base = this
14                base.container = $('body')
15                base.user_login = base.container.hasClass('logged-in')
16                base.form_login = base.container.find('.jeg_accountlink')
17                base.xhr = null
18                base.login_button = base.container.find('.jpw_login a')
19                base.package_item_button = base.container.find('.jpw-wrapper .package-item .button')
20                base.path = (jnewsoption.site_slug === undefined) ? '/' : jnewsoption.site_slug
21                base.domain = (jnewsoption.site_domain === undefined) ? window.location.hostname : jnewsoption.site_domain
22
23                base.set_event()
24                base.set_after_checkout()
25                document.cookie = 'paywall_product = false; path = ' + base.path + '; domain = ' + base.domain + '; secure'
26            },
27
28            set_event: function () {
29                var base = this
30                /**
31                 * Unlock Popup
32                 */
33                base.container.find('.jeg_paywall_unlock_post').off('click').on('click', function (e) {
34                    base.post_id = $(this).data('id')
35                    base.open_form(e, '#jpw_unlock_popup')
36                })
37
38                base.container.find('#jpw_unlock_popup .btn.yes').off('click').on('click', function (e) {
39                    e.preventDefault()
40                    e.stopPropagation()
41                    var $element = $(this),
42                        ajax_data = {
43                            unlock_post_id: '1',
44                            action: 'paywall_handler',
45                            post_id: base.post_id
46                        }
47                    $element.find('.fa-spinner').show();
48                    $element.find('span').hide();
49                    if (base.xhr !== null) {
50                        base.xhr.abort()
51                    }
52                    base.paywall_ajax(ajax_data)
53                })
54
55                base.container.find('#jpw_unlock_popup .btn.no').off('click').on('click', function (e) {
56                    $.magnificPopup.close()
57                })
58
59                /**
60                 * Cancel Subscription
61                 */
62                base.container.find('.jpw_manage_status .subscription').off('click').on('click', function (e) {
63                    base.open_form(e, '#jpw_cancel_subs_popup')
64                })
65
66                base.container.find('#jpw_cancel_subs_popup .btn.yes').off('click').on('click', function (e) {
67                    var nonce = base.container.find('#jpw_cencel_subs').val();
68                    e.preventDefault()
69                    e.stopPropagation()
70                    var $element = $(this),
71                        ajax_data = {
72                            cancel_subscription: 'yes',
73                            action: 'cancel_subs_handler',
74                            nonce: nonce
75                        }
76                    $element.find('.fa-spinner').show();
77                    $element.find('span').hide();
78                    if (base.xhr !== null) {
79                        base.xhr.abort()
80                    }
81                    base.paywall_ajax(ajax_data)
82                })
83
84                base.container.find('#jpw_cancel_subs_popup .btn.no').off('click').on('click', function (e) {
85                    $.magnificPopup.close()
86                })
87
88                /**
89                 * Login Needed
90                 */
91                if (!base.user_login) {
92                    base.login_button.off('click')
93                    base.package_item_button.off('click')
94                    if (base.form_login.length > 0) {
95                        if (jnewsoption.custom_login === '') {
96                            var package_item_button = base.package_item_button.attr("href", "#jeg_loginform")
97                            var login_button = base.login_button.attr("href", "#jeg_loginform")
98                            base.open_form_login(login_button)
99                            base.open_form_login(package_item_button)
100                        } else {
101                            var package_item_button = base.package_item_button.attr("href", "#")
102                            package_item_button.on('click', function (e) {
103                                e.preventDefault()
104                                $.magnificPopup.open({
105                                    type: 'inline',
106                                    removalDelay: 500,
107                                    mainClass: 'mfp-zoom-out',
108                                    items: {
109                                        src: '#jeg_loginform',
110                                    },
111                                    callbacks: {
112                                        beforeOpen: function () {
113                                            this.st.mainClass = 'mfp-zoom-out'
114                                            $('body').removeClass('jeg_show_menu')
115                                        },
116                                    }
117                                })
118
119                            })
120                        }
121                    } else {
122                        base.login_button.on('click', function (e) {
123                            e.preventDefault()
124                            alert('Please login to buy!')
125                        })
126                        base.package_item_button.on('click', function (e) {
127                            e.preventDefault()
128                            e.stopPropagation()
129                            alert('Please login to buy!')
130                        })
131                    }
132                    base.container.find('.jpw-wrapper .package-item .button').on('click', function (e) {
133                        var $element = $(this),
134                            productID = $element.attr('data-product_id'),
135                            ajax_data = {
136                                product_id: productID,
137                                action: 'refresh_checkout_redirect'
138                            };
139
140                        document.cookie = 'paywall_product = ' + productID + '; path = ' + base.path + '; domain = ' + base.domain
141
142                        base.xhr = $.ajax({
143                            url: jnews_ajax_url,
144                            type: 'post',
145                            dataType: 'json',
146                            data: ajax_data,
147                        }).done(function (data) {
148                            jnewsoption.login_reload = data.login_reload
149                        })
150
151                        $('#jeg_loginform form > p:nth-child(2)').text(jnewsoption.paywall_login)
152                        $('#jeg_registerform form > p:nth-child(2)').text(jnewsoption.paywall_register)
153                    })
154                } else {
155                    base.container.find('.jpw-wrapper .package-item .button').off('click').on('click', function (e) {
156                        e.preventDefault()
157                        e.stopPropagation()
158                        var $element = $(this),
159                            productID = $element.attr('data-product_id'),
160                            ajax_data = {
161                                product_id: productID,
162                                after_checkout: base.page_redirect(),
163                                action: 'add_paywall_product'
164                            }
165                        $element.find('.fa-spinner').show();
166                        $element.find('span').hide();
167                        if (base.xhr !== null) {
168                            base.xhr.abort()
169                        }
170                        base.paywall_ajax(ajax_data)
171                    })
172                }
173
174                base.container.find('.woocommerce-MyAccount-paymentMethods .stripepaywall .delete').off('click').on('click', function (e) {
175                    e.preventDefault()
176                    e.stopPropagation()
177                    var $element = $(this)
178                    var sourceID = $element.attr('data-source_id'),
179                        ajax_data = {
180                            source_id: sourceID,
181                            action: 'delete_source_handler'
182                        }
183                    $element.find('.fa-spinner').show();
184                    $element.find('span').hide();
185                    if (base.xhr !== null) {
186                        base.xhr.abort()
187                    }
188                    base.paywall_ajax(ajax_data)
189                })
190
191                base.container.find('.woocommerce-MyAccount-paymentMethods .stripepaywall .default').off('click').on('click', function (e) {
192                    e.preventDefault()
193                    e.stopPropagation()
194                    var $element = $(this)
195                    var sourceID = $element.attr('data-source_id'),
196                        ajax_data = {
197                            source_id: sourceID,
198                            action: 'default_source_handler'
199                        }
200                    $element.find('.fa-spinner').show();
201                    $element.find('span').hide();
202                    if (base.xhr !== null) {
203                        base.xhr.abort()
204                    }
205                    base.paywall_ajax(ajax_data)
206                })
207            },
208            page_redirect: function () {
209                var urlParams = new URLSearchParams(window.location.search);
210                return urlParams.get('jpw_after_checkout');
211            },
212            set_after_checkout: function () {
213                var base = this;
214                if (base.container.hasClass('woocommerce-checkout')) {
215                    var after_checkout = base.page_redirect();
216                    if (after_checkout) {
217                        document.cookie = 'jpw_after_checkout =' + after_checkout + "; path= " + base.path + '; domain = ' + base.domain;
218                    } else {
219                        document.cookie = 'jpw_after_checkout = default; path = ' + base.path + '; domain = ' + base.domain + '; secure'
220                    }
221                }
222            },
223
224            paywall_ajax: function (ajaxdata) {
225                var base = this
226                base.xhr = $.ajax({
227                    url: jnews_ajax_url,
228                    type: 'post',
229                    dataType: 'json',
230                    data: ajaxdata,
231                }).done(function (data) {
232                    if (data.redirect) {
233                        window.location.href = data.redirect
234                    } else {
235                        location.reload()
236                    }
237                })
238            },
239
240            open_form: function (e, popup_id) {
241                e.preventDefault()
242
243                $.magnificPopup.open({
244                    removalDelay: 500,
245                    midClick: true,
246                    mainClass: 'mfp-zoom-out',
247                    type: 'inline',
248                    items: {
249                        src: popup_id
250                    }
251                })
252            },
253
254            open_form_login: function (popuplink) {
255                window.jnews.loginregister.show_popup(popuplink);
256                window.jnews.loginregister.hook_form();
257            }
258        }
259
260        jnews.paywall.init()
261    }
262    $(document).on('jnews-ajax-load', main);
263
264    $(function () {
265        main()
266    });
267
268})(jQuery)

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.