PageSourceSearch

https://careerpilot.org.uk/assets/js/common.js?1591281671

js careerpilot.org.uk collected 2026-10-01 12:10:46 UTC 5,270 bytes, 174 lines download raw bytes

1$(function(){
2	$('[name=btnCancel]').on('click', function(){
3		window.location.href = cancelLink;
4	});
5
6	$('input[type=text], input[type=email], input[type=password], select, textarea, .btn.dropdown-toggle, input[type=checkbox], input[type=radio]').on('focus', function(){
7		var parent = $(this).closest('.form-group');
8		if (parent.length === 0){
9			parent = $(this).closest('.checkbox');
10		}
11		if (parent.length === 0){
12			parent = $(this).closest('.radio');
13		}
14		if ($(parent).hasClass('has-error')){
15			$(parent).removeClass('has-error');
16			if ($(parent).children('.error-message').length > 0){
17				$(parent).children('.error-message').remove();
18			}
19		}
20	});
21
22	$('.flash-message a').on('click', function(e){
23		e.preventDefault();
24		$(this).parents('.flash-message').fadeOut();
25	});
26
27	$('#choices_alert').on('close.bs.alert', function() {
28		setCookie('choices_alert', 1, 60);
29	});
30
31	$('a.disabled').on('click', function(e){
32		e.preventDefault();
33		$(this).blur();
34		return false;
35	});
36
37	//Yamm
38	$(document).on('click', '.yamm .dropdown-menu', function(e) {
39		e.stopPropagation();
40	});
41
42	var uri = new URI();
43	var host = uri.protocol()+'://'+uri.host();
44
45	$('a[href^=http]:not([href^="'+host+'"],[href^="http://parentzone.careerpilot.org.uk"])').on('click', function(e) {
46		e.preventDefault();
47		window.open($(this).attr("href"));
48		return false;
49	});
50
51	$('.table-responsive').on('show.bs.dropdown', function () {
52		$('.table-responsive').css( "overflow", "inherit" );
53	});
54	$('.table-responsive').on('hide.bs.dropdown', function () {
55		$('.table-responsive').css( "overflow", "auto" );
56	});
57
58});
59
60var resizeHeights = function(targetSelector) {
61	var target = $(targetSelector);
62	// reset height
63	target.height('auto');
64	// Get an array of all element heights
65	var elementHeights = target.map(function() {
66		return $(this).height();
67	}).get();
68	// Math.max takes a variable number of arguments
69	// `apply` is equivalent to passing each height as an argument
70	var maxHeight = Math.max.apply(null, elementHeights);
71	// Set each height to the max height
72	target.height(maxHeight);
73};
74
75function handleFormErrors(errors){
76	if (typeof errors !== 'undefined' && errors.length > 0){
77		$.each(errors, function(key, error){
78			var input = $('[name^='+error.field+']');
79			if (typeof input !== 'undefined'){
80				var errorMsg = $(document.createElement('div')).addClass('error-message').html(error.message);
81				var parent = $(input).closest('.form-group');
82				if (parent.length === 0){
83					parent = $(input).closest('.checkbox');
84				}
85				if (parent.length === 0){
86					parent = $(input).closest('.radio');
87				}
88				$(parent).addClass('has-error');
89				$(errorMsg).appendTo($(parent));
90			}
91		});
92	}
93}
94
95function printError(errMsg){
96	// The main error message div
97	var errDiv = $(document.getElementById('service-error'));
98	if (typeof errDiv !== 'undefined'){
99		$(errDiv).remove();
100	}
101	errDiv = $(document.createElement('div')).attr('id', 'service-error').addClass('alert alert-danger alert-dismissable fade in');
102	var btn  = $(document.createElement('button')).attr({type:'button', 'data-dismiss':'alert', 'aria-hidden':'true'}).html('×').addClass('close');
103	var span = $(document.createElement('span')).attr('id', 'service-error-message').html(errMsg);
104	$(errDiv).append(btn).append(span).appendTo('#service-error-container').show();
105}
106
107var handleAjaxError = function(jqXHR, textStatus, errorThrown){
108	if (jqXHR.status === 401){
109		printError('Authentication required. Your session may have timed out.');
110	}
111	else if (jqXHR.status === 404){
112		printError('The data source cannot be found.');
113	}
114	else if (jqXHR.status === 500){
115		printError('A server-side error occurred.');
116	}
117	else {
118		printError('An unexpected error occurred. Text status: '+textStatus+'. Error thrown: '+errorThrown);
119	}
120	$('.dataTables_processing').css('display', 'none');
121};
122
123// Return the current scrollbar offsets as the x and y properties of an object
124function getScrollOffsets(){
125	// This works for all browsers except IE versions 8 and before
126	if (window.pageXOffset != null){
127		return {
128			x: window.pageXOffset,
129			y: window.pageYOffset
130		};
131	}
132
133	// For browsers in Standards mode
134	var doc = window.document;
135	if (document.compatMode === 'CSS1Compat'){
136		return {
137			x: doc.documentElement.scrollLeft,
138			y: doc.documentElement.scrollTop
139		};
140	}
141
142	// For browsers in Quirks mode
143	return {
144		x: doc.body.scrollLeft,
145		y: doc.body.scrollTop
146	};
147}
148
149function capitalizeFirstLetter(string) {
150    return string.charAt(0).toUpperCase() + string.slice(1);
151}
152
153function setCookie(cname, cvalue, exdays) {
154    var d = new Date();
155    d.setTime(d.getTime() + (exdays*24*60*60*1000));
156    var expires = "expires="+ d.toUTCString();
157    document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
158}
159
160function internalPageLinks(){
161	var i = 0;
162	$('#main-content h3').each(function(){
163		var $heading = $(this);
164		if (i == 0) {
165			$('#anchor_links').append('<div class="list-group" role="navigation"></div>');
166		}
167		i++;
168		$heading.before('<a id="link-'+i+'"></a>');
169		$('#anchor_links .list-group').append('<a class="list-group-item" href="#link-'+i+'">'+$.trim($heading.text())+'<i class="fa fa-hand-o-down pull-right"></i></a>');
170	});
171	if (i > 1) {
172		$("#anchor_links").removeClass('hide');
173	}
174}

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.