PageSourceSearch

https://www.nriag.sci.eg/wp-content/plugins/cbxpoll/assets/js/cbxpoll-public.js?ver=2.0.5

js nriag.sci.eg collected 2026-09-24 21:22:56 UTC 9,821 bytes, 261 lines download raw bytes

1'use strict';
2
3var cbxpoll_awn_options_public = {
4    labels: {
5        tip          : cbxpollpublic.awn_options.tip,
6        info         : cbxpollpublic.awn_options.info,
7        success      : cbxpollpublic.awn_options.success,
8        warning      : cbxpollpublic.awn_options.warning,
9        alert        : cbxpollpublic.awn_options.alert,
10        async        : cbxpollpublic.awn_options.async,
11        confirm      : cbxpollpublic.awn_options.confirm,
12        confirmOk    : cbxpollpublic.awn_options.confirmOk,
13        confirmCancel: cbxpollpublic.awn_options.confirmCancel
14    }
15};
16
17function cbxpoll_formsubmit($element, $) {
18    var $submit_btn = $element.find('.cbxpoll_vote_btn');
19    var wrapper     = $element.closest('.cbxpoll_wrapper');
20    var $_this_busy = Number($submit_btn.attr('data-busy'));
21
22    var poll_id    = $submit_btn.attr('data-post-id');
23    var reference  = $submit_btn.attr('data-reference');
24    var chart_type = $submit_btn.attr('data-charttype');
25    var security   = $submit_btn.attr('data-security');
26
27    var user_answer   = $element.find('input.cbxpoll_single_answer:checked').serialize();
28    var answer_reason = $element.find('select.cbxpoll_answer_reason_select:checked');
29
30    let notifier = new AWN(cbxpoll_awn_options_public);
31
32
33    if ($_this_busy === 0) {
34
35        $submit_btn.attr('data-busy', '1');
36        $submit_btn.prop('disabled', true);
37        $submit_btn.addClass('running');
38
39        //wrapper.find('.cbvoteajaximage').removeClass('cbvoteajaximagecustom');
40
41        var user_answer_trim = user_answer.trim();
42
43        var $other_condition = true;
44
45        var $reason_enabled = cbxpollpublic.reason_enabled;
46        if ($reason_enabled) {
47            var $checked_answered = $element.find('input.cbxpoll_single_answer:checked');
48
49            $checked_answered.each(function (index, element) {
50                var $element     = $(element);
51                var $elm_parent  = $element.closest('.cbxpoll-form-ans-listitem');
52                var $reason      = $elm_parent.find('.cbxpoll_answer_reason_select').val();
53                var $reason_text = $elm_parent.find('.cbxpoll_answer_other_reason_text');
54                //$reason_text.removeClass('cbxpoll_answer_other_reason_text_err');
55
56                if ($reason === '-1') {
57                    var $reason_text_val = $reason_text.val();
58                    if ($reason_text_val === '') {
59                        $other_condition = false;
60                        //$reason_text.addClass('cbxpoll_answer_other_reason_text_err');
61                    }
62                }
63
64            });
65        }
66
67
68        if ($other_condition && typeof user_answer !== 'undefined' && user_answer_trim.length !== 0) { // if one answer given
69            wrapper.find('.cbxpoll-qresponse').hide();
70
71            $.ajax({
72                type    : 'post',
73                dataType: 'json',
74                url     : cbxpollpublic.ajaxurl,
75                data    : $element.serialize() + '&user_answer=' + $.base64.btoa(user_answer),
76                success : function (data, textStatus, XMLHttpRequest) {
77                    if (Number(data.error) === 0) {
78                        try { //the data for all graphs
79                            if (data.show_result === 1) {
80                                wrapper.append(data.html);
81                            }
82
83                            wrapper.find('.cbxpoll-qresponse').show();
84                            wrapper.find('.cbxpoll-qresponse').removeClass('cbxpoll-qresponse-alert cbxpoll-qresponse-error cbxpoll-qresponse-success');
85                            wrapper.find('.cbxpoll-qresponse').addClass('cbxpoll-qresponse-success');
86                            wrapper.find('.cbxpoll-qresponse').html('<p>' + data.text + '</p>');
87
88                            notifier.success(data.text);
89
90
91                            wrapper.find('.cbxpoll_answer_wrapper').hide();
92                        } catch (e) {
93
94                        }
95
96                    }// end of if not voted
97                    else {
98                        wrapper.find('.cbxpoll-qresponse').show();
99                        wrapper.find('.cbxpoll-qresponse').removeClass('cbxpoll-qresponse-alert cbxpoll-qresponse-error cbxpoll-qresponse-success');
100                        wrapper.find('.cbxpoll-qresponse').addClass('cbxpoll-qresponse-error');
101                        wrapper.find('.cbxpoll-qresponse').html('<p>' + data.text + '</p>');
102
103                        notifier.success(data.text);
104
105                    }
106
107                    $submit_btn.attr('data-busy', '0');
108                    $submit_btn.prop('disabled', false);
109                    $submit_btn.removeClass('running');
110                    //wrapper.find('.cbvoteajaximage').addClass('cbvoteajaximagecustom');
111                }//end of success
112            });//end of ajax
113
114        } else if ($other_condition === false) {
115            //reason condition failed
116
117            //if no answer given
118            $submit_btn.show();
119            $submit_btn.attr('data-busy', 0);
120            $submit_btn.prop('disabled', false);
121            $submit_btn.removeClass('running');
122            //wrapper.find('.cbvoteajaximage').addClass('cbvoteajaximagecustom');
123
124            var error_result = cbxpollpublic.other_reason_text_empty;
125
126
127            wrapper.find('.cbxpoll-qresponse').show();
128            wrapper.find('.cbxpoll-qresponse').removeClass('cbxpoll-qresponse-alert cbxpoll-qresponse-error cbxpoll-qresponse-success');
129            wrapper.find('.cbxpoll-qresponse').addClass('cbxpoll-qresponse-alert');
130            wrapper.find('.cbxpoll-qresponse').html(error_result);
131
132            notifier.alert(error_result);
133        } else {
134
135            //if no answer given
136            $submit_btn.show();
137            $submit_btn.attr('data-busy', 0);
138            $submit_btn.prop('disabled', false);
139            $submit_btn.removeClass('running');
140            //wrapper.find('.cbvoteajaximage').addClass('cbvoteajaximagecustom');
141
142            var error_result = cbxpollpublic.no_answer_error;
143
144
145            wrapper.find('.cbxpoll-qresponse').show();
146            wrapper.find('.cbxpoll-qresponse').removeClass('cbxpoll-qresponse-alert cbxpoll-qresponse-error cbxpoll-qresponse-success');
147            wrapper.find('.cbxpoll-qresponse').addClass('cbxpoll-qresponse-alert');
148            wrapper.find('.cbxpoll-qresponse').html(error_result);
149
150            notifier.alert(error_result);
151        }
152    }// end of this data busy
153}
154
155jQuery(document).ready(function ($) {
156
157
158    $.base64.utf8encode = true;
159
160
161    $(document.body).on('click', '.cbxpoll-listing-trig', function (e) {
162        e.preventDefault();
163
164        var $this  = $(this);
165        var parent = $this.closest('.cbxpoll-listing-wrap');
166
167
168        var busy     = Number($this.attr('data-busy'));
169        var page_no  = Number($this.attr('data-page-no'));
170        var per_page = Number($this.attr('data-per-page'));
171        var nonce    = $this.attr('data-security');
172        var user_id  = Number($this.attr('data-user_id'));
173
174        if (Number(busy) === 0) {
175            $this.attr('data-busy', 1);
176            $this.addClass('running');
177
178            //$this.find('.cbvoteajaximage').removeClass('cbvoteajaximagecustom');
179
180            $.ajax({
181
182                type    : 'post',
183                dataType: 'json',
184                url     : cbxpollpublic.ajaxurl,
185                data    : {
186                    action  : 'cbxpoll_list_pagination',
187                    page_no : page_no,
188                    per_page: per_page,
189                    security: nonce,
190                    user_id : user_id
191                },
192                success : function (data, textStatus, XMLHttpRequest) {
193
194                    $this.attr('data-busy', 0);
195                    $this.removeClass('running');
196
197
198                    if (data.found) {
199                        var content = data.content;
200                        parent.find('.cbxpoll-listing').append(content);
201                    }
202
203
204                    //check if we reached at last page
205                    var max_num_pages = data.max_num_pages;
206                    if ((page_no === max_num_pages) || (data.found === 0)) {
207                        $this.parent('.cbxpoll-listing-more').remove();
208                    }
209
210                    page_no++;
211                    $this.attr('data-page-no', page_no);
212
213                    //$this.find('.cbvoteajaximage').addClass('cbvoteajaximagecustom');
214
215                }
216            });
217
218        }
219
220    });//end on click
221
222
223    $(document.body).on('submit', '.cbxpoll-form', function (e) {
224        e.preventDefault();
225
226        var $element = $(this);
227
228        let defaultConfig = {
229            // class of the parent element where the error/success class is added
230            classTo     : 'cbxpoll_extra_field_wrap',
231            errorClass  : 'has-danger',
232            successClass: 'has-success',
233            // class of the parent element where error text element is appended
234            errorTextParent: 'cbxpoll_extra_field_wrap',
235            // type of element to create for the error text
236            errorTextTag: 'p',
237            // class of the error text element
238            errorTextClass: 'text-help'
239        };
240
241        var pristine = new Pristine($element[0], defaultConfig);
242        var valid    = pristine.validate(); // returns true or false
243
244        if (!valid) {
245            e.preventDefault();
246        } else {
247            cbxpoll_formsubmit($element, $);
248        }
249
250    });
251
252    //login form
253    $('.cbxpoll-guest-wrap').on('click', '.cbxpoll-title-login a', function (e) {
254        e.preventDefault();
255
256        let $this   = $(this);
257        let $parent = $this.closest('.cbxpoll-guest-wrap');
258        $parent.find('.cbxpoll-guest-login-wrap').toggle();
259    });
260
261});//end dom ready

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.