PageSourceSearch

https://essentialcu.org/scripts/main.js?ver=202610071100

js essentialcu.org collected 2026-10-09 18:13:44 UTC 23,066 bytes, 676 lines download raw bytes

1// perform on load initialization
2var errors_occured = false;
3var call_was_successful = false;
4var response_area = '';
5var encoded_params = '';
6var ajax_action = '';
7var JQajaxResult = false;
8var num_of_submits = 0;
9var datechk_format = 'mm/dd/yyyy';
10
11$(function(){
12   // set default ajax settings
13    $.ajaxSetup({
14        type: 'GET',
15        url: '/render.php',
16        timeout: 15000,
17 		async: false,
18        cache: false
19    })
20
21   // validate defaults
22
23   jQuery.validator.setDefaults({
24        onfocusout: false,
25        onkeyup: false,
26        onclick: false,
27        focusInvalid: false,
28        focusCleanup: true,
29        errorElement: "div",
30        errorClass: "errormsg",
31        errorPlacement: function(error, element) {
32            // if a placement element exists, use it, otherwise insert the message after the element
33            if($('#' + element.attr('id') + '_errmsg').length > 0){
34                if(element.attr('id') == 'address1' || element.attr('id') == 'address2'){
35                    error.appendTo('#address_errmsg');
36                } else {
37                    error.appendTo('#' + element.attr('id') + '_errmsg');
38                }
39            } else {
40                // no errmsg container exists for this eleement
41                if(element.attr('id') == 'address1' || element.attr('id') == 'address2'){
42                    error.appendTo('#address_errmsg');
43                    error.insertAfter(element);
44                } else {
45                    if(element.attr('type') == 'radio'){
46                       $(element).closest('div').append(error);
47                    } else {
48                        error.insertAfter(element);
49                    }
50
51                }
52
53            }
54
55        }
56    });
57
58
59	// footnote symbol link to footnote and back
60	$('body').on("click", '.JQfootnoteLink', function (e) {
61		footnoteID = $(this).attr('aria-describedby');
62		symbolID = $(this).attr('id');
63		$('#' + footnoteID).find('a').attr('href', '#' + symbolID);
64	});
65	
66    // JQtrack hrefs are trackable events
67    $('.JQtrack').on('click', function(e){
68        vTracker($(this));
69    });
70
71    // JQnewWindow hrefs open in a new window
72    //  (no tracking, an href with this class will have some other tracked class)
73
74    $('body').on("click", 'a.JQnewWindow:not([href^="mailto:"])', function (e) {
75        e.preventDefault();
76        window.open(this.href);
77    });
78
79    // JQfaq toggler
80    //  div to expand/toggle located in anchor's data-expid arg
81    $('body').on("click", 'a.JQfaq', function (e) {
82        e.preventDefault();
83        expid = $(this).data('expid');
84        $('#'+expid).slideToggle();
85        if($('#'+expid).is(':visible')) {
86            vTracker($(this));
87            fid = $(this).data('id');
88            vtracklocal('FAQ',fid);
89        }
90    });
91
92    // open speedbump in iframe modal dialog
93    $('*[class*="JQspeedbump"]').on('click', function(e){
94        e.preventDefault();
95        href = $(this).attr('href');
96        id = $(this).attr('id');
97        linktext = $(this).text();
98
99        var wWidth = $(window).width();
100        var dWidth = Math.round(wWidth * 0.8);
101        var wHeight = $(window).height();
102        var dHeight = Math.round(wHeight * 0.8);
103
104        // support for alternate speedbump styles:
105        bumpstyle = encodeURIComponent($(this).attr('class'));
106
107        $('#dialog_content').load('/render.php',{
108            mod: "speedbump",
109            action: "display",
110            params: 'id~' + id + '|linktext~' + linktext+'|href~'+href+'|style~'+bumpstyle+'|ww~'+wWidth+'|wh~'+wHeight}
111        );
112
113        if(linktext != ''){
114        	speedbumptitle = 'External Link - ' + linktext;
115		} else {
116			speedbumptitle = 'External Link';
117		}
118
119       $('#dialog').dialog({
120            autoOpen: false,
121            // position: { my: "center", at: "center", collision: 'fit' }, //removed as part of jquery3 update
122            modal: true,
123            overlay: { opacity: 0.1, background: "black" },
124            title: speedbumptitle,
125            height: "auto",
126 			maxHeight: dHeight,
127			width: '80%',
128            open: function(){
129                // TJ; the following closes modal on outside click:
130                $('.ui-widget-overlay').on('click', function () { $(this).parents("body").find(".ui-dialog-content").dialog("close"); });
131               
132            },
133            buttons: {
134                'Go': function() {
135                    vTracker($(this),'Speedbumps','Exit',href);
136                    $(this).dialog('close');
137
138                    // open new window for all speedbumps:
139                    //setTimeout(function() {
140                        window.open(href);
141                    //}, 100);
142
143                    // or if client requests same window always:
144                    //window.location.href = href;
145                },
146                'Stay': function() {
147                    vTracker($(this),'Speedbumps','Stay',href);
148                    $(this).dialog('close');
149                }
150            }
151       });
152
153        $('#dialog').dialog("open");
154
155    });
156
157    // open iframe modal window
158    $('a.JQmodal').on('click', function(e){
159        e.preventDefault();
160        src = $(this).attr('href');
161        if($(this).attr('data-title') !== undefined) {
162            wtitle = $(this).attr('data-title');
163        } else {
164            wtitle = '';
165        }
166
167        var wWidth = $(window).width();
168        var dWidth = Math.round(wWidth * 0.8);
169        var wHeight = $(window).height();
170        var dHeight = Math.round(wHeight * 0.8);
171        // check for protocol and adjust for http/https
172        if(window.location.protocol == 'https:'){
173            if (/http:/i.test(src)) {
174                src = src.replace(/http:/ig, "https:");
175            } else if(src.substr(0,2) != '//'){
176                if(src.substr(0,1) == '/'){
177                    src = "https://" + window.location.hostname + src;
178                }
179            }
180        }
181
182        $('<iframe src="' + src + '" />').dialog({
183              autoOpen: true,
184              title: wtitle,
185              width: dWidth,
186              height: dHeight,
187              modal: true,
188              resizable: true,
189              open: function(){
190                  $(this).css('width','98%');
191                  // TJ; the following closes modal on outside click:
192                  $('.ui-widget-overlay').on('click', function () { $(this).parents("body").find(".ui-dialog-content").dialog("close"); });
193              },
194              buttons: {
195                  'Close': function() {
196                      $(this).dialog('close');
197                  }
198              }
199        });
200    });
201
202   // FAQ Slider logic
203   $(".JQSlider").on('click', function(e){
204        event.preventDefault();
205        this_href = $(this).attr("href").replace(/javascript:/i,'');
206        eval(this_href);
207        div_2_toggle = $(this).parent(".JQSlider_parent").children(".slider_content").get(0);
208        if($(this).parent(".JQSlider_parent").children(".faq_icon").length > 0){
209            faq_icon = $(this).parent(".JQSlider_parent").children(".faq_icon").get(0);
210            if($(faq_icon).attr("src") == '/img/icon_faq.gif'){
211                $(faq_icon).attr({ src : "/img/icon_faq_open.gif"});
212            } else {
213                $(faq_icon).attr({ src : "/img/icon_faq.gif"});
214            }
215        }
216        $(div_2_toggle).slideToggle() ;
217    });
218
219    
220   // interior content tabs
221    $('body').on("click", '.ca_tabs li', function (e) {
222        e.preventDefault();
223        $('.ca_tabs').find('.current').removeClass("current");
224        $(this).addClass('current');
225
226        item_2_select = 'ca_' + $(this).index();
227        $('div[class^=ca_panel]:visible').hide();
228
229        $('div[class~=' + item_2_select + ']').show();
230
231        vTracker($(this),'Tabs','Tab Clicks',$(this).text());
232   });
233
234
235   // establish normal dialog parameters
236   $('#dialog').dialog({
237        autoOpen: false,
238        // position: { my: "center center", at: "center center"}, //removed as part of jquery3 update
239        modal: true,
240        height: 'auto',
241        width: 450,
242        buttons: {
243            'Ok': function() {
244              $(this).dialog('close');
245            }
246        }
247
248   });
249
250    // additional validator methods
251   jQuery.validator.addMethod("phoneUS", function(phone_number, element) {
252        phone_number = phone_number.replace(/\s+/g, "");
253    	return this.optional(element) || phone_number.length > 9 &&
254    		phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
255   }, "Please specify a valid phone number (format ###-###-####)");
256
257
258    // Track PDF links
259    $('body').on("click", 'a[href$=".pdf"]', function (e) {
260        vTracker($(this),'PDF Document Views',$(this).text(),$(this).attr('href'));
261   });
262
263   $('.formDatePicker').datepicker({showSecond: false, dateFormat:'mm/dd/yy'});
264
265   // validate date check mm/dd/yyyy
266    jQuery.validator.addMethod(
267		"dateCHK",
268		function(value, element) {
269			var check = false;
270            datechk_format = 'mm/dd/yyyy';
271            if($(element).is('[data-date-format]')){
272                datechk_format = $(element).attr('data-date-format');
273                switch($(element).attr('data-date-format')){
274                    case 'mm/dd/yyyy':
275                        var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
276                        if( re.test(value)){
277            				var adata = value.split('/');
278            				var mm = parseInt(adata[0],10); // was gg (giorno / day)
279            				var dd = parseInt(adata[1],10); // was mm (mese / month)
280            				var yyyy = parseInt(adata[2],10); // was aaaa (anno / year)
281                            var xdata = new Date(yyyy,mm-1,dd);
282            				if ( ( xdata.getFullYear() == yyyy ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == dd ) ){
283            					check = true;
284            				} else {
285            					check = false;
286                            }
287                        }
288                        break;
289                    case 'mm/yyyy':
290                        var re = /^\d{1,2}\/\d{4}$/;
291                        if( re.test(value)){
292            				var adata = value.split('/');
293            				var mm = parseInt(adata[0],10); // was gg (giorno / day)
294            				var dd = 1; // was mm (mese / month)
295            				var yyyy = parseInt(adata[1],10); // was aaaa (anno / year)
296                            var xdata = new Date(yyyy,mm-1,dd);
297            				if ( ( xdata.getFullYear() == yyyy ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == dd ) ){
298            					check = true;
299            				} else {
300            					check = false;
301                            }
302                        }
303                        break;
304                    case 'yyyy/mm/dd':
305                        var re = /^\d{4}\/\d{1,2}\/\d{1,2}$/;
306                        if( re.test(value)){
307            				var adata = value.split('/');
308            				var yyyy = parseInt(adata[0],10); // was gg (giorno / day)
309            				var mm = parseInt(adata[1],10); // was mm (mese / month)
310            				var dd = parseInt(adata[2],10); // was aaaa (anno / year)
311                            var xdata = new Date(yyyy,mm-1,dd);
312            				if ( ( xdata.getFullYear() == yyyy ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == dd ) ){
313            					check = true;
314            				} else {
315            					check = false;
316                            }
317                        }
318                        break;
319                    case 'freeform':
320                        check = true;
321                        break;
322                    case 'useDatePicker':
323                        check = true;
324                        break;
325                    default:
326                        var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
327            			if( re.test(value)){
328            				var adata = value.split('/');
329            				var mm = parseInt(adata[0],10); // was gg (giorno / day)
330            				var dd = parseInt(adata[1],10); // was mm (mese / month)
331            				var yyyy = parseInt(adata[2],10); // was aaaa (anno / year)
332            				var xdata = new Date(yyyy,mm-1,dd);
333            				if ( ( xdata.getFullYear() == yyyy ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == dd ) ){
334            					check = true;
335            				} else {
336            					check = false;
337                            }
338            			} else {
339            				check = false;
340                        }
341                        break;
342                }
343            } else {
344                var re = /^\d{1,2}\/\d{1,2}\/\d{4}$/;
345    			if( re.test(value)){
346    				var adata = value.split('/');
347    				var mm = parseInt(adata[0],10); // was gg (giorno / day)
348    				var dd = parseInt(adata[1],10); // was mm (mese / month)
349    				var yyyy = parseInt(adata[2],10); // was aaaa (anno / year)
350    				var xdata = new Date(yyyy,mm-1,dd);
351    				if ( ( xdata.getFullYear() == yyyy ) && ( xdata.getMonth () == mm - 1 ) && ( xdata.getDate() == dd ) ){
352    					check = true;
353    				} else {
354    					check = false;
355                    }
356    			} else {
357    				check = false;
358                }
359            }
360			return this.optional(element) || check;
361		},
362        function(params, element) {
363            return formatValidatorDateChkMsg();
364        }
365	);
366
367    // validate zip code check with optional last four
368    jQuery.validator.addMethod(
369		"zipCHK",
370		function(value, element) {
371			var check = false;
372			var re = /^\d{5}(-\d{4})?$/;
373			if( re.test(value)){
374				check = true;
375			} else {
376                check = false;
377            }
378            return this.optional(element) || check;
379		},
380		"Please enter a valid zip code"
381	);
382
383    // validate select box selected items value must not be blank
384   jQuery.validator.addMethod(
385        "JQforceSelect",
386        function(value, element){
387            var check = false;
388            if(value == ''){
389                check = false;
390            } else {
391                check = true;
392            }
393
394            return check;
395        },
396        "Select an item from the list"
397   );
398
399   // validate captcha validation
400    jQuery.validator.addMethod(
401		"JQcaptcha",
402		function(value, element) {
403            var JQajaxResult = false;
404            var formID = $(element).closest("form").attr('id');
405            if($('input[name=serial_number]').length == 0){
406                serial_num = '';
407            } else {
408                serial_num = $('input[name=serial_number]').val();
409            }
410            var url_params = {
411                // if more than one captcha, access by id will fail validation
412                fks: $('#'+formID).find('input[name="formkey_sys"]').val(),
413                fku: $('#'+formID).find('input[name="formkey_user"]').val(),
414                serial_number: serial_num
415            };
416            encoded_params = $.param(url_params);
417
418            $.ajax({
419                type: "GET",
420                url: "/scripts/captcha_validator.php",
421				dataType: 'json',
422				async: false,
423                data: encoded_params})
424             .done(function(resultsObj){
425
426                    if('status' in resultsObj && resultsObj.status == 'success'){
427                        if('serial_number' in resultsObj){
428                            if($('input[name=serial_number]').length == 0){
429                                $('<input>').attr({
430                                        type: 'hidden',
431                                        id: 'serial_number',
432                                        name: 'serial_number',
433                                        value: resultsObj.serial_number
434                                }).appendTo('#' + formID);
435                            }
436                        }
437                        JQajaxResult =  true;
438                    } else {
439                        JQajaxResult =  false;
440                    }
441             })
442             .fail(function(results){
443                  alert("We're sorry, our processing system is currently unavailable. Please try again later.");
444                  JQajaxResult = false;
445             });
446            return JQajaxResult;
447		},
448		"Correct security field code is required."
449	);
450
451	// handle hash URLs to thispage.html#goto_3 to automatically select and scroll to tabbed content
452	if(window.location.hash) {
453		var hash = window.location.hash.substring(1);
454		if(hash.substr(0,5) == 'goto_') {
455			var hparts = hash.split('_');
456			var tabnum = parseInt(hparts[1]);
457			$('.ca_tabs li:nth-child(' + tabnum + ')').trigger('click');
458			var anch = 'goto_' + tabnum;
459			if($('#'+hash).length > 0){
460				$('html, body').animate({ scrollTop: $('#'+anch).offset().top }, 'slow');
461			}
462		}
463	}
464
465	// needed to support #goto_X links to current page:
466	$("a[href*='#goto_']").on('click', function(e){
467		var hashf = this.href.split('#');
468		var hash = hashf[1];
469		if(hash.substr(0,5) == 'goto_') {
470			if (hashf[0] == window.location.href.split("#")[0]) {
471				var hparts = hash.split('_');
472				var tabnum = parseInt(hparts[1]);
473				$('.ca_tabs li:nth-child(' + tabnum + ')').trigger('click');
474				var anch = 'goto_' + tabnum;
475				if($('#'+hash).length > 0){
476					$('html, body').animate({ scrollTop: $('#'+anch).offset().top }, 'slow');
477				}
478			}
479		}
480	});
481
482    /* mod: v2.6-000 [3]
483       date: 2016-Oct-21
484       who: brian
485       onclick evemt for taggling a radio button when a tag other than label is used. this simulates a label click
486    */
487    $('body').on("click", '.JQradioClick', function (e) {
488        $(this).prev('input').trigger('click');
489
490    });
491    
492	// open/close the hidden container.
493	$(".JQslideToggle, .JQslideToggle_close_button").on('click', function(e) {
494		e.preventDefault();
495		$clicked_item = $(this);
496		if($(this).hasClass('JQslideToggle')){
497			if($(this).data('container-class-to-close') && $(this).data('container-class-to-close') != '') {
498				// close all open containers
499				class_to_close = $(this).data('container-class-to-close');
500				$('body').find('.' + class_to_close).each(function(){
501					if($(this).is(":visible")){
502						$(this).hide();
503					}
504				});
505			}
506			// toggle an indicator if present
507			if($clicked_item.hasClass('content-open') || $clicked_item.hasClass('content-closed')){
508				if($('#' + $clicked_item.data('container-id-to-open')).is(':hidden')){
509					$clicked_item.removeClass('content-closed').addClass('content-open');
510				} else {
511					$clicked_item.removeClass('content-open').addClass('content-closed');
512				}
513			}
514			$('#' + $clicked_item.data('container-id-to-open')).slideToggle();
515		} else {
516			$('#' + $clicked_item.data('container-id-to-close')).slideToggle();
517		}
518	});
519    upscaleImages();
520
521});
522function formatValidatorDateChkMsg(){
523    return 'Please enter a valid date (' + datechk_format + ')';
524}
525// Voice Tracker
526function vTracker(e,ec,ea,el) {
527
528    var EventCategory = 'UNKNOWN';
529    var EventAction = 'Click';
530    var EventLabel = 'UNKNOWN';
531
532    if(ec) { EventCategory = ec;}
533    if(ea) { EventAction = ea;}
534    if(el) { EventLabel = el;}
535
536    if(!ec && e.attr('data-cat')) {
537        EventCategory = e.data('cat');
538    }
539
540    if(!ea && e.attr('data-action')) {
541        EventAction = e.data('action');
542    }
543
544    if(!el && e.attr('data-label')) {
545        EventLabel = e.data('label');
546    }
547
548    if(EventAction=='URL') {
549        EventAction = window.location.pathname;
550    }
551
552    if(!el && !e.attr('data-label') && e.text()) {
553        EventLabel = e.text();
554    }
555
556 
557
558    try {
559		// support the two generations of analytics:  _gaq if traditional async ga.js, ga if analytics.js
560		if (typeof (_gaq) !== "undefined") {
561			_gaq.push(['_trackEvent', EventCategory,EventAction,EventLabel]);
562		} else if (typeof (ga) !== "undefined") {
563			ga('send', 'event', EventCategory,EventAction,EventLabel);
564		}
565    } catch(err) {
566        // no action.
567    }
568
569    // some trackable events do not navigate, so a required timeout (delay)
570    //   will need to be added to events that navigate (after the call to vTracker)
571    //setTimeout(function() { document.location.href = TargetHref; }, 100);
572
573}
574
575function vtracklocal(t,i) {
576
577            var url_params = { t:t,i:i };
578            encoded_params = $.param(url_params);
579            $.ajax({
580                type: "GET",
581                url: "/scripts/vtrack.php",
582                data: encoded_params
583            });
584}
585
586// upscale default-size content images to optimize file size for bandwidth
587//  by providing image file of dimensions to match image width as
588//  a percentage of the content container's width
589function upscaleImages() {
590  
591    // set this to the ID of the content container
592    //  to be the width reference to which images will
593    //  be matched
594    var containr = 'cimg-container';
595    var fallbacksize = 320;
596
597    var idx = 1;
598
599  	$(".cimg").each(function(index){
600      var par = $(this).closest(".cimg-container");
601      if(par.length > 0){
602          var caw = par.width();
603          // check to see that this is reasonable and not broken:
604          if(caw<50 || caw>2400){
605            caw = fallbacksize;
606          }
607      } else {
608        // establish reasonable fallback
609        var caw = fallbacksize;
610      }
611
612
613
614    var isrc = $(this).attr('src');
615    var shouldupdate = 0;
616    var dinfo = '';
617    var classname = '';
618    var classscale = 1.0;
619
620    var idealwidth = caw;
621
622     for(i=0;i<img_cimg_scales.length;i++) {
623       classname=img_cimg_scale_classes[i];
624       classscale=img_cimg_scales[i];
625
626       if($(this).hasClass(classname)) {
627         idealwidth = Math.round(caw * classscale);
628         shouldupdate = 1;
629
630         // build some debug info:
631         dinfo += "<b>image #" + idx + "</b> (class " + classname + ")<br />";
632         dinfo += classscale + ' x ' + caw + ' = optimal width of <b>' + idealwidth + "</b> pixels.<br />";
633         dinfo += 'initial src = ' + isrc + "<br />";
634
635
636       }
637     }
638
639
640
641        if (shouldupdate > 0) {
642          chosen_width = img_avail_widths[0];
643          // loop through avail widths and choose closest without going over
644          for(i=0;i<img_avail_widths.length;i++) {
645            if(idealwidth <= img_avail_widths[i]) {
646              chosen_width = img_avail_widths[i];
647            }
648          }
649
650          for(i=img_avail_widths.length-1;i>=0;i--) {
651            if(chosen_width == img_avail_widths[i]) {
652              dinfo += "<b>" + img_avail_widths[i] + "</b>";
653            } else {
654              dinfo += img_avail_widths[i];
655            }
656            dinfo += "&nbsp;&nbsp;";
657          }
658
659
660            if(chosen_width > 0) {
661        		isrc = $(this).attr('src');
662                isrc = isrc.replace("/default/","/"+chosen_width+"/");
663                dinfo += "<br />updated src = " + isrc + "<br />";
664        		$(this).attr('src',isrc);
665            }
666
667            // this will produce debug info before each upscaled image
668            //$('<p style="display: block; padding: 8px; border: solid 1px #fff; border-color: #c44e53; border-radius: 4px; font-size: 0.75em; width: auto;">'+dinfo+'</p>').insertBefore($(this));
669
670        }
671
672        idx++;
673
674  	});
675
676}

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.