403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.216.11
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/connectionsdev/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/connectionsdev/js/index.js
var timeout    = 500;
var closetimer = 0;
var ddmenuitem = 0;
var sheet_dirty = false;
var dTable = [];
var dTable_width = [];
var dTable_sort =[];
var dTable_filter = [];
var window_terms_orig_html;

function jsddm_open()
{  jsddm_canceltimer();
   jsddm_close();
   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

function jsddm_close()
{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

function jsddm_timer()
{  closetimer = window.setTimeout(jsddm_close, timeout);}

function jsddm_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
	  closetimer = null;}}

function jsddm_recalc()
{
	var total_width = 0;
	//console.log('jsddm total actual width: ' + $('#jsddm').actual('width'));
	//console.log('jsddm total actual height: ' + $('#jsddm').actual('height'));
	//console.log('jsddm first LI actual height * 2: ' + $('#jsddm li').first().actual('height') * 2);
	//if ( ($('#jsddm').actual('height') >= $('#jsddm li').first().actual('height') * 2) || ($(window).width() <=760) )
	if ( ($(window).width() <=760) )
	{
		$('#newnav').hide();
		$('.slicknav_menu').show();
	}
	else
	{
		$('#newnav').show();
		$('.slicknav_menu').hide();
	}
}

$(document).ready(function()
{  
	$('#jsddm > li').bind('mouseover', jsddm_open);
	$('#jsddm > li').bind('mouseout',  jsddm_timer);

	// If the browser is IE, apply Z-Order bug fix
	if($.browser.msie)
	{
		/*
		** For each div with class menu (i.e.,
		** the thing we want to be on top),
		*/
		$("#jsddm > li > ul").parents().each(function() {
			var p = $(this);
			var pos = p.css("position");
 
			// If it's positioned,
			if(pos == "relative" ||
			   pos == "absolute" ||
			   pos == "fixed")
			{
				/*
				** Add the "on-top" class name when the
				** mouse is hovering over it, and remove
				** it when the mouse leaves.
				*/
				p.hover(function() {
						$(this).addClass("on-top");
					},
					function() {
						$(this).removeClass("on-top");
					});
			}
		});
	}

	$('#jsddm').slicknav({
		label: '',
		duration: 200
	});
	
	$( window ).resize(function() {
		jsddm_recalc();
	});
	
	jsddm_recalc();

	Date.format = 'mm/dd/yyyy';
	$('.date-pick').datePicker({
							   		createButton: false,
							   		clickInput: true,
									startDate: '01/01/1996',
									verticalOffset: 18
							   });
	
	$('.mail_field').blur(function(){
								//alert($('#linkout_' + $(this).attr('id')).attr('href'));
						   		$('#linkout_' + $(this).attr('id')).attr('href','mailto:' + $(this).val());
								//alert($('#linkout_' + $(this).attr('id')).attr('href'));
						   })

	$('.link_field').blur(function(){
								//alert($('#linkout_' + $(this).attr('id')).attr('href'));
								link = $(this).val();
								if (typeof link === 'undefined' || !link) 
								{
								}
								else
								{
									if (link.substr(0, 7).toLowerCase() != 'http://' && link.substr(0, 8).toLowerCase != 'https://') 
									{
										link = 'http://' + link;
									}
						   			$('#linkout_' + $(this).attr('id')).attr('href','' + link);
								}
								//alert($('#linkout_' + $(this).attr('id')).attr('href'));
						   })

   //$('.help_icon').bind('click', toggleHelp('a'));
	//format_dtable('db_grid_main');
	$('#main_footer_spacer').html($('#main_footer').html());
	//*********** $.wakeUp(function(sleep_time) { logoutRedirect(); } );
	$('table.dbgrid').each(function() {format_dtable($(this).attr('id'));});
	window_terms_orig_html = $('#terms_content').html();
	/*
	$('form.delay_submit').submit(function (e) 
		{
			var form = this;
			e.preventDefault();
			setTimeout(function () {
					//alert('submitting');
					$(form).submit();
				}, 1000); // in milliseconds
		});	
	*/

});

document.onclick = jsddm_close;	

setCookie = function(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	//document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
	document.cookie=c_name+ "=" +encodeURIComponent(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

getCookie = function(c_name) {
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		//return unescape(document.cookie.substring(c_start,c_end));
		return decodeURIComponent(document.cookie.substring(c_start,c_end));
		} 
	  }
	return "";
}

function when(condition, callback) {
	if (condition()) {
		callback();
	} else {
		setTimeout(function() {
			when(condition, callback);
		}, 100);
	}
}

val_checkbox = function(cbval)
{
	if (typeof cbval === 'undefined')
	{
		cbval = '0';
	}
	//alert(cbval);
	return cbval;
}

change_rating = function(eid, rating)
{
	//alert(eid);
	//alert(rating);
	var html = '';
	var xdiv = document.getElementById('rating_' + eid);
	var i = 0;
	var jscript = '';
	for (i=1; i<=5; i++)
	{
		jscript = "'" + eid + "'," + i;
		if (i <= rating)
			html = html + '<img src="img/star_filled_16.gif" style="cursor:pointer;" onclick="change_rating(' + jscript + ');">';
		else
			html = html + '<img src="img/star_hollow_16.gif" style="cursor:pointer;" onclick="change_rating(' + jscript + ');">';
	}
	xdiv.innerHTML = html;
	xelem = document.getElementById(eid);	
	xelem.value = rating;	
}

