eol.isscommand.com Open in urlscan Pro
44.193.186.179  Public Scan

Submitted URL: https://app.isscommand.com/vendor/api/lnf/LostwebApiOptimized.js
Effective URL: https://eol.isscommand.com/vendor/api/lnf/LostwebApiOptimized.js
Submission: On May 29 via api from LU — Scanned from DE

Form analysis 0 forms found in the DOM

Text Content

//var url_to = "api/generateFormHtml.php";
var url_to = "https://app.isscommand.com/vendor/api/lnf/GenerateLostFormHtmlOptimized.php";

function getFacilityDropDown(api_key)
{
	if(api_key != '') {
		jQuery.ajax({
			type: "GET",
			dataType: 'jsonp',
		  	jsonp: 'jsonp_callback',
			url: url_to,
			data: "act=getFacility&api_key=" + api_key,
			success: function(data){
				if(data != null)
				{
					var count = data.count;
					var i= 0;
					if(count > 1)
					{
						var target = jQuery("#show_facility_drop_down");
						jQuery("#show_facility_drop_down").html('<option id="" value="" name="" selected="selected">Select Facility</option>');

						jQuery("#facility_text_box").attr('value','');
						jQuery("#facility_read_only_textbox_div").children().attr('disabled', 'disabled');

						jQuery("#facility_drop_down_div").css("display","block");

						jQuery("#facility_val").attr('value','');


						while(i < count)
						{
							if(typeof data.facilities[i]['facility_id'] != "undefined") {
								var targetOption = jQuery(document.createElement("option")).attr({
									id:	'option_' + data.facilities[i]['facility_id'],
									value:	data.facilities[i]['facility_name'],
									name: data.facilities[i]['facility_name']

								}).html(data.facilities[i]['facility_name'])
								.click(function(event){

								});

								target.append(targetOption);
							}
							i++;
						}
					}
					else
					{
						jQuery("#facility_val").attr('value',data.facilities[i]['facility_id']);

						jQuery("#facility_drop_down_div").css("display","none");

						jQuery("#show_facility_drop_down").css("display","none");

						jQuery("#facility_text_box").attr('value',data.facilities[i]['facility_name']);

						jQuery("#facility_read_only_textbox_div").css("display","block");

					}

					if(document.getElementById('load_after_facility') && (document.getElementById('load_after_facility').value == 1))
					{
						getAllData();
					}
				}
			}
		});
	}
}

function getLocationSectionDropDownFieldSettings(api_key)
{
	if(api_key != '') {
		jQuery.ajax({
			type: "GET",
			dataType: 'jsonp',
		  	jsonp: 'formsetting',
			url: url_to,
			data: "act=getFormSettings&api_key=" + api_key,
			success: function(data){
				var form_settings = data.settings;
				if(form_settings != '' && form_settings != null)
				{
					var field_array = [];
					var option_array = [];
					var image_field_array = [];
					var settings_array = form_settings.split(',');
					for(var m = 0; m < settings_array.length ; m++)
					{
						if(settings_array[m].indexOf('LOC_SET_') > -1)
						{
							option_array.push(settings_array[m]);
						}
						else if(settings_array[m].indexOf('LOST_IMAGE_UPLOAD') > -1)
						{
							image_field_array.push(settings_array[m]);
						}
						else
						{
							field_array.push(settings_array[m]);
						}
					}

					if(field_array.length)
					{
						var text_fields = ['LOST_ROWS','LOST_SEATS'];
						var dd_fields = ['LOST_LOCATION','LOST_SECTION'];
						var input_types = [];
						var field_width = 3;
						if(field_array.length == 1)
						{
							field_width = 12;
						}
						else if(field_array.length == 2)
						{
							field_width = 6;
						}
						else if(field_array.length == 3)
						{
							field_width = 4;
						}
						else if(field_array.length == 4)
						{
							field_width = 3;
						}
						for(var m = 0; m < field_array.length; m++)
						{
							if(text_fields.indexOf(field_array[m]) > -1)
							{
								if(field_array[m] == 'LOST_ROWS')
								{
									input_types.push('<div class="form-group col-sm-'+field_width+'"><label class="control-label">Row</label><input autocomplete="off" type="text" id="row"  name="row" data-minlength="1" placeholder="Row" class="form-control"/></div>');
								}
								else if(field_array[m] == 'LOST_SEATS')
								{
									input_types.push('<div class="form-group col-sm-'+field_width+'"><label class="control-label">Seat</label><input autocomplete="off" type="text" id="seat"  name="seat" data-minlength="1" placeholder="Seat" class="form-control"/></div>');
								}
							}
							else if(dd_fields.indexOf(field_array[m]) > -1)
							{
								if(field_array[m] == 'LOST_SECTION')
								{
									input_types.push('<div class="form-group col-sm-'+field_width+'"><label class="control-label">Section</label><select name="section" id="lost_section_dropdown" class="form-control" disabled="disabled"><option id="" value="" name="">Select Section</option></select></div>');
								}
								else if(field_array[m] == 'LOST_LOCATION')
								{
									if(option_array.length && option_array[0] == 'LOC_SET_LOST_TEMPLATE')
									{
										input_types.push('<div class="form-group col-sm-'+field_width+'"><label class="control-label">Location</label><select name="location" id="lost_location_dropdown" class="form-control" disabled="disabled"><option id="" value="" name="">Select Location</option></select></div>');
									}
									else
									{
										input_types.push('<div class="form-group col-sm-'+field_width+'"><label class="control-label">Location</label><input autocomplete="off" type="text" name="location_text" data-minlength="1" placeholder="Location" class="form-control"/></div>');
									}
								}
							}
						}
						jQuery('#field_setting_loc_sec').html(input_types.join(' '));
					}
					else
					{
						jQuery('#field_setting_loc_sec').html('');
						jQuery('#field_setting_loc_sec').hide();
					}

					if(image_field_array.length)
					{
						jQuery('#image_input').html('<div class="form-group form-group-file col-sm-12"><label for="photo" class="control-label">Upload Image</label><input autocomplete="off" type="file" id="photo" name="photo" class="form-control" data-filesize="3" data-filesize-error="Files greater then 3MB not allowed" accept="image/*" /><div class="help-block with-errors"></div></div>');
					}
					else
					{
						jQuery('#image_input').html('');
						jQuery('#image_input').hide();
					}
				}
				else
				{
					jQuery('#field_setting_loc_sec').html('');
					jQuery('#field_setting_loc_sec').hide();
					jQuery('#image_input').html('');
					jQuery('#image_input').hide();
				}
				jQuery('#lnfwebform').validator('update');
			}
		});
	}
}

