PageSourceSearch

https://www.bcr.gob.sv/wp-content/themes/instituciones/js/formHandler.js?7891

js bcr.gob.sv collected 2026-09-24 18:23:44 UTC 2,691 bytes, 86 lines download raw bytes

1$(function()
2{	
3	$('[data-form-type="blocs-form"] input,[data-form-type="blocs-form"] textarea').jqBootstrapValidation(
4    {
5     	preventSubmit: true,
6     	submitSuccess: function($form, event)
7	 	{			
8			if(!$form.attr('action')) // Check form doesnt have action attribute
9			{
10				event.preventDefault(); // prevent default submit behaviour
11			
12				var processorFile = getProcessorPath($form);
13				var formData = {};
14
15				$form.find("input, textarea, option:selected").each(function(e) // Loop over form objects build data object
16				{		
17					var fieldData =  $(this).val();
18					var fieldID =  $(this).attr('id');
19				
20					if($(this).is(':checkbox')) // Handle Checkboxes
21					{
22						fieldData = $(this).is(":checked");
23					}
24					else if($(this).is(':radio')) // Handle Radios
25					{
26						fieldData = $(this).val()+' = '+$(this).is(":checked");
27					}
28					else if($(this).is('option:selected')) // Handle Option Selects
29					{
30						fieldID = $(this).parent().attr('id');
31					}
32					
33					formData[fieldID] = fieldData;		
34				});
35	
36				$.ajax({
37		        	url: processorFile,
38		    		type: "POST",
39		    		data: formData,
40		    		cache: false,
41		    		success: function() // Success
42		 			{  
43						if($form.is('[data-success-msg]')) // Show Success Message
44						{
45							$form.append("<div id='form-alert' class=\"mt-2\"><div class='alert alert-success'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button><strong>"+$form.attr('data-success-msg')+"</strong></div></div>");
46						}
47						else // Re-Direct
48						{
49							window.location.replace($form.attr('data-success-url'));
50						}	
51						
52						$form.trigger("reset"); // Clear Form	
53		 	   		},
54			   		error: function() // Fail
55			   		{
56						if($('#form-alert').length == 0)
57						{
58							$form.append("<div id='form-alert' class=\"mt-2\"><div class='alert alert-danger'><button type='button' class='close' data-dismiss='alert' aria-hidden='true'>&times;</button><strong>"+$form.attr('data-fail-msg')+"</strong></div></div>");
59						}	
60			   		},
61		   		});
62			}
63         },
64         filter: function() // Handle hidden form elements
65		 {
66			 return $(this).is(":visible");
67         },
68	 });
69	 
70	 // Get Path to processor PHP file
71	 function getProcessorPath(form)
72	 {
73		var path = "./includes/"+form.attr('id')+".php";
74		
75		if (form.attr('data-clean-url-used')) // Clean URL use Double Dot
76		{
77			path = "."+path;
78		}
79		else if (form.attr('template-path')) // Check For Template path
80		{
81			path = form.attr('template-path')+"/includes/"+form.attr('id')+".php";
82		}
83		
84	 	return path
85	 }
86});

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.