clear_search_box = function(search_box_id)
{
	$('#' + search_box_id).val('').keyup();
}


exportExcel = function(xls_sql)
{
	//window.location.href = "mod/_export_excel.php?sql=" + xls_sql;
	window.location.href = "ajax.php?call=_export_excel&sql=" + xls_sql;
	//rptWindowName = this.open("mod/_export_excel.php?sql=" + xls_sql, "rptWindowName", "scrollbars=yes, resizable=yes, location=no, toolbar=no, menubar=no, height=200, width=400");
	//rptWindowName.focus();
}

function confirm_delete(msg, id, div) {
	var answer = confirm(msg);
	//alert(eval(div + '_call') + ' id: ' + id);
	if (answer == true){
		$.ajax({
			url: "ajax.php?call=" + eval(div + '_call') + "&func=delete&id=" + id,
			cache: false,
			dataType: "json",
			success: function(json) {
					if (json.result == 'Success')
					{
						lcs_db_load(div, eval(div + '_call'), 'grid', eval(div + '_ix_form'), 
									eval(div + '_sort_col'), eval(div + '_sort_order'), eval(div + '_search_str'),
									eval(div + '_parm1'), eval(div + '_parm2'), eval(div + '_parm3'), eval(div + '_filter_cols'), eval(div + '_multi_filter') );
					}
					else
					{
						alert(json.result);
					}
			}
			 ,error: function (request, status, error) { alert(status + ", " + error); }
		})
	}
}

function confirm_inactivate(msg, id, div) {
	var answer = confirm(msg);
	//alert(eval(div + '_call') + ' id: ' + id);
	if (answer == true){
		$.ajax({
			url: "ajax.php?call=" + eval(div + '_call') + "&func=inactivate&id=" + id,
			cache: false,
			dataType: "json",
			success: function(json) {
					if (json.result == 'Success')
					{
						lcs_db_load(div, eval(div + '_call'), 'grid', eval(div + '_ix_form'), 
									eval(div + '_sort_col'), eval(div + '_sort_order'), eval(div + '_search_str'),
									eval(div + '_parm1'), eval(div + '_parm2'), eval(div + '_parm3'), eval(div + '_filter_cols'), eval(div + '_multi_filter') );
					}
					else
					{
						alert(json.result);
					}
			}
			 ,error: function (request, status, error) { alert(status + ", " + error); }
		})
	}
}

function confirm_restore_revision(msg, revision_id) {
	var answer = confirm(msg);
	//alert(eval(div + '_call') + ' id: ' + id);
	if (answer == true){
		$.ajax({
			url: 'ajax.php?call=revisions_ajax&func=restore_revision&id=' + revision_id,
			cache: false,
			dataType: "json",
			success: function(json) {
					if (json.result == 'Success') {
						location.reload();
					} else {
						alert(json.result);
					}
			}
			 ,error: function (request, status, error) { alert(status + ", " + error); }
		})
	}
}

function show_revision(revision_id) {
	hide_revision_details();
	$.ajax({
		url: 'ajax.php?call=revisions_ajax&func=load_revision&id=' + revision_id,
		dataType: 'json',
		success: function(json) {
			if (json.result == 'Success') {
				$('#grid_popup_contents').html(json.html);
				$('#grid_popup').show();
			} else {
				alert('Error: ' + json.result);
			}
		},
		error: function (request, status, error) {
			alert('Error! ' + status + ' ' + error);
		},
	});
}

function hide_revision_details() {
	$('div.grid_popup').hide();
}

live_field = function(id)
{
	var input_type = $('#' + id).attr('type');
	switch(input_type)
	{
		case 'text' :
			//alert('value ' + $('input[id=' + id + ']').attr('val'));
			$('input[id=' + id + ']').attr('value', $('input[id=' + id + ']').val());
			break;
		case 'checkbox' :
			if (val_checkbox($('input[id=' + id + ']:checked').val()) == 0)
			{
				$('input[id=' + id + ']').attr('checked', null);
			}
			else
			{
				$('input[id=' + id + ']').attr('checked', $('input[id=' + id + ']').attr('checked'));
			}
			break;
		case 'radio' :
			//alert('radio ' + id + '   ' + $('input[id=' + id + ']').val());
			var radio_name = $('input[id=' + id + ']').attr('name');
			var checked_id = '';
			$('input[name=' + radio_name + ']').each(function()
				{
					if ($(this).is(':checked'))
					{
						checked_id = $(this).attr('id');
						//$(this).attr('checked', 'checked');
					}
					else
					{
						//$(this).attr('checked', null);
					}
				});
			$('input[name=' + radio_name + ']').removeAttr('checked');
			if (checked_id > '')
			{
				$('#' + checked_id).attr('checked', 'checked');
			}
			/*
			var this_checked = $('input[id=' + id + ']').attr('checked');
			$('input[name=' + radio_name + ']').removeAttr('checked');
			if (this_checked == 'checked')
			{
				$('input[id=' + id + ']').attr('checked', 'checked');
			}
			break;
			*/
	}
}

function real_width(container_obj, measure_obj)
{
    var clone = container_obj.clone();
    clone.css("visibility","hidden");
    $('body').append(clone);
    var width = clone.outerWidth();
	//alert(clone.innerWidth());
    clone.remove();
    return width;
}

