PageSourceSearch

https://teachermatic.com/wp-content/plugins/affs/assets/js/frontend/dashboard.js?ver=9.2

js teachermatic.com collected 2026-09-28 09:19:22 UTC 14,263 bytes, 316 lines download raw bytes

1/* global fs_affiliates_dashboard_params */
2
3jQuery( function ( $ ) {
4
5    //File Upload
6    if ( $( '.fs_affiliates_file_upload' ).length ) {
7        $( '.fs_affiliates_file_upload' ).each( function ( e ) {
8
9            var data = [ {
10                    name: 'action',
11                    value: 'fs_affiliates_file_upload',
12                },
13                {
14                    name: 'key',
15                    value: $( this ).attr( 'name' )
16                } ];
17            $( this ).fileupload( {
18                url: fs_affiliates_dashboard_params.ajax_url,
19                type: 'POST',
20                async: false,
21                formData: function ( form ) {
22                    return data;
23                },
24                dataType: 'json',
25                done: function ( e, data ) {
26                    if ( data.result.success === true ) {
27                        var html;
28                        html = '<p class="fs_affiliates_uploaded_file_name"><b>' + data.files[0].name + '</b>';
29                        html += '<span class="fs_affiliates_delete_uploaded_file" style="color:red;margin-left:10px;cursor: pointer;">[x]';
30                        html += '<input type="hidden" class="fs_affiliates_remove_file" value=' + data.files[0].name + ' /></span></p>';
31
32                        $( this ).closest( 'div' ).find( '.fs_affiliates_display_file_names' ).append( html );
33                    } else {
34                        $( '.fs_affiliates_display_file_names' ).html( '<span class="fs_affiliates_error_msg_for_upload" style="color:red;">' + data.result.data.content + '</span>' );
35                        $( '.fs_affiliates_error_msg_for_upload' ).delay( 3000 ).fadeOut( );
36                    }
37                }
38            } );
39        } );
40    }
41
42    var FS_Dashboard = {
43        init: function () {
44            this.trigger_on_page_load();
45
46            $(document).on('change', '#aff_change_slug', this.modifiy_slug);
47            $(document).on('change', '#fs_affiliates_payment_method', this.payment_method_change);
48            $(document).on('click', '#fs_affiliates_form_save', this.affiliates_form_save);
49            $(document).on('click', '#fs_affiliates_form_send_mail', this.affiliates_form_send_mail);
50            $(document).on('click', '.fs_affiliates_delete_uploaded_file', this.remove_uploaded_file);
51            $(document).on('click', '.fs_affiliates_delete_table_uploaded_file', this.remove_table_uploaded_file);
52            $(document).on('click', '.fs_request_unpaid_commission', this.get_unpaid_commissions);
53            $(document).on('focusout', 'input[name=fs_new_campaign]', this.validate_campaign_name);
54            // Pagination.
55            $(document).on('click', '.fs-pagination', this.pagination);
56            // Search products.
57            $(document).on('click', '.fs-product-commission-search-btn', this.search_product);
58        }, trigger_on_page_load: function () {
59            FS_Dashboard.aff_payment_method_common('#fs_affiliates_payment_method');
60            this.show_or_hide_for_modifiy_slug();
61
62        }, payment_method_change: function ( event ) {
63            event.preventDefault();
64            var $this = $( event.currentTarget );
65            FS_Dashboard.aff_payment_method_common( $this );
66        }, aff_payment_method_common: function ( $this ) {
67            $( '.fs_affiliates_validation_error' ).hide();
68            $( '.affiliate-pay' ).hide();
69            var selected_val = $( $this ).val();
70            if ( selected_val == 'paypal' ) {
71                $( '.affiliate-paypal-pay' ).show();
72            } else if ( selected_val == 'direct' ) {
73                $( '.affiliate-direct-pay' ).show();
74            } else if ( selected_val == 'wallet' ) {
75                $( '.affiliate-wallet-pay' ).show();
76            }
77        }, remove_uploaded_file: function ( event ) {
78            event.preventDefault();
79            var $this = $( event.currentTarget );
80
81            var data = {
82                action: 'fs_affiliates_remove_uploaded_file',
83                key: $( $this ).closest( 'div' ).find( '.fs_affiliates_uploaded_file_key' ).val(),
84                file_name: $( $this ).find( '.fs_affiliates_remove_file' ).val(),
85            };
86            $.post( fs_affiliates_dashboard_params.ajax_url, data, function ( response ) {
87                if ( true === response.success ) {
88                    $( $this ).closest( 'p.fs_affiliates_uploaded_file_name' ).remove();
89                } else {
90                    window.alert( response.data.error );
91                }
92            } );
93        },
94        remove_table_uploaded_file: function ( event ) {
95            event.preventDefault();
96            var $this = $( event.currentTarget );
97
98            var data = {
99                action: 'fs_affiliates_remove_uploaded_file',
100                key: $( $this ).find( '.fs_affiliates_uploaded_file_key' ).val(),
101                file_name: $( $this ).find( '.fs_affiliates_remove_file' ).val(),
102            };
103            $.post( fs_affiliates_dashboard_params.ajax_url, data, function ( response ) {
104                if ( true === response.success ) {
105                    $( $this ).closest( 'tr' ).remove();
106                } else {
107                    window.alert( response.data.error );
108                }
109            } );
110        }, affiliates_form_save: function ( event ) {
111            var affilate_id = $( '#fs_affiliates_current_id' ).val();
112            var pay_method = $( '#fs_affiliates_payment_method' ).val();
113            var paypal_email = $( '#fs_affiliates_paypal_email' ).val();
114            var paypal_bank = $( '#fs_affiliates_bank_details' ).val();
115            var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,10})?$/;
116
117            $( '.fs_affiliates_validation_error' ).hide();
118
119            if ( pay_method == 'direct' ) {
120                if ( paypal_bank === '' ) {
121                    $( '.fs_affiliates_detail_validate' ).show();
122                    return false;
123                }
124            } else if ( pay_method == 'paypal' ) {
125                if ( paypal_email == '' || !emailReg.test( paypal_email ) ) {
126                    $( '.fs_affiliates_email_validate' ).show();
127                    return false;
128                }
129            }
130
131            var data = {
132                action: "fs_affiliates_pay_method_change",
133                fs_affiliate_current_id: affilate_id,
134                fs_affiliates_payment_method: pay_method,
135                fs_affiliates_paypal_email: paypal_email,
136                fs_affiliates_bank_details: paypal_bank,
137                fs_security: fs_affiliates_dashboard_params.pay_save_nonce,
138
139            }
140            jQuery.post( fs_affiliates_dashboard_params.ajax_url, data,
141                    function ( response ) {
142                        if ( true === response.success ) {
143                            if ( response.data.content == 'success' ) {
144                                $( '#fs_affiliates_msg_success' ).remove();
145                                $( '#fs_affiliates_pay_msg_wraper' ).append( '<span id="fs_affiliates_msg_success" class="fs_affiliates_msg_success"><i class="fa fa-check"></i>Success!!!</span>' );
146                                $( '#fs_affiliates_pay_msg_wraper' ).show();
147                            }
148                        } else {
149                            window.alert( response.data.error );
150                        }
151                    }
152            );
153        },
154        modifiy_slug: function () {
155            FS_Dashboard.show_or_hide_for_modifiy_slug();
156        },
157        show_or_hide_for_modifiy_slug: function () {
158            if ( jQuery( '#aff_change_slug' ).is( ':checked' ) == true ) {
159                jQuery( '#aff_new_slug' ).closest( 'p' ).show();
160            } else {
161                jQuery( '#aff_new_slug' ).closest( 'p' ).hide();
162            }
163        }, affiliates_form_send_mail: function ( event ) {
164
165            var refer_mails = $( '#fs_affiliates_refer_mails' ).val();
166            var refer_mail_subject = $( '#fs_affiliates_refer_mail_subject' ).val();
167            var refer_mail_content = $( '#fs_affiliates_refer_mail_content' ).val();
168            var hidden_id = $( '#fs_affiliates_hidden_id' ).val();
169
170            var splited = refer_mails.split( '|' );
171            var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
172
173            $( '.fs_affiliates_msg_success' ).hide();
174
175            $( '.fs_affiliates_msg_fails' ).hide();
176
177            $( '.fs_affiliates_refer_friend_validation_error' ).hide();
178
179            if ( refer_mails == '' ) {
180                $( '.fs_affiliates_refer_mail_validate' ).show();
181                return false;
182            } else {
183                $.each( splited, function ( key, value ) {
184                    if ( !emailReg.test( value ) ) {
185                        $( '.fs_affiliates_refer_mail_validate' ).show();
186                        return false;
187                    }
188                } );
189            }
190
191
192            if ( refer_mail_subject === '' ) {
193                $( '.fs_affiliates_refer_subject_validate' ).show();
194                return false;
195            }
196
197            if ( refer_mail_content === '' ) {
198                $( '.fs_affiliates_refer_content_validate' ).show();
199                return false;
200            }
201
202
203
204            var data = {
205                action: "fs_affiliates_referafriend_mails",
206                refer_mails: refer_mails,
207                refer_mail_subject: refer_mail_subject,
208                refer_mail_content: refer_mail_content,
209                hidden_id: hidden_id,
210                fs_security: fs_affiliates_dashboard_params.pay_save_nonce,
211
212            }
213            jQuery.post( fs_affiliates_dashboard_params.ajax_url, data,
214                    function ( response ) {
215                        var trimmed_response = Number( jQuery.trim( response ) );
216                        $( '.fs_affiliates_refer_friend_validation_error' ).hide();
217                        if ( trimmed_response > 0 ) {
218                            $( '.fs_affiliates_refer_mail_success' ).show();
219                        } else {
220                            $( '.fs_affiliates_refer_mail_fails' ).show();
221                        }
222                    }
223            );
224        }, get_unpaid_commissions: function () {
225            if ( confirm( fs_affiliates_dashboard_params.request_submit_confirm ) ) {
226                var data = {
227                    action: "fsunpaidcommission",
228                    affiliateid: $( this ).attr( 'data-affiliateid' ),
229                    fs_security: fs_affiliates_dashboard_params.unpaid_commission,
230
231                }
232                $.post( fs_affiliates_dashboard_params.ajax_url, data, function ( response ) {
233                    if ( true === response.success ) {
234                        $( "<div><span class='fs_affiliates_msg_success'><i class='fa fa-check'> " + response.data.content + " !!!</i></span></div>" ).insertBefore( '.fs_affiliates_form' );
235                    } else {
236                        $( "<div><span class='fs_affiliates_msg_fails_post'><i class='fa fa-exclamation-triangle'> " + response.data.error + "</i></span></div>" ).insertBefore( '.fs_affiliates_form' );
237                    }
238                } );
239            }
240            return false;
241        },
242        pagination: function (event) {
243            event.preventDefault( );
244            var $this = $(event.currentTarget),
245                    wrapper = $this.closest('.fs-product-commission-wrapper'),
246                    table = $this.closest('table.fs-affiliates-product-commisssion-table'),
247                    filter = table.prev('.fs-frontend-filter'),
248                    table_body = table.find('tbody'),
249                    selected_page = $this.data('page');
250            var data = ({
251                action: 'fs_pagination_action',
252                selected_page: selected_page,
253                s: filter.find('.fs-frontend-search').val(),
254                fs_security: fs_affiliates_dashboard_params.pagination_action_nonce
255            });
256            $.post(fs_affiliates_dashboard_params.ajax_url, data, function (res) {
257                if (true === res.success) {
258                    wrapper.find('table').remove();
259                    wrapper.html(res.data.html);
260                } else {
261                    alert(res.data.error);
262                }
263            }
264            );
265        },
266        search_product: function (event) {
267            event.preventDefault( );
268            var $this = $(event.currentTarget),
269                    wrapper = $this.closest('.fs-product-commission-wrapper'),
270                    table = wrapper.find('table.fs-affiliates-product-commisssion-table'),
271                    table_body = table.find('tbody');
272
273            var data = ({
274                action: 'fs_search_action',
275                s: wrapper.find('.fs-frontend-search').val(),
276                product_id: wrapper.find('.fs-product-id').val(),
277                fs_security: fs_affiliates_dashboard_params.filter_search_nonce
278            });
279
280            $.post(fs_affiliates_dashboard_params.ajax_url, data, function (res) {
281                if (true === res.success) {
282                    wrapper.find('table').remove();
283                    wrapper.html(res.data.html);
284                } else {
285                    alert(res.data.error);
286                }
287            }
288            );
289        },
290        validate_campaign_name: function (event) {
291            event.preventDefault();
292            var $this = $( event.currentTarget );
293
294            if ( $this.val().indexOf( " " ) !== -1 ) {
295                var $without_whitespace = $this.val().replace( /\s/g, '' );
296                $this.val( $without_whitespace );
297            }
298        },
299    };
300    FS_Dashboard.init();
301
302    if ( $( '.fs_affiliates_frontend_dashboard' ).length ) {
303
304        $( 'ul.submenu' ).hide();
305        $( 'ul > li, ul.submenu > li' ).hover( function () {
306            if ( $( '> ul.submenu', this ).length > 0 ) {
307                $( '> ul.submenu', this ).stop().slideDown( 'slow' );
308            }
309        }, function () {
310            if ( $( '> ul.submenu', this ).length > 0 ) {
311                $( '> ul.submenu', this ).stop().slideUp( 'slow' );
312            }
313        } );
314    }
315
316} );

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.