Your IP : 216.73.216.85


Current Path : /home/smartconb/www/armencom33/administrator/components/com_eyesite/assets/
Upload File :
Current File : /home/smartconb/www/armencom33/administrator/components/com_eyesite/assets/eyesite.js

// ********************************************************************
// Product      : Eyesite
// Date         : 1 December 2023
// Copyright    : Les Arbres Design 2012-2023
// Contact      : https://www.lesarbresdesign.info
// Licence      : GNU General Public License
// *********************************************************************
//
// Admin Javascript for Eyesite
//
jQuery(document).ready(function() { 
    jQuery('.ladj-change-submit').on('change', lad_submit); 
    jQuery('.ladj-click-submit').on('click', lad_submit); 
    jQuery('.ladj-check-all').on('click', function() {Joomla.checkAll(this)}); 
	if (jQuery('#ajax_response').length)
		setTimeout(function(){ey_check_for_update()},1000);
	var ey_scan_url = Joomla.getOptions('ey_scan', '');
	if (ey_scan_url != '')		// the controller sets this to start an admin scan
		jQuery.ajax({url:ey_scan_url, type:'GET', timeout:1000});
});

function lad_submit(e)
{
    e.preventDefault();    
    if (typeof(jQuery(this).attr('data-controller')) != 'undefined') 
        this.form.controller.value = jQuery(this).attr('data-controller');
    if (typeof(jQuery(this).attr('data-task')) != 'undefined') 
        this.form.task.value = jQuery(this).attr('data-task');
    this.form.submit();
}

function ey_check_for_update()
{
	var url = '?option=com_eyesite&task=ajax_status&format=raw&tmpl=component';
	jQuery.ajax({
		url: url,
		type: 'get',
		success: function(responseText, status, xhr) {ey_handle_response(responseText);},
		});
}

function ey_handle_response(responseText)
{
	jQuery('#ajax_response').html(responseText);
	if (typeof window.eyesite_responseText === 'undefined')	// first time through
		{
		window.eyesite_scanning = false;
		window.eyesite_responseText = responseText;
		window.eyesite_responseCount = 0;
		setTimeout(function(){ey_check_for_update()},1000);	// check again in 1 second
		return;
		}
		
	var scanning = false;
	if (responseText.indexOf('eyesite_scanning') > -1)
		scanning = true;
		
	if (window.eyesite_scanning && !scanning)			    // if we were scanning and now we're not, reload the page
		window.location.href = window.location.href.replace('&task=scan_now','');

	window.eyesite_scanning = scanning;

	if (window.eyesite_responseText != responseText)		// if the response has changed
		{
		window.eyesite_responseText = responseText;
		window.eyesite_responseCount = 0;					// reset the count, and ..
		setTimeout(function(){ey_check_for_update()},1000);	// check again in 1 second
		return;
		}
	window.eyesite_responseCount ++;						// if the response hasn't changed, increment the count
	if (window.eyesite_responseCount >= 60)					// if it hasn't changed for 60 refreshes (2 minutes)
		{
		setTimeout(function(){ey_check_for_update()},5000);	// check again in 5 seconds
		return;
		}
	setTimeout(function(){ey_check_for_update()},2000);		// count is < 60 - check again in 2 seconds
}