function getCategoryDropDown(facility_id, api_key) {

	if(api_key != '' && facility_id != '') {
		jQuery('#lost_category_dropdown').attr('disabled','disabled');
		jQuery.ajax({
			type: "GET",
			dataType: 'jsonp',
		  	jsonp: 'category',
			url: url_to,
			data: "act=getCategory&api_key=" + api_key +"&facility_id=" + facility_id,
			success: function(data){
				if(data != null)
				{
					var count = data.count;
					var target = jQuery("#lost_category_dropdown");
					jQuery("#lost_category_dropdown").html('<option id="" value="" name="">Select Category</option>');
					if(count)
					{
						var i = 0;
						while(i < count)
						{
							if(typeof data.rows[i]['category_id'] != "undefined") {
								var targetOption = jQuery(document.createElement("option")).attr({
									id:	'option_' + data.rows[i]['category_id'],
									value:	data.rows[i]['category_name'],
									name: data.rows[i]['category_name']

								}).html(data.rows[i]['category_name'])
								.click(function(event){

								});

								target.append(targetOption);
							}
							i++;
						}
						jQuery('#lost_category_dropdown').removeAttr('disabled');
					}
				}
			}
		});
	}
}

function getLocationDropDown(facility_id, api_key) {

	if(api_key != '' && facility_id != '') {
		jQuery('#lost_location_dropdown').attr('disabled','disabled');
		jQuery.ajax({
			type: "GET",
			dataType: 'jsonp',
		  	jsonp: 'location',
			url: url_to,
			data: "act=getLocation&api_key=" + api_key +"&facility_id=" + facility_id,
			success: function(data){
				if(data != null)
				{
					var count = data.count;
					var target = jQuery("#lost_location_dropdown");
					jQuery("#lost_location_dropdown").html('<option id="" value="" name="">Select Location</option>');
					if(count)
					{
						var i = 0;
						while(i < count) {

							if(typeof data.location[i]['id'] != "undefined") {
								var targetOption = jQuery(document.createElement("option")).attr({
									id:	'option_' + data.location[i]['id'],
									value:	data.location[i]['location'],
									name: data.location[i]['location']

								}).html(data.location[i]['location'])
								.click(function(event){

								});

								target.append(targetOption);
							}
							i++;
						}
						jQuery('#lost_location_dropdown').removeAttr('disabled');
					}
				}
			}
		});
	}
}

