PageSourceSearch

https://getawesomesupport.com/wp-content/plugins/awesome-support-productivity/assets/js/functions.js?ver=6.9.9

js getawesomesupport.com collected 2026-09-25 15:25:40 UTC 10,767 bytes, 233 lines download raw bytes

1
2var grecaptcha_validated = false;
3var grecaptcha_active    = false;
4var grecaptcha_loaded    = false;
5
6
7
8(function($) {
9        
10        // This will run once registration form submitted and captcha verified
11        function onRegSubmit(code) {
12                
13                grecaptcha_validated = true;	
14                jQuery('#wpas_form_registration .wpas-btn[type=submit]').prop('disabled', false ).trigger('click');
15
16        }
17        
18        window.onRegSubmit = onRegSubmit;
19
20        // Check if captcha is loaded
21        function check_recaptcha_loaded() {
22                if( 0 === $('.g-recaptcha #g-recaptcha-response').length ) {
23                        setTimeout( check_recaptcha_loaded , 500 );
24                } else {
25                        $('.g-recaptcha iframe').get(0).onload = function() {
26                                grecaptcha_loaded = true;
27                                $('.g-recaptcha').trigger('loaded');
28                        }
29                }
30        }
31
32        // Fix some css once captcha loaded with error message
33        function onCaptchaLoaded() {
34                if($('.g-recaptcha .grecaptcha-user-facing-error').length > 0) {
35                        $('.g-recaptcha .grecaptcha-user-facing-error').remove();
36                        $('.g-recaptcha .grecaptcha-badge').css('width', '300px');
37                        $('.g-recaptcha iframe').css('width', '306px');
38                }
39        }
40
41        // Init captcha verification once registration form submitted
42        function onRegFormSubmit(e) {
43                if( !grecaptcha_validated ) {
44                        e.preventDefault();
45                        e.stopImmediatePropagation();
46                        grecaptcha.execute();
47                        return false;
48                }
49
50                return true;
51        }
52        
53        
54        /**
55         * Check if element have a attribute
56         * 
57         * @param string name
58         * @returns Boolean
59         */
60        $.fn.hasAttr = function(name) {  
61                return this.attr(name) !== undefined;
62        };
63        
64        $(function() {
65                // Check if captcha is active
66                grecaptcha_active = $('.g-recaptcha').length > 0 ? true : false
67                
68                // check if captcha is loaded
69                if( grecaptcha_active ) {
70                        check_recaptcha_loaded();
71                        $('.g-recaptcha').on('loaded', onCaptchaLoaded );
72                        $('#wpas_form_registration').on('submit', onRegFormSubmit );
73                }
74                
75                
76                /**
77                 * Load add/edit email notification form once email card expanded
78                 */
79                $('body').delegate('.card', 'card_expanded', function( e ) {
80                        var card = $(this);
81                        
82                        
83                        var email = card.data( 'email' );
84                        var user_notification = card.data( 'user_notification' );
85                        var item_id = card.data( 'item_id' );
86
87                        var template = wp.template( 'wpas-notification-add-item' );
88                        
89                        var type = item_id ? 'edit' : 'add';
90
91                        var el = template( { 
92                                item_id : item_id,
93                                email : email, 
94                                user_notification : user_notification, 
95                                can_delete : card.data('can_delete'),
96                                type : type
97                        } );
98                        
99
100                        $(this).find('.card_expanded_inner').append( $(el) );
101                });
102                
103                /**
104                 * Clear add/edit email form once email card collapsed
105                 */
106                $('body').delegate('.card', 'card_collapsed', function( e ) {      
107                        var card = $(this);
108                        card.find('.card_expanded_inner').html('');
109                });
110                
111                /**
112                 * Save notification email from email card
113                 */
114                $('body').delegate( '.card_expanded_inner .buttons .button.btn-save', 'click', function() {
115                
116                        var data = new Array();
117                        var btn = $(this);
118                        var form = $(btn).closest('.card');
119                        var sec = form.closest('.wpas_pf_ui_wrapper').data('section');
120
121
122                        var loader = $('<div class="spinner"></div>');
123                        loader.insertBefore( btn );
124                        btn.prop('disabled', true );
125
126                        form.find('input, select, textarea').each(function() {
127
128                                if( ($(this).hasAttr('id') || $(this).hasAttr('data-name')) && !$(this).hasClass('ed_button') ) {
129
130                                        if( ('checkbox' == $(this).attr('type') && $(this).prop('checked')) || $(this).attr('type') != 'checkbox' ) {
131                                                var name = $(this).hasAttr('data-name') ? $(this).data('name') : $(this).attr('id');
132                                                var value = $(this).val();
133                                                data.push({ name: name, value : value });
134                                        }
135                                }
136                        });
137
138                        var form_action = form.find('.wpas_form_action').val();
139                        data.push({name:'action', value : form_action});
140                        data.push({name:'duid', value : $(this).closest('.wpas_pf_ui_wrapper').data('duid')});
141
142                        $.post(ajaxurl, data, function (response) {
143
144
145                                if( true == response.success ) {
146
147
148                                        if( response.data.item ) {
149                                                $('.wpas_pf_ui_wrapper .wpas_pf_main_msg').removeClass('error').addClass('updated').html('<p>'+response.data.msg+'</p>').show();
150                                                
151                                                var item = $(response.data.item);
152                                                
153                                                Window.close_card( $('.cards_add_new_email_notification .card') );
154                                                
155                                                $('#wpas_pf_'+sec+'_items .wpas_pf_ui_items').append(item);
156                                                
157                                                
158                                        } else if( response.data.update_item ) {
159                                                var item = $(response.data.update_item);
160
161                                                $('.wpas_pf_ui_wrapper .wpas_pf_main_msg').removeClass('error').addClass('updated').html('<p>'+response.data.msg+'</p>').show();
162                                                
163                                                Window.close_card( btn.closest('.card') );
164                                                
165                                                $('#wpas_pf_'+sec+'_items .wpas_pf_ui_items .wpas_pf_ui_item[data-item_id='+response.data.item_id+']').replaceWith(item);
166                                        }
167
168
169                                        item.trigger( form_action + '_response', [sec, data, response] );
170
171                                } else {
172                                        form.find('.wpas_msg').addClass('error').removeClass('updated').html('<p>'+response.data.msg+'</p>');
173                                }
174
175                                loader.remove();
176                                btn.prop('disabled', false);
177
178                        });
179                } );
180
181                
182                
183                
184                // Send delete email request to server
185                $('body').delegate('.wpas_pf_ui_item .wpas_pf_ui_item_action.wpas_pf_ui_item_action_delete', 'click', function(e) {
186                        e.preventDefault();
187                        var section = $(this).closest('.wpas_pf_ui_wrapper').data('section');
188                        var item = $(this).closest('.wpas_pf_ui_item');
189                        var item_id = item.data('item_id');
190                        var btn = $(this);
191                        var msg = btn.data('confirm');
192
193                        if(confirm(msg)) {
194                                btn.hide();
195                                var loader = $('<div class="spinner"></div>');
196                                loader.css({visibility: 'visible'})
197                                $(this).closest('li').append(loader);
198
199                                var data = new Array();
200                                var nonce = btn.closest('.wpas_pf_data_items').find('.delete-nonce');
201                                var action = $(this).data('action');
202
203                                data.push({name:'action', value : action });
204                                data.push({name:'id', value : item_id});
205                                data.push({name:$(nonce).data('name'), value : $(nonce).val()});
206                                data.push({name:'duid', value : $(this).closest('.wpas_pf_ui_wrapper').data('duid')});
207
208                                $.post(ajaxurl, data, function (response) {
209
210                                        var msg = item.find('.wpas_pf_ui_item_msg');
211                                        $(msg).find('.msg').html(response.data.msg);
212
213                                        if( true == response.success ) {
214                                                        item.trigger( action + '_response', [section, data, response] );
215                                                        Window.close_card(item);
216                                                        item.remove();
217                                                        $('.wpas_pf_ui_wrapper .wpas_pf_main_msg').removeClass('error').addClass('updated').html('<p>'+response.data.msg+'</p>').show();
218                                        } else {
219                                                        msg.removeClass('updated').addClass('error').show();
220                                                        loader.remove();
221                                                        btn.show();
222                                        }
223                                });
224                        }
225
226                });
227                
228                
229                
230        });
231	
232	
233}(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.