PageSourceSearch

https://worldaircargoawards.com/wp-content/plugins/waca-plugin/js/waca.js?tme=1790703698&ver=1

js worldaircargoawards.com collected 2026-10-04 13:23:33 UTC 31,383 bytes, 1,003 lines download raw bytes

1jQuery(document).ready(function(){
2    if(document.getElementById('waca-sideline')){
3        jQuery('.follow').each(function(){
4            jQuery(this).click(function(){
5                window.location.href = jQuery(this).attr('data-url');
6            });
7        });
8    }
9
10
11
12    if(document.getElementById('country')){
13        jQuery('#country').change(function(){
14           if(jQuery(this).val() == 'UK' || jQuery(this).val() == 'uk'){
15               jQuery(this).val('United Kingdom');
16               jQuery('#country_code').val('+44');
17           }
18           if(jQuery(this).val() == 'USA' || jQuery(this).val() == 'usa'){
19               jQuery(this).val('United States');
20               jQuery('#country_code').val('+1');
21           }
22           if(jQuery(this).val() == 'UAE' || jQuery(this).val() == 'uae'){
23               jQuery(this).val('United Arab Emirates');
24               jQuery('#country_code').val('+971');
25           }
26        });
27    }
28
29    if(document.getElementById('orderbydate')){
30        jQuery('#orderbydate').trigger('click'); // for the CRM ordering by most recent first
31    }
32
33    if(document.getElementById('company_type')){
34        jQuery('#company_type').on('input', function(){
35           if(jQuery(this).val() == 'Other (please type)'){
36               jQuery(this).select();
37           }
38        });
39    }
40});
41
42function triage_nomination(pid, type){
43   if( type < 1 && jQuery('#nomrow_' + pid).hasClass('accepted')){
44       if(!window.confirm('This nomination has been accepted. Rejecting now will send an email asking for resubmission. Continue?')){
45           return false;
46       }
47   }
48   console.log('triaging_' + pid);
49   jQuery('#accept_' + pid).html(cc_spinner('small'));
50   jQuery('#reject_' + pid).html(cc_spinner('small'));
51   var accept_class = type == 1 ? 'accepted' : 'rejected';
52   var remove_class = type == 1 ? 'rejected' : 'accepted';
53   var da = {
54       post_id : pid,
55       accept : type,
56       action : 'triage_nomination'
57   }
58   //return false;
59   console.log(da);
60
61   jQuery.ajax({
62       method : 'POST', data : da, url : php.form,
63       success : function(r){
64           //console.log(r);
65           r = JSON.parse(r);
66           //console.log(r);
67           jQuery('#accept_' + pid).closest('tr').removeClass(remove_class);
68           jQuery('#accept_' + pid).closest('tr').addClass(accept_class);
69           jQuery('#accept_' + pid).html(r.accept);
70           jQuery('#reject_' + pid).html(r.reject);
71       },
72       error : function(e){
73           console.log(e);
74       }
75   })
76}
77
78function waca_modal_open(id, fld, title){
79     jQuery('#popup_overlay').addClass('active');
80     jQuery('#popup_content').addClass('active');
81     jQuery('#popup_content h3').html(title);
82     jQuery('#popup_body').html(cc_spinner());
83     var da = {
84         action : 'fetch_nomination_company_json',
85         pid : id,
86         field : fld
87     }
88     console.log(da);
89     jQuery.ajax({
90         method : 'post', data: da, url: php.wfunc,
91         success : function(r){
92           console.log(r);
93           jQuery('#popup_body').html(r);
94           jQuery(window).scrollTop( jQuery("#popup_overlay").offset().top );
95         },
96         error : function(e){
97           jQuery('#popup_body').html('AJAX ERROR');
98         }
99     });
100}
101
102
103function ValidateEmail(email) {
104    const emailPattern = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
105    return emailPattern.test(email);
106}
107
108function preview_file_url(select_element){
109    var url = jQuery('#' + select_element + ' option:selected').attr('data-url');
110    window.open(url, '_blank').focus();
111}
112
113function waca_save_option(opt,val){
114    var da = {
115        action : 'waca_save_option',
116        option_name : opt,
117        option_value : val
118    }
119
120    jQuery.ajax({
121        method : 'POST', url: php.wfunc, data: da,
122        success : function(r){
123            if(r == 'done'){
124               jQuery('#' + opt + '_' + 'saved').html(cc_success());
125            } else {
126               jQuery('#' + opt + '_' + 'saved').html(cc_fail());
127            }
128        }
129    });
130}
131
132function save_download_file_selection(opt){
133     jQuery('#' + opt + '_' + 'saved').html(cc_spinner('small'));
134     waca_save_option(opt, jQuery('#' + opt + ' option:selected').val());
135}
136
137function save_waca_settings(){
138    //get all .collect vals and data-option vals and send them to update options
139    jQuery('#submit_progress').html(cc_spinner('small'));
140    var sets = [];
141    jQuery('.collect').each(function(){
142       var tn = jQuery(this).prop('tagName');
143       var st = {};
144       st['option_name'] = jQuery(this).attr('data-option');
145       if(tn == 'INPUT'){
146           if(jQuery(this).attr('type') == 'checkbox'){
147             st['option_value'] = jQuery(this).is(':checked') ? 1 : 0;
148           } else {
149             st['option_value'] = jQuery(this).val();
150           }
151       }
152       if(tn == 'SELECT'){
153           st['option_value'] = jQuery(this).find('option:selected').val();
154       }
155       sets.push(st);
156    });
157    var da = {
158        action : 'save_waca_admin_settings',
159        settings : sets
160    };
161    jQuery.ajax({
162        method : 'POST', data: da, url: php.wfunc,
163        success: function(r){
164            console.log(r);
165            if(r.trim() == 'done'){
166               jQuery('#submit_progress').html(cc_success());
167            } else {
168               jQuery('#submit_progress').html(cc_fail());
169            }
170        }
171    });
172}
173
174function send_sponsor_pack(spid){
175    var spdf = jQuery('#pdf_sent_' + spid).text();
176    if(!spdf.includes('-')){
177        if(!window.confirm('A sponsorship email has already been sent. Are you sure you wish to 
177send another?')){
178            return false;
179        }
180    }
181    jQuery('#email_send_' + spid).html(cc_spinner('small'));
182    var da = {
183        action : 'send_sponsor_pack',
184        sponsor : spid
185    }
186    jQuery.ajax({
187        method : 'post', url: php.wfunc, data : da,
188        success : function(r){
189           console.log(r);
190           if((r * 1) > 0){
191                jQuery('#email_send_' + spid).html(cc_success());
192           } else {
193                jQuery('#email_send_' + spid).html(cc_fail());
194           }
195        },
196        error : function(e){
197
198        }
199    })
200}
201
202function waca_form_completed(){
203    var incomplete = false;
204    jQuery('.required').each(function(){
205       if(jQuery(this).val().length < 1){
206           var id = jQuery(this).attr('id');
207           jQuery('#tr_' + id).addClass('incomplete');
208           incomplete = true;
209       }
210    });
211    if(incomplete){
212         alert('Please complete all fields');
213         return false;
214    }
215    return true;
216}
217
218function setcheckvalue(elid){
219    var val = jQuery('#' + elid).is(':checked') ? 1 : 0;
220    jQuery('#' + elid).val(val);
221}
222
223function add_new_event_name(){
224    var newname = jQuery('#new_event_name').val();
225    var da = {
226        action : 'waca_add_new_event_name',
227        event : newname
228    };
229    console.log(da);
230
231    jQuery.ajax({
232        method : 'POST', data : da, url: php.wfunc,
233        success : function(r){
234            jQuery('#event_names_list').html(r);
235        },
236        error : function(e){
237            console.log('AJAX ERROR');
238        }
239    })
240}
241
242//function display_function_pane(awid, type){
243function create_new_function_tab(awid, type){
244    var user_pid = jQuery('#award_category_chooser').attr('data-pid');
245    jQuery('#aw_tabs li').each(function(){
246        jQuery(this).removeClass('aw-tab-active');
247    });
248    jQuery('#aw_tabs_containers .awcontainer').each(function(){
249        jQuery(this).removeClass('aw-container-active');
250    })
251
252    var da = {
253        award_id : awid,
254        pid : user_pid,
255        atype : type,
256        action : 'get_pane_frame_form'
257    }
258    console.log(da);
259
260    jQuery.ajax({
261        data : da, url : php.form, method : 'POST',
262        success : function(r){
263            //console.log(r);
264            r = JSON.parse(r);
265            jQuery('#aw_tabs').append(r.tab);
266            jQuery('#aw_tabs_containers').append(r.content);
267
268            setTimeout(function(){
269               arm_the_drop_zones(awid);
270            },500);
271
272
273            //mark completed nominations as completed in the tabs:
274            jQuery('li.submitted').each(function(){
275                var id = jQuery(this).attr('id');
276                jQuery('#awtab_' + id).addClass('tab-completed');
277                jQuery('#awtab_' + id + '_c').addClass('content_completed');
278                jQuery('#awtab_' + id + '_c').find('input').each(function(){
279                   jQuery(this).prop('disabled', true);
280                });
281                jQuery('#admin_enable_' + id).show();
282                jQuery('#awtab_' + id + '_c').find('button').each(function(){
283                   if(!jQuery(this).hasClass('reenable')){
284                      jQuery(this).prop('disabled', true);
285                   }
286                });
287
288            });
289        },
290        error : function(e){
291            console.log('AJAX ERROR');
292        }
293    });
294}
295
296function is_in_view(elid){
297    var elementTop = jQuery('#' + elid).offset().top;
298    var elementBottom = elementTop + jQuery('#' + elid).outerHeight();
299    var viewportTop = jQuery(window).scrollTop();
300    var viewportBottom = viewportTop + jQuery(window).height();
301
302    return elementBottom > viewportTop && elementTop < viewportBottom;
303}
304
305function scroll_to_anchor(aid){
306    var aTag = jQuery("#" + aid);
307    jQuery('html,body').animate({scrollTop: aTag.offset().top},'slow');
308}
309
310
311function display_this_award_info(id){
312    //get the award details and show them in #award_details;
313    jQuery('#award_details').html(cc_spinner());
314    jQuery('#award_details').removeClass('minimised');
315    jQuery('#award_details').addClass('maximised');
316
317    var da = {
318        award_id : id,
319        action : 'fetch_award_details_preview'
320    }
321
322    jQuery.ajax({
323        method: 'POST', url: php.form, data : da,
324        success : function(r){
325            jQuery('#award_details').html(r);
326            if(!is_in_view('award_details')){
327               scroll_to_anchor('award_details');
328               jQuery('#link_back_to_list').show();
329            }
330        },
331        error : function(e){
332            console.log('AJAX ERROR');
333        }
334    });
335}
336
337function preview_finalist_file(url, eid){
338    jQuery('.fin_vote_pill').each(function(){
339        jQuery(this).removeClass('active_finalist');
340    });
341    jQuery('#tr_' + eid).addClass('active_finalist');
342    preview_nominee_file(url, eid, true);
343}
344
345function preview_nominee_file(url, eid, fin = false){
346    jQuery('#doc_preview').html(cc_spinner());
347    var ifr = document.createElement('iframe');
348    ifr.setAttribute('id', 'dociframe');
349    ifr.classList.add('expanding_iframe');
350    ifr.classList.add('minimal');
351    ifr.setAttribute('src', url);
352    ifr.setAttribute('width', '100%');
353    ifr.setAttribute('height', '100%');
354    jQuery('#doc_preview').html(ifr);
355    jQuery('.nomination_file').removeClass('emboldened');
356    setTimeout(function(){
357        jQuery('#' + eid).addClass('emboldened')
358        jQuery('#dociframe').removeClass('minimal');
359        jQuery('#dociframe').addClass('maxium');
360    },500);
361
362    if(fin === false){
363        //now record this view for this juror:
364        juror_record_view(eid);
365    }
366
367}
368
369function juror_record_view(eid){
370    var da = {
371        nomid : eid,
372        action : 'record_jury_views_nomination'
373    }
374    jQuery.ajax({
375        method : 'post', url : php.wfunc, data: da,
376        success : function(r){
377            console.log(r);
378            fetch_award_submissions_count_for_jury('jury'); //update the numbers
379        }
380    })
381}
382
383function show_this_awards_nominees(id){
384    //id is the award_id
385    jQuery('#current_award_choice').remove();
386    var cac = document.createElement('div');
387    cac.setAttribute('id', 'current_award_choice');
388    cac.classList.add('shrunk');
389    cac.innerHTML = cc_spinner('small');
390    jQuery('#' + id).append(cac);
391    var da = {
392        awid : id,
393        action : 'fetch_nominees_this_award'
394    }
395    jQuery.ajax({
396        method : 'POST', data : da, url : php.wfunc,
397        success : function(r){
398            jQuery('#current_award_choice').html(r);
399            jQuery('#current_award_choice').removeClass('shrunk');
400            jQuery('#current_award_choice').addClass('expand');
401            jQuery('#current_award_choice').closest('li').addClass('expandli');
402        }, error : function(r){
403            console.log('AJAX ERROR');
404        }
405    })
406}
407
408function remove_show_awtabs(id, verb, recall = false){
409   if(!recall){
410      jQuery('#unchecked-'+id).toggleClass('fa-circle fa-circle-check');
411   }
412
413   console.log('checking verb: ' + verb);
414   if(verb == 'preview'){
415       display_this_award_info(id);
416       return;
417   }
418
419   if(verb == 'jury'){
420       show_this_awards_nominees(id);
421       return;
422   }
423
424   var awardids = [];
425   jQuery('.caward').each(function(){
426      var cid = jQuery(this).attr('id');
427      if(jQuery('#unchecked-' + cid).hasClass('fa-circle-check')){
428          awardids.push(cid);
429          if(!document.getElementById('awtab_' + cid)){
430              console.log('creating_new_tab');
431              create_new_function_tab(cid, verb);
432          }
433      } else {
434         remove_function_tab(cid);
435      }
436   });
437}
438
439function set_active_tab(awid){
440    jQuery('.aw-tab').each(function(){
441       jQuery(this).removeClass('aw-tab-active');
442       if(jQuery(this).attr('id') == 'awtab_' + awid){
443           jQuery(this).addClass('aw-tab-active');
444       }
445    });
446    jQuery('.awcontainer').each(function(){
447       jQuery(this).removeClass('aw-container-active');
448       if(jQuery(this).attr('id') == 'awtab_' + awid + '_c'){
449           jQuery(this).addClass('aw-container-active');
450       }
451    });
452
453    //highlight the chosen award in the list;
454    jQuery('.caward').removeClass('highlight');
455    jQuery('#' + awid).addClass('highlight');
456}
457
458function recall_chosen_awards(tpe){
459    console.log('resellecting chosen');
460    var id = jQuery('.selection_mark .fa-circle-check').first().closest('.caward').attr('id');
461    id = id * 1;
462    if(id > 0){
463       remove_show_awtabs(id, tpe, true);
464       setTimeout(function(){
465         console.log('id : ' + id);
466         set_active_tab(id);
467         expand_parents();
468       }, 700 );
469    }
470
471}
472
473function expand_parents(){
474    jQuery('.selection_mark .fa-circle-check').each(function(){
475        var parent = jQuery(this).closest('li').attr('data-parent');
476        if(parent > 0){
477            jQuery('#' + parent).removeClass('closed');
478            jQuery('#' + parent).addClass('open');
479            jQuery('.award-parent-'+parent).addClass('sub-open');
480        }
481    });
482}
483
484function aw_save_my_selection(pid, prevent_alert = false){
485    //pid is the user's pid
486   var awardids = [];
487   jQuery('.caward').each(function(){
488      var cid = jQuery(this).attr('id');
489      if(jQuery('#unchecked-' + cid).hasClass('fa-circle-check')){
490          awardids.push(cid);
491      }
492   });
493
494   var da = {
495       action : 'save_awards_selection',
496       post_id : pid,
497       aws : awardids
498   }
499   jQuery.ajax({
500       method : 'POST', url: php.form, data : da,
501       success : function(r){
502           //connects the award-id to the nomination/voter with the appropriate joining post.
503           //post-type: nomination-award
504           jQuery('body').removeClass('nom_save_pending');
505           if(!prevent_alert){
506               alert(r + ' chosen awards are selected. Please upload your presentations for them.');
507           }
508       }
509   })
510}
511
512
513function remove_function_tab(awid){
514    jQuery('#awtab_'+awid+'_c').remove();
515    jQuery('#awtab_'+awid).remove();
516}
517
518function nom_next_page(pid){
519    //works for nominations and for voting to display the next page
520    //after verification.
521    if(pid == 16){
522        //catch the bug that is adding a password to the Elementor Header PID...!
523        console.log('error in page_id');
524        return false;
525    }
526    var da = {
527        action : 'display_next_page',
528        post_id : pid
529    }
530    console.log(da);
531
532    jQuery.ajax({
533        method : 'POST', url: php.form, data : da,
534        success : function(r){
535            window.open(r, "_self");
536        }
537    })
538}
539
540function submit_nomination_contact(){
541   if(!waca_form_completed()){
542       return false;
543   }
544   if(!ValidateEmail(jQuery('#email').val())){
545        alert('Please check the email address you have entered.');
546        jQuery('#email').focus();
547        return false;
548   }
549
550   var tcs = jQuery('#tcs').val();
551   if((tcs * 1) !== 1){
552       jQuery('#tcs').focus();
553       alert('Please accept the Terms and Conditions');
554       return false;
555   }
556
557    var sp = document.getElementById("submission_entry_form");
558    eleStyle = window.getComputedStyle(sp);
559    var eleWidth = eleStyle.width;
560    var eleHeight = eleStyle.height;
561    jQuery('#submit_progress').html(cc_spinner('small'));
562    var flds = [];
563    //check if there's a file field:
564    var includes_file = false;
565    jQuery('.collect').each(function(){
566        var tpe = jQuery(this).attr('type');
567        if(tpe == 'file' || tpe == 'FILE'){
568            includes_file = true;
569        }
570    });
571
572    const formData = new FormData();
573
574    jQuery('.collect').each(function(){
575        var tpe = jQuery(this).attr('type');
576        if(tpe == 'file' || tpe == 'FILE'){
577            formData.append(jQuery(this).attr('id'), jQuery(this).prop('files'));
578        } else {
579            formData.append(jQuery(this).attr('id'), jQuery(this).val());
580        }
581
582        var mta = {};
583        mta[jQuery(this).attr('id')] = jQuery(this).val();
584        flds.push(mta);
585    });
586
587    console.log(flds);
588    console.log(formData);
589
590    var da = {
591        action:"new_nomination_contact"
592    }
593    var procda = true, contype = true;
594    if(includes_file){
595        da['nomination'] = formData;
596        procda = false;
597        contype = false;
598    } else {
599        da['nomination'] = flds;
600    }
601    console.log(da);
602    console.log(php.form);
603    //var furl = "https://worldaircargoawards.com/wp-content/plugins/waca-plugin/waca_form_functions.php";
604
605        jQuery.ajax({
606            method : 'POST', data: JSON.stringify(da), url: php.form,
607            processData : procda, contentType: contype,
608            success: function(r){
609                console.log(r);
610                if(r !== 'error'){
611                   jQuery('#submit_progress').html(cc_success());
612                   jQuery('#submission_entry_form').hide();
613                   jQuery('#contact_success').width(eleWidth).height(eleHeight);
614                   jQuery('#contact_success').show();
615                    var el = jQuery('#contact_success');
616                    var elOffset = el.offset().top;
617                    var elHeight = el.height();
618                    var windowHeight = jQuery(window).height();
619                    var offset;
620
621                    if (elHeight < windowHeight) {
622                        offset = elOffset - ((windowHeight / 2) - (elHeight / 2));
623                    }
624                    else {
625                        offset = elOffset - 270;
626                    }
627
628                    var speed = 1500;
629                    jQuery('html, body').animate({scrollTop:offset}, speed);
630                    /*
631                    jQuery('html, body').animate({
632                        scrollTop: jQuery("#contact_success").offset().top
633                    }, speed);
634                    */
635                } else {
636                   jQuery('#submit_progress').html(cc_fail());
637                }
638            },
639            error: function(jqXHR, textStatus, errorThrown) {
640                // Log the error status
641                console.error('Ajax Error:', textStatus);
642
643                // Log the error thrown
644                console.error('Error Thrown:', errorThrown);
645
646                // Log the full response object
647                console.error('Response Object:', jqXHR);
648
649                // Log HTTP status code
650                console.error('HTTP Status:', jqXHR.status);
651
652                // Log response text (often contains detailed error message)
653                console.error('Response Text:', jqXHR.responseText);
654
655                // Try to parse JSON error response if available
656                if (jqXHR.responseJSON) {
657                    console.error('Response JSON:', jqXHR.responseJSON);
658                    console.error('Error Message:', jqXHR.responseJSON.message);
659                }
660
661                // Display user-friendly error message
662                //alert('An error occurred: ' + (errorThrown || 'Unknown error'));
663            },
664            complete: function(jqXHR, textStatus) {
665                console.log('Request completed with status:', textStatus);
666            }
667        });
668}
669
670function new_sponsor_interest(){
671    //collect new sponsor submissions, send verification email, enable pdf for those verified
672    //add to sponsor CRM for Rosa. Send email notification to Rosa on verification.
673   if(!waca_form_completed()){
674       return false;
675   }
676
677    if(!ValidateEmail(jQuery('#email').val())){
678        alert('Please check the email address you have entered.');
679        jQuery('#email').focus();
680        return false;
681    }
682
683    var sp = document.getElementById("sponform");
684    eleStyle = window.getComputedStyle(sp);
685    var eleWidth = eleStyle.width;
686    var eleHeight = eleStyle.height;
687
688    var holder = jQuery('#the_sponsorship_form'); //not needed
689
690    console.log(eleWidth + ' - ' + eleHeight);
691
692    jQuery('#submit_progress').html(cc_spinner('small'));
693
694    var flds = [];
695    jQuery('.collect').each(function(){
696        var mta = {};
697        mta[jQuery(this).attr('id')] = jQuery(this).val();
698        flds.push(mta);
699    });
700
701    console.log(flds);
702
703    var da = {
704        action:"save_new_sponsor_interest",
705        sponsor: flds
706    }
707    jQuery.ajax({
708        method : 'POST', data: da, url: php.wfunc,
709        success: function(r){
710            console.log(r);
711            if(r !== 'error'){
712               jQuery('#submit_progress').html(cc_success());
713               jQuery('#sponform').hide();
714               jQuery('#success_message').width(eleWidth).height(eleHeight);
715               jQuery('#success_message').show();
716            } else {
717               jQuery('#submit_progress').html(cc_fail());
718            }
719        }
720    });
721}
722
723function reveal_form_again(){
724    jQuery('#success_message').hide();
725    jQuery('#sponform').show();
726    jQuery('#email').focus();
727}
728
729function cc_success(){
730     return "<span style='color:green; width:100%; text-align:center;display:inline-block'><i class='fas fa-check'></i></span>";
731}
732
733function cc_fail(){
734     return "<span style='color:red; width:100%; text-align:center;display:inline-block'><i class='fas fa-times'></i></span>";
735}
736
737function waca_is_json(str){
738    try {
739        JSON.parse(str);
740    } catch (e) {
741        return false;
742    }
743    return true;
744}
745
746function set_finalists_this_award(awid){
747    //get all awards in available and selected so we can apply the meta to them accordingly:
748    jQuery('#finalists_save_progress').html(cc_spinner('small'));
749    var finalists = [];
750    var unselected = [];
751    var all = [];
752    //get all unselected pills
753    jQuery('#selectables .pills_holder .nompill').each(function(){
754       unselected.push(jQuery(this).attr('id') * 1);
755       all.push(jQuery(this).attr('id') * 1);
756    });
757    //get all selected pills
758    jQuery('#finalists .pills_holder .nompill').each(function(){
759       finalists.push(jQuery(this).attr('id') * 1);
760       all.push(jQuery(this).attr('id') * 1);
761    });
762    var da = {
763        action : 'set_finalists_this_award',
764        award_id : awid,
765        chosen : finalists,
766        not_chosen : unselected,
767        all_pids : all
768    }
769
770    console.log(da);
771
772    jQuery.ajax({
773        method: 'post', url: php.form, data: da,
774        success: function(r){
775            jQuery('#finalists_save_progress').html(cc_success());
776        },
777        error : function(e){
778            console.log(e);
779            jQuery('#finalists_save_progress').html(cc_fail());
780        }
781    })
782}
783
784function transliterate(word){
785    //this doesn't work for our purpose
786    var answer = ""
787      , a = {};
788
789   a["?"]="YO";a["?"]="I";a["?"]="TS";a["?"]="U";a["?"]="K";a["?"]="E";a["?"]="N";a["?"]="G";a["?"]="SH";a["?"]="SCH";a["?"]="Z";a["?"]="H";a["?"]="'";
790   a["?"]="yo";a["?"]="i";a["?"]="ts";a["?"]="u";a["?"]="k";a["?"]="e";a["?"]="n";a["?"]="g";a["?"]="sh";a["?"]="sch";a["?"]="z";a["?"]="h";a["?"]="'";
791   a["?"]="F";a["?"]="I";a["?"]="V";a["?"]="A";a["?"]="P";a["?"]="R";a["?"]="O";a["?"]="L";a["?"]="D";a["?"]="ZH";a["?"]="E";
792   a["?"]="f";a["?"]="i";a["?"]="v";a["?"]="a";a["?"]="p";a["?"]="r";a["?"]="o";a["?"]="l";a["?"]="d";a["?"]="zh";a["?"]="e";
793   a["?"]="Ya";a["?"]="CH";a["?"]="S";a["?"]="M";a["?"]="I";a["?"]="T";a["?"]="'";a["?"]="B";a["?"]="YU";
794   a["?"]="ya";a["?"]="ch";a["?"]="s";a["?"]="m";a["?"]="i";a["?"]="t";a["?"]="'";a["?"]="b";a["?"]="yu";
795
796   for (i in word){
797     if (word.hasOwnProperty(i)) {
798       if (a[word[i]] === undefined){
799         answer += word[i];
800       } else {
801         answer += a[word[i]];
802       }
803     }
804   }
805   return answer;
806}
807
808function update_menu_order_adv(advid){
809    jQuery('#su_' + advid).html(cc_spinner('small'));
810    var mo = jQuery('#mo_' + advid).val();
811    var da = {
812        action : 'update_advertiser_menu_order',
813        adv : advid,
814        value : mo
815    }
816
817    jQuery.ajax({
818        method: 'POST', url: php.wfunc, data: da,
819        success : function(r){
820           jQuery('#su_' + advid).html(cc_success());
821        }, error : function(r){
822
823        }
824    })
825}
826
827function refresh_this_awards_advertisers(){
828   var award_id = jQuery('#this_awards_ads_table').attr('data-awid');
829   var da = {
830       action : 'fetch_advertisers_this_award_list',
831       awid : award_id
832   };
833
834   jQuery.ajax({
835       method: 'POST', url: php.wfunc, data: da,
836       success : function(r){
837           jQuery('#existing_advertisers').html(r);
838       },
839       error: function(e){
840           console.log('AJAX ERROR');
841       }
842   })
843}
844
845function add_new_advertiser_to_award(){
846    //from waca_shortcodes
847    var adv = jQuery('#finalist_advertisers option:selected').val();
848    var award_id = jQuery('#this_awards_ads_table').attr('data-awid');
849    var leader = jQuery('#is_leaderboard_ad').val();
850    if(leader !== '1'){leader = 0;}
851    var da = {
852        action : 'add_new_award_advertiser',
853        nomid : adv,
854        awid : award_id,
855        leaderboard : leader
856    }
857    console.log(da);
858
859    jQuery.ajax({
860        method: 'POST', url: php.wfunc, data: da,
861        success : function(r){
862            refresh_this_awards_advertisers();
863        }, error : function(e){
864            console.log('AJAX ERROR');
865        }
866    });
867}
868
869function vote_for_this_advertiser(file_id){
870    var check = jQuery('#vote_' + file_id);
871    if(!check.is(':checked')){
872        check.trigger('click');
873    }
874    scroll_to_anchor('finalists_entrance');
875    if(!document.getElementById('vote_' + file_id)){
876      jQuery('#tr_' + file_id).find('td:first').trigger('click');         
877      show_vote_register_modal();
878    }
879}
880
881function remove_advertiser_this_award(adaw){
882    //from waca_shortcodes
883    var da = {
884        action: 'remove_this_adv_award',
885        adawd: adaw
886    }
887    jQuery.ajax({
888        method: 'POST', url: php.wfunc, data: da,
889        success : function(r){
890            refresh_this_awards_advertisers();
891        }, error : function(e){
892            console.log('AJAX ERROR');
893        }
894    });
895}
896
897function fetch_finalist_awards(){
898    var vt  = jQuery('#voting_section').attr('data-hash');
899    var uid = jQuery('#voter_uid').text().trim();
900    var vf  = jQuery('#voting_for').text().trim();
901    var inp = jQuery('#finalist_finder');
902    var fn  = inp.val();
903
904    console.log('The Finalist: ' + fn);
905
906    var finalists = jQuery('#all_finalists').text();
907    var fins = JSON.parse(finalists);
908
909    // Clear previous results
910    jQuery('#award_results').empty();
911
912    for(var i = 0; i < fins.length; i++){
913        var this_fin = fins[i].finalist.toLowerCase().trim()
914                           .replace('(', '')
915                           .replace(')', '');
916        var search   = fn.toLowerCase().trim()
917                           .replace('(', '')
918                           .replace(')', '');
919
920        if(this_fin == search){
921            console.log('finalist_found');
922            var thisfin = fins[i];
923
924            // Build link — global finalists get vt + uid, standard finalists get vt (+ nm if present)
925            var link;
926            if(thisfin.is_global){
927                link = thisfin.link.trim() + '?vt=' + vt;
928                if(uid.length > 0){
929                    link += '&uid=' + encodeURIComponent(uid);
930                }
931            } else {
932                link = thisfin.link.trim() + '?vt=' + vt;
933                if(vf.length > 0){
934                    link += '&nm=' + vf;
935                }
936            }
937
938            var fla    = document.createElement('a');
939            fla.classList.add('finalist_link');
940            fla.setAttribute('target', '_blank');
941            fla.setAttribute('href', link);
942
943            var finbox = document.createElement('div');
944            finbox.classList.add('finalist_link_box');
945
946            var finaw  = document.createElement('div');
947            finaw.classList.add('box_award');
948            finaw.innerHTML = thisfin.award;
949
950            var finfin = document.createElement('div');
951            finfin.classList.add('box_finalist');
952            finfin.innerHTML = 'Finalist: ' + fn;
953
954            var finvt  = document.createElement('div');
955            finvt.classList.add('votenow');
956            finvt.innerHTML = 'Vote Now';
957
958            finbox.append(finaw);
959            finbox.append(finfin);
960            finbox.append(finvt);
961            fla.append(finbox);
962            jQuery('#award_results').append(fla);
963        }
964    }
965}
966
967function expand_sub_menu(id){
968    jQuery('.parent_' + id).toggleClass('expanded');
969    jQuery('#caret_' + id).toggleClass('caret_show');
970}
971
972function set_finalist(id, type){
973    //for adding or removing finalists from award-category pages as admin
974    var wd = Math.round(jQuery('#' + id).width()) + 3;
975    var pill = jQuery('#' + id).prop('outerHTML');
976    jQuery('#' + id).remove();
977    if(type == 'add'){
978        pill = pill.replace('add', 'remove');
979        pill = pill.replace('fa-circle-plus', 'fa-circle-minus');
980        jQuery('#finalists .pills_holder').append(pill);
981    } else {
982        pill = pill.replace('fa-circle-minus', 'fa-circle-plus');
983        pill = pill.replace('remove', 'add');
984        jQuery('#selectables .pills_holder').append(pill);
985    }
986    jQuery('#' + id).css('width', wd + 'px');
987}
988
989function cc_spinner(sm=null, type="div"){
990    disp = " display:flex; "
991    if(type == 'span'){
992        disp = ' display:inline-block;margin-left:5px; '
993    }
994    var flex = '<' + type + ' style="' + disp + ' width:100%;flex-direction:column;align-items:center;font-size:1.2em" id="spinner" >'
995    if(sm !== null){
996        //disp += ' font-size: 1em; color:green '
997        flex = '<' + type + ' style="' + disp + ' width:100%;flex-direction:column;align-items:center;font-size:0.5em;color:green" id="spinner" >'
998    }
999    var spin =  '<' + type + ' class="fa-3x"><i class="fas fa-spinner fa-spin"></i></' + type + '>';
1000    var fin = '</' + type + '>'
1001    return flex + spin + fin;
1002}
1003

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.