PageSourceSearch

https://shop.siriusxm.com/scripts/jquery-form.js

js siriusxm.com collected 2026-09-24 08:28:14 UTC 4,816 bytes, 158 lines download raw bytes

1$(function() {
2	$(document).on('click', '[data-swf-event]', function(event) {
3		var $target = $(event.currentTarget);
4
5		// we don't disable the element b/c for a submit button, it will keep the form from being submitted
6		// after we've disabled it here.
7		// so we do it via CSS classes
8		if ($target.hasClass('acdc-prevent-double-submission')) {
9			if ($target.hasClass('acdc-prevent-double-submission-submitted')) {
10				console.log('already submitted');
11				return false;
12			}
13		}
14
15		var swf_event = $target.data('swf-event');
16		var swf_form_selector = $target.data('swf-form-selector');
17
18		if (swf_event && swf_event != '') {
19			$target.addClass('acdc-prevent-double-submission-submitted');
20			console.log('submitting event ' + swf_event);
21			return submitEvent(swf_event, swf_form_selector);
22		}
23	});
24});
25
26function get_form_values(form_id) {
27	return $('#' + form_id).serialize();
28}
29
30function append_hidden_field(elementID, fieldName, fieldValue) {
31	$('#' + elementID).append('<input type="hidden" name="' + fieldName + '" value="' + fieldValue + '">');
32}
33
34/**
35 * sets, instead of appending.
36 */
37function set_hidden_field(elementID, fieldName, fieldValue) {
38	$('#' + elementID).html('<input type="hidden" name="' + fieldName + '" value="' + fieldValue + '">');
39}
40
41/**
42 * same as append_hidden_field() but this will let you set the hidden field's id for things like easy removal.
43 */
44function append_hidden_field_with_id(append_id, name, value, element_id) {
45	$('#' + append_id).append('<input type="hidden" name="' + name + '" value="' + value + '" id="' + element_id + '">');
46}
47
48function create_and_submit_form(url, params) {
49	var $form = $("<form method='POST'>").attr("action", url);
50	$.each(params, function(name, value) {
51		$("<input type='hidden'>").attr("name", name).attr("value", value).appendTo($form);
52	});
53	$form.appendTo("body");
54	$form.submit();
55}
56
57/**
58 * useful for SWF - attach as onclick on <a> tags. just looks for the first hidden div within the #command form and adds a hidden
59 * element. appends a hidden div if not found
60 */
61function submitEvent(event, form_selector) {
62	if (event.indexOf('_eventId_') !== 0) {
63		event = '_eventId_' + event;
64	}
65
66	if (typeof form_selector === 'undefined' || form_selector == null || form_selector == '') {
67		form_selector = '#command';
68	}
69
70	if ($(form_selector + ' > div:hidden').length == 0) {
71		$(form_selector).prepend('<div style="display: none"></div>');
72	}
73
74	$(form_selector + ' > div:hidden:first').append('<input type="hidden" name="' + event + '" value="value" />');
75	$(form_selector).submit();
76	return false;
77}
78
79/**
80 * @param event doesn't have to being with '_eventId_'
81 * @param handler if undefined/null, just calls a "blank" function
82 * @param form_id '#command' by default
83 * @returns {Boolean}
84 */
85function submitAjaxEvent(event, handler, form_id) {
86	var form_selector = '#command';
87
88	if (typeof form_id === 'undefined' || form_id == null || form_id == '') {
89
90		// default
91	} else if (form_id.substring(0, 1) == '#' || form_id.substring(0, 1) == '.') {
92
93		// we assume that "form_id" is actually a selector
94		form_selector = form_id;
95	} else {
96		form_selector = '#' + form_id;
97	}
98
99	if ($(form_selector + ' > div:hidden').length == 0) {
100		$(form_selector).append("<div style='display: none'></div>");
101	}
102
103	// get the action of the form
104	var action = $(form_selector).attr('action');
105
106	// location.protocol would be 'https:' or 'http:'
107	action = action.replace(/^http+:/i, location.protocol);
108	// console.log(action);
109
110	if (event.indexOf('_eventId_') !== 0) {
111		event = '_eventId_' + event;
112	}
113
114	if (typeof handler === 'undefined' || handler == null) {
115		handler = function() {
116		};
117	}
118
119	$(form_selector + ' > div:hidden:first').append('<input type="hidden" name="' + event + '" value="value" />');
120	$.post(action, $(form_selector).serialize(), handler);
121	return false;
122}
123
124/**
125 * @deprecated THIS IS TOO SIMPLE. IT ASSUMES YOU WILL ALWAYS WRITE THE DATA TO THE SAME ELEMENT REGARDLESS OF WHETHER IT'S
126 *             SUCCESSFUL OR NOT. DO NOT USE THIS. CALL submitAjaxEvent() instead.
127 */
128function submitEventAjax(toFill) {
129	$.post($("#command").attr('action'), $("#command").serialize(), function(data) {
130		$("#" + toFill).html(data);
131	});
132}
133
134/**
135 * @param selector the element to attach event listener
136 * @param el_selector the element we'll submit or click
137 */
138function attachEnterKey(selector, el_selector) {
139	jQuery(selector).keypress(function(event) {
140		if (event.which === 13) {
141			var target = jQuery(event.target);
142
143			if (target.is('input')) {
144				var el = jQuery(el_selector);
145
146				if (el.is('form')) {
147					console.log('submitting form ' + el_selector);
148					el.submit();
149				} else {
150					console.log('clicking ' + el_selector);
151					el.click();
152				}
153			} else {
154				console.log('target is not input, ignoring');
155			}
156		}
157	});
158}

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.