function getSectionDropDown(facility_id, api_key) {
	if(api_key != '' && facility_id != '') {
		jQuery('#lost_section_dropdown').attr('disabled','disabled');
		jQuery.ajax({
			type: "GET",
			dataType: 'jsonp',
		  	jsonp: 'section',
			url: url_to,
			data: "act=getSection&api_key=" + api_key +"&facility_id=" + facility_id,
			success: function(data){
				if(data != null)
				{
					var count = data.count;
					var target = jQuery("#lost_section_dropdown");
					jQuery("#lost_section_dropdown").html('<option id="" value="" name="">Select Section</option>');
					if(count)
					{
						var i = 0;
						while(i < count)
						{
							if(typeof data.rows[i]['section_id'] != "undefined") {
								var targetOption = jQuery(document.createElement("option")).attr({
									id:	'option_' + data.rows[i]['section_id'],
									value:	data.rows[i]['section_name'],
									name: data.rows[i]['section_name']

								}).html(data.rows[i]['section_name'])
								.click(function(event){

								});

								target.append(targetOption);
							}
							i++;
						}
						jQuery('#lost_section_dropdown').removeAttr('disabled');
					}
				}
			}
		});
	}
}

function getEventDropDown(facility_id, api_key) {
	if(api_key != '' && facility_id != '') {
		jQuery('#lost_event_dropdown').attr('disabled','disabled');
		jQuery.ajax({
			type: "GET",
			dataType: 'jsonp',
		  	jsonp: 'rows',
			url: url_to,
			data: "act=getEvent&api_key=" + api_key +"&facility_id=" + facility_id,
			success: function(data){
				if(data != null)
				{
					var count = data.count;
					var target = jQuery("#lost_event_dropdown");
					jQuery("#lost_event_dropdown").html('<option id="" value="" name="">Select Event</option>');
					if(count)
					{
						var i = 0;
						while(i < count)
						{
							if(typeof data.rows[i]['event_id'] != "undefined") {
								var targetOption = jQuery(document.createElement("option")).attr({
									id:	'option_' + data.rows[i]['event_id'],
									value:	data.rows[i]['org_event_name'],
									name: data.rows[i]['org_event_name']

								}).html(data.rows[i]['event_name'])
								.click(function(event){

								});

								target.append(targetOption);
							}
							i++;
						}
						jQuery('#lost_event_dropdown').removeAttr('disabled');
					}
				}
			}
		});
	}
}

//Function used in case if the account has multiple facilities.
function facilityDropDownChange() {

	var facility_selected = jQuery("#show_facility_drop_down").find(":selected").attr('id');

	var facility_val = facility_selected.split("_");

	var facility_id  = facility_val[1];

	var api_key      = jQuery("#api_key").val();

	jQuery("#facility_val").val(facility_id);

	getCategoryDropDown(facility_id,api_key);
	getLocationDropDown(facility_id, api_key);
	getEventDropDown(facility_id,api_key);
	getSectionDropDown(facility_id, api_key);
}

//Function used in case if the account is single facility.
function postFacilityAction(api_key, facility_id) {
	if(api_key != '' && facility_id != '')
	{
		getCategoryDropDown(facility_id,api_key);
		getLocationDropDown(facility_id, api_key);
		getEventDropDown(facility_id,api_key);
		getSectionDropDown(facility_id, api_key);
	}
}

function getAllData()
{
	var api_key = jQuery("#api_key").val();

	var lost_form_type = jQuery("#lost_form_type").val();
	var show_facility_dropdown = jQuery("#show_facility_dropdown").val();

	if(show_facility_dropdown == 0)
	{
		jQuery("#do_not_show_facility_block").css('display','none');
	}

	if(lost_form_type == 1)// form type 1
	{
		// play as it is, nothing to do
		if(jQuery('#facility_val').val() == '')
		{
			jQuery("#show_facility_drop_down").attr('required','required');// make facility dropdown mandatory
		}
		else
		{
			var facility_id = jQuery('#facility_val').val();
			if(facility_id != '') {
				postFacilityAction(api_key,facility_id);
			}
		}
	}
	else if(lost_form_type == 2)// form type 2 multiple facility but only one needed
	{
		var facility_id  = jQuery("#facility_id_val").val();

		var facility_name = jQuery('#show_facility_drop_down').find('option[id="option_'+facility_id+'"]').val();

		jQuery('#facility_val').val(facility_id);

		jQuery("#facility_drop_down_div").css("display","none");

		jQuery("#show_facility_drop_down").css("display","none");

		if(typeof facility_name == 'undefined')
		{
			jQuery("#facility_text_box").attr('value','Please provide facility as you set form type 2');
		}
		else
		{
			jQuery("#facility_text_box").attr('value',facility_name);
		}

		jQuery("#facility_read_only_textbox_div").css("display","block");

		if(facility_id != '') {
			postFacilityAction(api_key,facility_id);
		}
	}
}

function reset_action()
{
	jQuery('#show_facility_drop_down').val('').change();
	if(jQuery("#datepicker"))
	{
		jQuery("#datepicker").val('');
	}
	var api_k = jQuery('#api_key').val();
	getFacilityDropDown(api_k);
	getLocationSectionDropDownFieldSettings(api_k);
}