function insert_text_at_cursor(text, select, elem_id) {
	try {
		var elem = $('#' + elem_id).parent().children('div.trumbowyg-editor').first();
		elem.focus();
		var sel, range, html;
		if (window.getSelection) {
			sel = window.getSelection();
			if (sel.getRangeAt && sel.rangeCount) {
				range = sel.getRangeAt(0);
				range.deleteContents();
				range.insertNode( document.createTextNode(text) );
				//range.collapse(true);
				range.collapse(false);
			}
		} else if (document.selection && document.selection.createRange) {
			document.selection.createRange().text = text;
		}
		editor.html($(elem).html());
		$('#' + elem_id).val($(elem).html());
	} catch {
		return false;
	}
}	

/* ************************************************************ */

var grid_data = [];
var col_defs_custom = [];
var dtable_callback_custom = [];

format_dtable = function(table_id)
{
	if (dTable[table_id])
		return;
	col_defs_custom[table_id] = col_defs_custom[table_id] || [];
	dTable_sort[table_id] = dTable_sort[table_id] || [];
	var col_defs_default = [ 
					{
						"targets": [ "no-sort" ],
						"sortable": false
					}
				];
	col_defs = col_defs_default.concat(col_defs_custom[table_id]);
	if ($('#' + table_id).length > 0 && $('#' + table_id).is(':visible'))
	{
		/*
		if ( $('#' + table_id).is(':visible') )
		{
			var t_width = $('#' + table_id).width() + 18;
		}
		else
		{
			//var t_width = real_width($('#' + table_id).parents('div[class="tab_content"]').first(), $('#' + table_id)) + 10;
			$('#' + table_id).parents('div[class="tab_content"]').first().show();
			var t_width = $('#' + table_id).width() + 18;
			$('#' + table_id).parents('div[class="tab_content"]').first().hide();
		}
		dTable_width[table_id] = $('#' + table_id).width();
		*/
		/*
		if($.browser.msie)
		{
			var expr = new RegExp('>[ \t\r\n\v\f]*<', 'g');
			var expr2 = new RegExp('\\t', 'g');
			var expr3 = new RegExp('\\n', 'g');
			var grid_div_id = $('#' + table_id).parent().attr('id');
			var strHTML = document.getElementById(grid_div_id).innerHTML;
			strHTML = strHTML.replace(expr, '><');
			strHTML = strHTML.replace(expr2, '');
			strHTML = strHTML.replace(expr3, '');
			//$('#' + table_id).html(strHTML);
			document.getElementById(grid_div_id).innerHTML = strHTML;
		}
		*/
		dTable[table_id] = $('#' + table_id).DataTable( {
			"data":  grid_data[table_id],
			"autoWidth": true,
			"scrollY": "450px",
			"searching": true,
			"info": false,
			"ordering": true,
			"orderClasses": false,
			"paging": true,
			"pageLength": 50,
			//"paging": false,
			"dom": 'tiS',
			//"dom": 'ti',
			//"deferRender": true,
			"deferRender": false,
			"processing": false,
			"drawCallback": dtable_callback_custom[table_id],
			"order": dTable_sort[table_id],
			"columnDefs": col_defs			
			
		} );
		$('#' + table_id + '_total_count').text(dTable[table_id].page.info().recordsDisplay);
		//$('#' + table_id + '_wrapper').css('width', t_width + 'px');
		//dTable[table_id].columns.adjust();
		$('#' + table_id + '_strSearch').on( 'keyup', function () {
				dTable[table_id].search( this.value ).draw();
				$('#' + table_id + '_total_count').text(dTable[table_id].page.info().recordsDisplay);
				if (this.value > ' ')
				{
					$('#' + table_id + '_strSearch').removeClass('search');
					$('#' + table_id + '_strSearch').addClass('search_cancel');
					$('#' + table_id + '_search_box a').show();
				}
				else
				{
					$('#' + table_id + '_strSearch').removeClass('search_cancel');
					$('#' + table_id + '_strSearch').addClass('search');
					$('#' + table_id + '_search_box a').hide();
				}
			} );
	}
}
	
dtable_filter = function(obj, col, table_id)
{
	if ($(obj).hasClass('pressed'))
	{
		//alert(dTable_filter[table_id + '_' + col]);
		//$.fn.dataTableExt.afnFiltering.splice(dTable_filter[table_id + '_' + col] - 1, 1);
		$.fn.dataTableExt.afnFiltering[dTable_filter[table_id + '_' + col] - 1] = 
				function ( oSettings, aData, iDataIndex ) {
					return true;
			};
		$(obj).removeClass('pressed');
	}
	else
	{
		dTable_filter[table_id + '_' + col] = $.fn.dataTableExt.afnFiltering.push(
			function( oSettings, aData, iDataIndex ) {
				if (oSettings.nTable.getAttribute('id') == table_id)
				{
					var nTr = oSettings.aoData[ iDataIndex ].nTr;
					var checkbox = $(nTr).find("td:eq(" + col + ") input[type=checkbox]").is(":checked");
					if (checkbox && checkbox !== "null" && checkbox !== "undefined")
					{
						return true;
					}
					return false;
				}
				else
				{
					return true;
				}
			}
		);
		$(obj).addClass('pressed');
	}
	dTable[table_id].draw();
	$('#' + table_id + '_total_count').text(dTable[table_id].page.info().recordsDisplay);
}


