PageSourceSearch

https://lematinal.bj/wp-content/plugins/jnews-paywall/assets/js/frontend.js?ver=11.0.6

js lematinal.bj collected 2026-10-02 12:39:33 UTC 9,467 bytes, 224 lines download raw bytes

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