PageSourceSearch

https://www.getinvolved.qld.gov.au/gi/js/public/survey.js

js getinvolved.qld.gov.au collected 2026-09-24 18:35:48 UTC 7,780 bytes, 208 lines download raw bytes

1$(function() {
2	// Other choices
3	$('input.otherSpecify').each(function() {
4		var otherSpecify = $(this);
5		otherSpecify.siblings('select').change(function() {
6			otherSpecify.toggle($(this).val() == messages.other);
7		}).change();
8		otherSpecify.parent().find('input:checkbox:last').change(function() {
9			otherSpecify.toggle($(this).is(':checked'));
10		}).change();
11		otherSpecify.parent().find('input:radio').change(function() {
12			otherSpecify.toggle($(this).val() == messages.other);
13		}).change();
14	});
15	$('.otherSpecify').hide();
16	$('input.otherSpecify').hide();
17	// Ranking choices
18	$('ol.ordered + input:hidden').each(function() {
19		var currentHidden = $(this);
20		var currentList = currentHidden.prev('ol');
21		currentList.prepend('<li class="cutoff"><input style="visibility: hidden"/>' + messages.cutOff + '</li>');
22		if (currentHidden.val()) { // Restore selected order
23			var splitHidden = currentHidden.val().split('|');
24			for (var i = splitHidden.length - 1; i >= 0; i--) {
25				currentList.find('li').filter(function() {
26						return $.trim($('label', this).text()) == splitHidden[i];
27					}).prependTo(currentList);
28			}
29		}
30	});
31	$('ol.ordered').each(function() {
32		var ol = $(this);
33		ol.sortable({stop: function(event, ui) {
34			renumberItems(ui.item.parent('ol'));
35			ui.item.hide().show();
36		}}).
37		find('li').prepend('<img src="' + contextPath + '/img/order.gif" alt="' + messages.drag + '" title="' + messages.drag + '"/>').
38		find('input').keydown(function(e) {
39			var li = $(this).closest('li');
40			switch (e.keyCode) {
41				case 38: // Up key
42					li.insertBefore(li.prev());
43					renumberItems(li.parent());
44					break;
45				case 40: // Down key
46					li.insertAfter(li.next());
47					renumberItems(li.parent());
48					break;
49			}
50			$(this).focus();
51		}).change(function() {
52			var ol = $(this).closest('ol');
53			var li = $(this).closest('li')[0];
54			var lis = ol.find('li').
55				map(function() {
56					var val = $(this).hasClass('cutoff') ? 1e6 - 1 :
57						parseInt($(this).find('input').val(), 10);
58					val = isNaN(val) || val === '' ? 1e6 : val - (this == li ? 0.5 : 0) ;
59					return {li: this, val: val};
60				}).
61				get().sort(function(a, b) {
62					return a.val - b.val;
63				});
64			$.each(lis, function() {
65				$(this.li).appendTo(ol);
66			});
67			renumberItems(ol);
68		}).first().change();
69	});
70
71
72    for (var i = $('.group').length - 1; i >= 0; i--) {
73       $('.group')[i].addEventListener("change", groupResize);
74    }
75
76
77	// Textareas
78	$('#qg-content textarea').each(function() {
79		var max = $(this).next('span.initMaxLength').text();
80		$(this).maxlength({max: max}).autoGrow({minRows: Math.min(20, max / 100)});
81	});
82	// RatingMatrix stripes
83	$('table.ratingMatrix > tbody > tr:odd').css('background-color', '#EDF6FF');
84	// Demographics
85	$('#consultationResponse\\:demographicsDiv\\:outsideAustralia').change(function() {
86			if ($(this).is(':checked')) {
87				$('#consultationResponse\\:demographicsDiv\\:location').attr('disabled', true);
88			}
89			else {
90				$('#consultationResponse\\:demographicsDiv\\:location').removeAttr('disabled');
91			}
92		}).change();
93	// Contacts
94	var contactMe = $('#consultationResponse\\:contactMeDiv\\:contactMe').change(function() {
95			$('div.contacts').toggle(contactMe.is(':checked'));
96			$(window).triggerHandler('resize');
97			$('#consultationResponse\\:contactsMethodDiv\\:viaEmail,#consultationResponse\\:contactsMethodDiv\\:viaPhone,#consultationResponse\\:contactsMethodDiv\\:viaPost').change();
98		});
99	contactMe.change();
100	$('#consultationResponse\\:contactsMethodDiv\\:viaEmail').change(function() {
101			$('div.contactEmail').toggle($(this).is(':checked') && contactMe.is(':checked'));
102		}).change();
103	$('#consultationResponse\\:contactsMethodDiv\\:viaPhone').change(function() {
104			$('div.contactPhone').toggle($(this).is(':checked') && contactMe.is(':checked'));
105		}).change();
106	$('#consultationResponse\\:contactsMethodDiv\\:viaPost').change(function() {
107			$('div.contactPost').toggle($(this).is(':checked') && contactMe.is(':checked'));
108		}).change();
109	$('#sameAsAboveEmail').change(function() {
110		var same = $(this).is(':checked');
111		if (same && $('#consultationResponse\\:moderationEmailDiv\\:moderationEmail').val().length > 0) {
112			$('#consultationResponse\\:contactsEmailDiv\\:contactEmailAddress').val($('#consultationResponse\\:moderationEmailDiv\\:moderationEmail').val());
113		}
114		if (same && $('#consultationResponse\\:moderationEmailDiv\\:moderationEmail').val().length == 0) {
115			$('#contactEmailAddressError').show();
116		} else {
117			$('#contactEmailAddressError').hide();
118		}
119		if (!same) {
120			$('#contactEmailAddressError').hide();
121		}
122	});
123	$('#sameAsAbovePost').change(function() {
124		var same = $(this).is(':checked');
125		//$('div.contactPost input:not(:checkbox)').boolAttr('disabled', same);
126		if (same) {
127			$('#consultationResponse\\:contactsPostDiv\\:postalLine1').val($('#consultationResponse\\:addressDiv\\:line1').val());
128			$('#consultationResponse\\:contactsPostDiv\\:postalLine2').val($('#consultationResponse\\:addressDiv\\:line2').val());
129			$('#consultationResponse\\:contactsPostDiv\\:postalLine3').val($('#consultationResponse\\:addressDiv\\:line3').val());
130			$('#consultationResponse\\:contactsPostDiv\\:postalCity').val($('#consultationResponse\\:addressDiv\\:city').val());
131			$('#consultationResponse\\:contactsPostDiv\\:postalState').val($('#consultationResponse\\:addressDiv\\:state').val());
132			$('#consultationResponse\\:contactsPostDiv\\:postalPostcode').val($('#consultationResponse\\:addressDiv\\:postcode').val());
133			$('#consultationResponse\\:contactsPostDiv\\:postalCountry').val($('#consultationResponse\\:addressDiv\\:country').val());
134		}
135	});
136	// Publication
137	$('#consultationResponse\\:privateResponseDiv\\:privateResponse input').change(function() {
138		$('#consultationResponse\\:moderationEmailDiv input').boolAttr('disabled', !$('#consultationResponse\\:privateResponseDiv\\:privateResponse\\:1').is(':checked'));
139		$('#sameAsAboveEmail').prop('checked', !$('#consultationResponse\\:privateResponseDiv\\:privateResponse\\:1').is(':checked'));
140	}).filter(':first').change();
141
142	// For notify me.
143	$(window).triggerHandler('resize');
144
145	// Dialog and timer for session timeout
146	setTimeout(saveUnfinishedBeforeTimeout, 2400000);
147
148	$('#sessionTimeoutDialog').dialog({autoOpen: false, modal: true, width: 640,
149		buttons: createButtons(
150			messages.save, function() {
151				$(this).dialog('close');
152				$('input.finishLater').click();
153			},
154			messages.cancel, function() {
155				$(this).dialog('close');
156			}
157		),
158		open: dialogCUEButtons
159	});
160
161});
162
163function saveUnfinishedBeforeTimeout() {
164	setTimeout(function() {
165		$('#sessionTimeoutDialog').dialog('close');
166		$('input.finishLater').click();
167	}, 150000);
168
169	$('#sessionTimeoutDialog').dialog('open').
170		dialog('widget').find('div.ui-dialog-buttonpane button').removeAttr('disabled');
171}
172
173function renumberItems(ol) {
174	var cutoff = false;
175	var items = '';
176	ol.find('li').each(function(i) {
177		var li = $(this);
178		if (li.hasClass('cutoff')) {
179			cutoff = true;
180		}
181		else {
182			li.find('input').val(cutoff ? '' : i + 1);
183			if(!cutoff) {
184				items += '|' + $.trim(li.text());
185			}
186		}
187	});
188	ol.next('input:hidden').val(items.substring(1));
189}
190
191function inList(elem, list) {
192	var values = $(elem).closest('div.fieldValue').find('select,input:checked').map(function(i, e) {
193			return $(e).val();
194		}).get();
195	var found = false;
196	$.each(values, function(i, v) {
197		if ($.inArray(v, list) != -1) {
198			found = true;
199			return !found;
200		}
201	});
202	return found;
203}
204
205function groupResize() {
206   $(window).trigger('resize');
207}
208

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.