printSection = function (id)
{
	if (window[id + '_load_method'] == 'lazy2' || window[id + '_load_method'] == 'lazy3')
	{
		while (window[id + '_current_block'] <= window[id + '_block_count'])
		{
			if (window[id + '_load_method'] == 'lazy2')
			{
				lcs_db_lazy_load2(window[id + '_uid'], id);
			}
			else if (window[id + '_load_method'] == 'lazy3')
			{
				lcs_db_lazy_load3(window[id + '_uid'], id, false);
			}
		}
	}
	var table_grid_id;
	var table_grid_scroller;
	var table_grid_header;
	var scroller_style;
	var class_list = $('#' + id).attr('class').split(/\s+/);
	$.each( class_list, function(index, item){
		if (item === 'db-grid') 
		{
			table_grid_id = $('#' + id).find("table").eq(1).attr('id');
			table_grid_scroller = $('#' + id).find(".dataTables_scrollBody").eq(0);
			table_grid_header = $('#' + id).find(".dataTables_scrollHeadInner").eq(0);
			var header_width = $(table_grid_header).width();
			if ($('#' + table_grid_id ).length > 0)
			{
				scroller_style = $(table_grid_scroller).attr('style');
				$(table_grid_scroller).attr('style', 'width:' + header_width + 'px;');
			}
		}
	});
	var height = $('#' + id).css('height');
	if (height == '')
	{
		height = 'auto';
	}
	var html="<html>";
	var unix_time = Math.round(+new Date()/1000);
	html+='<link rel="stylesheet" href="css/main.css?' + unix_time + '" type="text/css" >';
	html+='<link rel="stylesheet" href="css/lcs_db_grid.css?' + unix_time + '" type="text/css" >';
	html+='<link rel="stylesheet" href="css/print.css?' + unix_time + '" type="text/css" >';
	html+='<style type="text/css">' + $('style#lcs_dbg_style_' + id).html() + '</style>';
	if (typeof print_header !== 'undefined')
		html+= print_header;
	if (typeof print_sub_header !== 'undefined')
		html+= print_sub_header;
	html+= '<h1>' + $('h1:first').html() + '</h1>';
	html+= '<div style="float:none;position:relative;min-height:' + height + ';">';
	//html+= document.getElementById(id).innerHTML;
	//alert($('#' + id).html());
	//html+= $('#' + id).html();
	var clean_html = $('#' + id).html();
	clean_html = clean_html.replace(/<script.*?>[\s\S]*?<\/script>/ig, "");
	clean_html = clean_html.replace(/onclick="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onchange="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onblur="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onmouseover="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onmousedown="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onmouseup="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onkeypress="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onkeydown="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onkeyup="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onfocus="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/href="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/<input /ig, '<input readonly="readonly" ');
	clean_html = clean_html.replace(/ type="checkbox"/ig, ' type="checkbox" disabled="disabled" ');
	clean_html = clean_html.replace(/ type="radio"/ig, ' type="radio" disabled="disabled" ');
	clean_html = clean_html.replace(/ type="button"/ig, ' type="hidden" ');
	html+= clean_html;
	html+= '</div>';
	html+= '<div style="float:none;">';
	if (typeof print_footer !== 'undefined')
		html+= print_footer;
	html+= '</div>';
	html+="</html>";
	//alert(html);
	
	$.each( class_list, function(index, item){
		if (item === 'db-grid') 
		{
			$(table_grid_scroller).attr('style', scroller_style);
		}
	});

	var printWin = window.open('','','left=50,top=50,width=960,height=600,toolbar=0,scrollbars=1,menubar=1,status=0');
	printWin.document.write(html);
	printWin.document.close();
	printWin.focus();
	setTimeout(function(){
		printWin.print();
	}, 500);
	//printWin.close();
}

pdfSection = function (id, strip_anchor)
{
	var rec_count = parseInt(trim($('#' + id + '_total_count').text()));
	if (rec_count > 200) 
	{
		alert('Creating a PDF with too many records will take a long time and may crash the server. Please filter the records to narrow your selection or try the Print or Excel function instead.');
		return;
		/*
		var answer = confirm('Are you sure?  Creating a PDF with too many records will take a long time and may crash the server. Please click [Cancel] and try the Print or Excel function instead.');
		if (answer != true){
			return;
		}
		*/
	}
	if ('undefined' === typeof strip_anchor)
	{
		strip_anchor = 1;
	}
	if (window[id + '_load_method'] == 'lazy2' || window[id + '_load_method'] == 'lazy3')
	{

		while (window[id + '_current_block'] <= window[id + '_block_count'])
		{
			if (window[id + '_load_method'] == 'lazy2')
			{
				lcs_db_lazy_load2(window[id + '_uid'], id);
			}
			else if (window[id + '_load_method'] == 'lazy3')
			{
				lcs_db_lazy_load3(window[id + '_uid'], id, false);
			}
		}
	}
	var table_grid_id;
	var table_grid_scroller;
	var table_grid_header;
	var scroller_style;
	var class_list =$('#' + id).attr('class').split(/\s+/);
	$.each( class_list, function(index, item){
		if (item === 'db-grid') 
		{
			table_grid_id = $('#' + id).find("table").eq(1).attr('id');
			table_grid_scroller = $('#' + id).find(".dataTables_scrollBody").eq(0);
			table_grid_header = $('#' + id).find(".dataTables_scrollHeadInner").eq(0);
			var header_width = $(table_grid_header).width();
			if ($('#' + table_grid_id ).length > 0)
			{
				scroller_style = $(table_grid_scroller).attr('style');
				$(table_grid_header).hide();
				$(table_grid_scroller).attr('style', 'width:' + header_width + 'px;');
			}
		}
	});
	var height = $('#' + id).css('height');
	if (height == '')
	{
		height = 'auto';
	}
	var html="<html><head>";
	var unix_time = Math.round(+new Date()/1000);
	html+='<link rel="stylesheet" href="css/main.css?' + unix_time + '" type="text/css" >';
	html+='<link rel="stylesheet" href="css/lcs_db_grid.css?' + unix_time + '" type="text/css" >';
	html+='<link rel="stylesheet" href="css/pdf.css?' + unix_time + '" type="text/css" >';
	html+='<style type="text/css">' + $('style#lcs_dbg_style_' + id).html() + '</style>';
	html+='</head><body>';
	if (typeof print_header !== 'undefined')
		html+= print_header;
	if (typeof print_sub_header !== 'undefined')
		html+= print_sub_header;
	html+= '<div style="float:none;position:relative;min-height:' + height + ';">';
	//html+= document.getElementById(id).innerHTML;
	//alert($('#' + id).html());
	//html+= $('#' + id).html();
	var table_header_row = $('div#' + id + ' table.lcs_dbg_header_section tbody').html();
	//alert(table_header_row);
	var clean_html = $('#' + id).html();
	clean_html = clean_html.replace(table_header_row, '');
	clean_html = clean_html.replace(/<table /ig, '<table repeat_header="1" ');
	clean_html = clean_html.replace(/<tbody><tr class="lcs_dbg_row"/ig, '<thead>' + table_header_row + '</thead><tbody><tr class="lcs_dbg_row" ');
	clean_html = clean_html.replace(/<script.*?>[\s\S]*?<\/script>/ig, "");
	clean_html = clean_html.replace(/onclick="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onchange="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onblur="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onmouseover="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onmousedown="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onmouseup="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onkeypress="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onkeydown="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onkeyup="[\s\S]*?"/ig, "");
	clean_html = clean_html.replace(/onfocus="[\s\S]*?"/ig, "");
	if (strip_anchor == 1)
	{
		clean_html = clean_html.replace(/href="[\s\S]*?"/ig, "");
	}
	clean_html = clean_html.replace(/<input /ig, '<input readonly="readonly" ');
	clean_html = clean_html.replace(/ type="checkbox"/ig, ' type="checkbox" disabled="disabled" ');
	clean_html = clean_html.replace(/ type="radio"/ig, ' type="radio" disabled="disabled" ');
	clean_html = clean_html.replace(/ type="button"/ig, ' type="hidden" ');
	html+= clean_html;
	html+= '</div>';
	html+= '<div style="float:none;">';
	if (typeof print_footer !== 'undefined')
		html+= print_footer;
	html+= '</div>';
	html+="</body></html>";
	//alert(html);
	$.each( class_list, function(index, item){
		if (item === 'db-grid') 
		{
			$(table_grid_header).show();
			$(table_grid_scroller).attr('style', scroller_style);
		}
	});

	$("textarea#pdf_html").val(html);
	$("form#frm_pdf").submit();
}

appstack_reset = function()
{
	var ar_stack = [];
	sessionStorage.appstack = JSON.stringify(ar_stack);
	return false;
}

appstack_pop = function()
{
	if (sessionStorage.appstack)
	{
		var ar_stack = JSON.parse(sessionStorage.appstack);
		ar_stack.pop();  //pop current page
		var ar_url = ar_stack.pop();  //get to previous page
		if (typeof ar_url === 'object')
		{
			var url = $.param(ar_url);
			sessionStorage.appstack = JSON.stringify(ar_stack);
			if (url > ' ')
			{
				window.location.href = 'index.php?' + url;
			}
			else
			{
				window.open('','_self').close();
			}
		}
		else
		{
			window.open('','_self').close();
		}
	}
	return false;
}

appstack_push = function()
{
	if (!sessionStorage.appstack)
	{
		var ar_stack = [];
		sessionStorage.appstack = JSON.stringify(ar_stack);
	}
	else
	{
		var ar_stack = JSON.parse(sessionStorage.appstack);
	}
	var ar_url = window.location.search.substring(1).split('&');
	var ar_param = [];
	var ar_item = {};
	for (var i = 0; i < ar_url.length; i++)
	{
		ar_param = ar_url[i].split('=');
		ar_item[ar_param[0]] = ar_param[1];
	}
	var ar_compare = ar_stack[ar_stack.length - 1];
	if (typeof ar_compare === 'undefined')
	{
		ar_compare = {};
	}
	if (ar_compare['IX'] != ar_item['IX'])
	{
		ar_stack.push(ar_item);
	}
	else
	{
		ar_stack[ar_stack.length - 1] = ar_item;
	}
	sessionStorage.appstack = JSON.stringify(ar_stack);
}

appstack_switch_param = function(param, value)
{
	if (sessionStorage.appstack)
	{
		var ar_stack = JSON.parse(sessionStorage.appstack);
		ar_stack[ar_stack.length - 1][param] = value;
		sessionStorage.appstack = JSON.stringify(ar_stack);
	}
	return false;
}

logoutRedirect = function()
{
	//console.log('logoutRedirect');
	$.ajax({
		url: "ajax.php?call=logout_check",
		cache: false,
		dataType: "json",
		success: function(json) {
				//alert('got JSON');
				//alert(json.logout);
				if (json.logout == 1)
				{
					sheet_dirty = false;
					//alert('logging out ' + json.session);
					window.location.href = 'index.php?IX=logout';
				}
				else
				{
					var logout_timer = window.setTimeout("logoutRedirect()",30000);
				}
		}
		 ,error: function (request, status, error) { /*alert(status + ", " + error);*/ }
	});
}

toggleReports = function()
{
	//alert('toggleHelp');
	if ($('#report_select').is(':visible'))
	{
		$('#report_select').hide();
		//$('#report_icon').text('Reports...');
		$('#report_icon').show();
	}
	else
	{
		$('#report_select').show();
		//$('#report_icon').text('Close');
		$('#report_icon').hide();
	}
}

toggleHelp = function(ix)
{
	//alert('toggleHelp');
	if ($('#help_section').is(':visible'))
	{
		$('#help_section').hide();
		$('#help_icon').text('?');
		$('#help_icon').css('margin-top','-38px');
		$('#ajax_help').load('ajax.php?call=help_toggle&mode=off');
	}
	else
	{
		$('#help_section').show();
		$('#help_icon').text('X');
		$('#help_icon').css('margin-top','-18px');
		$('#ajax_help').load('ajax.php?call=help_toggle&mode=on');
	}
}

loadHelp = function(ix)
{
	$('#help_section').load('ajax.php?call=help_load&ix=' + ix,
			function() 
			{
				
			} );
}

function copy_to_clipboard(eid) {
	var elem = $('#' + eid).first().get(0);
	if (typeof elem !== 'undefined') {
		elem.select();
		elem.setSelectionRange(0, 99999);
		navigator.clipboard.writeText(elem.value);
		alert('Copied.');
	}
}

window_open = function (w_id,x,y)
{
	var open_timer = 500;
	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	//Set height and width to mask to fill up the whole screen
	$('#mask').css({'width':maskWidth,'height':maskHeight});
	 
	//transition effect    
	//$('#mask').fadeIn(open_timer);   
	$('#mask').fadeTo(0,0.8); 
	//Get the window height and width
	var winH = $(window).height();
	var winW = $(window).width();
	//Set the popup window to center
	//$(w_id).css('top',  winH/2-$(w_id).height()/2);
	//$(w_id).css('left', winW/2-$(w_id).width()/2);
 
	//transition effect
	$('#' + w_id).fadeIn(open_timer);
}
	
window_close = function ()
{
	$('#mask, div.window').hide();
	$('#terms_content').html(window_terms_orig_html);
}


window_video = function (w_id, ix)
{
	//$('#terms_title').html(title);
	$('#terms_content').html(window_terms_orig_html);
	//$('#terms_content').scrollTop(0);
	window_open(w_id);
	$('#terms_content').load('ajax.php?call=video_load&ix=' + ix,
			function() 
			{
				
			} );
	//$('#terms_content').load('mod/terms.php?text_key=' + text_key, function() { $('#terms_content').scrollTop(1); });
	//window_open(w_id);
}

window_popup = function (w_id, ix)
{
	$('#terms_content').html(window_terms_orig_html);
	window_open(w_id);
	$('#terms_content').load('ajax.php?call=video_load&ltype=text&ix=' + ix,
			function() 
			{
				
			} );
	//$('#terms_content').load('mod/terms.php?text_key=' + text_key, function() { $('#terms_content').scrollTop(1); });
	//window_open(w_id);
}

switch_tab = function(tab_name)
{
	$(".tab_content").hide();
	$("#tab_content_" + tab_name).show();
	$(".tab_header").removeClass("tab_header_selected");
	$("#tab_" + tab_name).addClass("tab_header_selected");
	$("#active_tab").val(tab_name);
	//$('#tab_content_' + tab_name + ' table.dbgrid[id]').each(function() {dTable[$(this).attr('id')].columns.adjust(); });
	$('#tab_content_' + tab_name + ' table.dbgrid').each(function() {format_dtable($(this).attr('id'));});
	appstack_switch_param('tab', tab_name);
	$('#tab_content_' + tab_name + ' div.db-grid').each(function() 
					{ 
						if (!ar_lcs_db_loaded[$(this).attr('id')])
						{
							ar_lcs_db_load[$(this).attr('id')](); 
						}
					});
}

function normalize_new_lines(text)
{
    return text.replace(/(\r\n|\r|\n)/g, '\r\n');
}

notes_load = function(ix, ix_id, show)
{
	/*
	$('#notes_ajax').load('ajax.php?call=notes_load&notes_ix=' + ix + '&notes_ix_id=' + ix_id,
			function() 
			{
				$('#system_notes').val(normalize_new_lines($('#notes_ajax').html().trim()));
			} );
	*/
	$.ajax({
		url: 'ajax.php?call=notes_load&notes_ix=' + ix + '&notes_ix_id=' + ix_id,
		cache: false,
		dataType: "json",
		success: function(json) {
				$('#system_notes').val(normalize_new_lines(json.note));
				$('#notes_followup_date').val(json.date);
				if (json.complete == '1')
				{
					$('#notes_followup_complete').attr('checked', 'checked');
				}
				if ($('#system_notes').val() > ' ' || $('#notes_followup_date').val() > ' ')
				{
					$('#note_icon_image').attr('src','img/lg_note_icon_checked_30x30.png');
				}
				else
				{
					$('#note_icon_image').attr('src','img/lg_note_icon_30x30.png');
				}
		}
		 ,error: function (request, status, error) { /* alert(status + ", " + error); */ }
	})
	$('#system_notes').unbind('change');
	$('#notes_followup_date').unbind('change');
	$('#notes_followup_complete').unbind('change');
	if (show)
	{
		$('#note_window').show();
	}
}

notes_save = function(ix, ix_id)
{
	//alert(val_checkbox($('#notes_followup_complete:checked').val()));
	$('#notes_ajax').load('ajax.php?call=notes_save&notes_ix=' + ix + '&notes_ix_id=' + ix_id + '&note=' + encodeURIComponent($('#system_notes').val()) + 
						'&date=' + encodeURIComponent($('#notes_followup_date').val()) + '&complete=' + val_checkbox($('#notes_followup_complete:checked').val()),
			function() 
			{
			} );
	$('#note_window').hide();
}

function key(e) 
{
	//return e?e.which:event.keyCode;
	evt = e || window.event;
	return evt.keyCode;
}

function delay(ms) 
{
	ms += new Date().getTime();
	while (new Date() < ms){}
} 

function prevent_enter_submit(e) 
{
	evt = e || window.event;
	//alert(evt.keyCode);
    if (evt.keyCode == 13) 
	{
       var tagName = e.target.tagName.toLowerCase(); 
	   var tagTpe = '';
	   if ($(e.target).attr('type'))
	   {
		   tagType = $(e.target).attr('type').toLowerCase();
	   }
       if (tagName !== "textarea" && tagType != 'submit' && tagType != 'button') 
	   {
		   if (window.event)
		   {
			   window.event.keyCode = 9;
			   return window.event.keyCode;
		   }
		   else
		   {
			   return false;
		   }
	   }
	   else
	   {
		   //return false;
	   }
    }
}

function check_enter(e)
{
	//alert('check enter');
	/*
	*/
	evt = e || window.event;
	//alert(evt.keyCode);
	if (evt.keyCode == 13)
	{
		return false;
	}
	//return false;
}

var ok_to_submit = false;
var form_to_submit = '';

function delay_submit(frm)
{
	form_to_submit = $(frm).attr('id');
	if (ok_to_submit)
	{
		frm.submit();
	}
	else
	{
		ok_to_submit = true;
		setTimeout( function() 
			{
				delay_submit(frm);
			}, 1000);
		return false;
	}
}

function preventEnterSubmit(e) 
{
    if (e.which == 13) {
        var $targ = $(e.target);

        if (!$targ.is("textarea") && !$targ.is(":button,:submit")) {
            var focusNext = false;
            $(this).find(":input:visible:not([disabled],[readonly]), a").each(function(){
                if (this === e.target) {
                    focusNext = true;
                }
                else if (focusNext){
                    $(this).focus();
                    return false;
                }
            });

            return false;
        }
    }
}

/* ************* Form processing ****** */
function lcs_autocomplete_open(fid)
{
	setTimeout(function() {
			$('#' + fid + '_autocomplete').show(); 
			lcs_autocomplete_filter(fid);
		}, 50);
}

function lcs_autocomplete_close(fid)
{
	setTimeout(function() {$('#' + fid + '_autocomplete').hide(); }, 600);
}

function lcs_autocomplete_filter(fid)
{
	var search_text = $('#' + fid).val().toLowerCase();
	$('div#' + fid + '_autocomplete ul li').each(function() {
			var string = $(this).text().toLowerCase();
			if(string.indexOf(search_text)!=-1) {
				$(this).show();
			} else {
				$(this).hide();
			}
		});
}

function lcs_autocomplete_pick(elem, fid)
{
	$('#' + fid).val($(elem).text());
}
/****************************************/

var ac_picked = 0;
var ac_filter = 0;
var ac_mouse_x = 0;
var ac_mouse_y = 0;

jQuery.expr[':'].Contains = function(a,i,m)
{
	return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
};

jQuery.expr[':'].Equals = function(a,i,m)
{
	return (a.textContent || a.innerText || "").toUpperCase() == m[3].toUpperCase();
};

autocomplete_toggle = function(fid, limit_list)
{
	if($('#' + fid + '_items').is(":visible")) 
	{
		autocomplete_close(fid, limit_list);
	}
	else
	{
		autocomplete_open(fid, limit_list);
	}
}

autocomplete_open = function(fid, limit_list)
{
	$('#' + fid + '_items li').slideDown(0);
	$('#' + fid + '_items').show().scrollTop(0);
	ac_picked = 0;
	ac_filter = 0;
	setTimeout(function()
	{						
		$(document).on('click.mynamespace_' + fid, function(event) { 
			if($(event.target).parents().index($('#' + fid + '_items')) == -1 && $(event.target).attr('id') != fid + '_mask' ) {
				if($('#' + fid + '_items').is(":visible")) {
					autocomplete_close(fid, limit_list);
					$(document).off('click.mynamespace_' + fid);
				}
			}        
		});
		$('#' + fid + '_mask').keydown(function (e) 
			{
				if (e.keyCode == 9) 
				{
					autocomplete_close(fid, limit_list);
				}
			});
	},200);
	setTimeout(function() {$('#' + fid + '_items').attr('ac_open','1');},200);
}

autocomplete_close = function(fid, limit_list)
{
	setTimeout(function() 
					{
						if (ac_picked == 0)
						{
							$('#' + fid).val($('#' + fid + '_mask').val());
						}
						if (limit_list)
						{
							var filter = $('#' + fid + '_mask').val();
							if (filter)
							{
								$('#' + fid).val($('#' + fid + '_items li:Equals(' + filter + ')').first().attr('ac_value'));
							}
							else
							{
								$('#' + fid).val('');
							}
							
						}
						ac_filter = 0;
					},50);
	setTimeout(function() 
					{
						$('#' + fid + '_items').hide(); 
						$('#' + fid + '_items').attr('ac_open','0');
						$('#' + fid + '_items li').slideDown(0);
						$(document).off('click.mynamespace_' + fid);
					},100);
}
autocomplete_pick = function(fid,value,text, limit_list)
{
	$('#' + fid + '_mask').val(text);
	$('#' + fid).val(value);
	ac_picked = 1;
	autocomplete_close(fid, limit_list);
}

autocomplete_filter = function(e, fid)
{
	var xkey = key(e);
	if (xkey == 9 || xkey > 111 || (xkey < 48 && xkey != 8))
	{
		return;
	}
	var filter = $('#' + fid + '_mask').val();
	if (filter)
	{
		$('#' + fid + '_items li:not(:Contains(' + filter + '))').slideUp(50);
		$('#' + fid + '_items li:Contains(' + filter + ')').slideDown(50);
	}
	else
	{
		$('#' + fid + '_items li').slideDown(50);
	}
}

function check2val(cbname)
{
	var ar_values = [];
	$('input[name=' + cbname + ']:checked').each(function () {
		ar_values.push($(this).val());
	});
	return(ar_values);
}

function trim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

function ltrim(stringToTrim) 
{
	return stringToTrim.replace(/^\s+/,"");
}

function rtrim(stringToTrim) 
{
	return stringToTrim.replace(/\s+$/,"");
}
  
function str2num(strInput)
{
	var numResult = 0.0;
	var dec_flag = 0;
	var strVal = "0";
	strInput = trim(strInput);
	for (var i = 0; i < strInput.length; i++)
	{
		strChar = strInput.charAt(i);
		if ((i == 0) && (strChar == "-"))
			strVal = "-0";
		if ((strChar >="0") && (strChar <="9"))
			strVal = strVal + strChar;
		if ((strChar == ".") && (dec_flag == 0))
			{
				strVal = strVal + strChar;
				dec_flag = 1;
			}
	}
	numResult = parseFloat(strVal);
	//alert(strVal);
	return numResult;
}

// Parameters:
//    numInput - number to convert to string
//    intDec - number of digits after the decimal point
//    strComma - thousands separatot
//    intLen - maximum length of result not counting signs - will fill with leading zeroes
//    strMinusL - minus character(s) to the left of result
//    strMinusR - minus character(s) to the right of result
function num2str(numInput, intDec, strComma, intLen, strMinusL, strMinusR)
{
	var i = 0;
	var j = 0;
	var strResult = "";
	var numResult = Math.round(numInput * Math.pow(10, intDec));
	if (numResult >= 0)
		strMinusL = strMinusR = "";
	var arNum = (Math.abs(numResult) + "").split("");  //convert to array
	var x = arNum.length;                              //make sure at least one zero before decimal
	if (x < (intDec + 1))
	{
		var y = intDec - x + 1;
		for (i = 0; i < y; i++)
			arNum.splice(i, 0, "0");
	}
	if (intDec > 0)                                    //insert decimal
		arNum.splice(arNum.length - intDec, 0, ".");
	j = 0;                                             //insert thousands
	x = arNum.length - 1;
	if (intDec > 0)
		intDec = intDec + 1;
	for (i = (x - intDec); i > 0; i--)
	{
		j = j + 1;
		if (j == 3)
		{
			arNum.splice(i, 0, strComma);
			j = 0;
		}
	}
	if (intLen > 0)                                    //insert leading zeroes
	{
		for (i = 0; (i < intLen - arNum.length); i++)
		{
			arNum.splice(0, 0, "0");
		}
	}
	strResult = strMinusL + arNum.join("") + strMinusR;
	return strResult;
}

function val_dollar_field(field)
{
	if (!strID) 
		var strID = "";
	field.value = trim(field.value);
	field.value = num2str(str2num(field.value),2,",",0,"-","");
}

function val_int_field(field)
{
	if (!strID) 
		var strID = "";
	field.value = trim(field.value);
	field.value = num2str(str2num(field.value),0,",",0,"-","");
}

function check_dirty()
{
	if (sheet_dirty == true)
	{
		return "Data has changed - discard changes?";
	}
}

function nl2br (str, is_xhtml) 
{   
    var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';    
    return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
}

function set_country(state_field, country_field)
{
	if ($('#' + country_field).val() == '')
	{
		if ($('#' + state_field + ' option:selected').attr('attr_country') != 'United States of America')
		{
			$('#' + country_field).val($('#' + state_field + ' option:selected').attr('attr_country'));
		}
	}
	/*
	else
	{
		if ($('#' + state_field + ' option:selected').attr('attr_country') == 'United States of America')
		{
			$('#' + country_field).val('');
		}
	}
	*/
}

function reload_captcha(elem, captcha_type) {
	$('#' + elem).attr('src', 'ajax.php?call=_captcha&captcha_type=' + captcha_type + '&ver=' + Math.random()) ;
}

var MAX_DUMP_DEPTH = 10;

dump = function(obj, name, indent, depth) 
{
	  if (depth > MAX_DUMP_DEPTH) {
			 return indent + name + ": <Maximum Depth Reached>\n";
	  }
	  if (typeof obj == "object") {
			 var child = null;
			 var output = indent + name + "\n";
			 indent += "\t";
			 for (var item in obj)
			 {
				   try {
						  child = obj[item];
				   } catch (e) {
						  child = "<Unable to Evaluate>";
				   }
				   if (typeof child == "object") {
						  output += dump(child, item, indent, depth + 1);
				   } else {
						  output += indent + item + ": " + child + "\n";
				   }
			 }
			 return output;
	  } else {
			 return obj;
	  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit