// Admin settings -> monitor if schema is activated and reflect in the dashboard home

// Identify each activated icon on dash home
const schema_status_local_business_icon = document.getElementById('schema_status_local_business_icon');
const schema_status_logo_icon = document.getElementById('schema_status_logo_icon');
const schema_status_sitelinks_icon = document.getElementById('schema_status_sitelinks_icon');
const schema_status_woocommerce_icon = document.getElementById('schema_status_woocommerce_icon');

// Identify each checkbox 
const checkbox_local_display = document.getElementById('checkbox_local_display');
const checkbox_logo_activate = document.getElementById('checkbox_logo_activate');
const checkbox_sl_activate = document.getElementById('checkbox_sl_activate');
const checkbox_woocommerce_activate = document.getElementById('checkbox_woocommerce_activate');

// Schema status on load checkers
if (checkbox_local_display.checked ) {

    schema_status_local_business_icon.style.background = '#ff7601';
    schema_status_local_business_icon.textContent = 'activated';
    
} else {
    
    schema_status_local_business_icon.style.background = '#112e76';
    schema_status_local_business_icon.textContent = 'not activated';
    
}

if (checkbox_logo_activate.checked ) {

    schema_status_logo_icon.style.background = '#ff7601';
    schema_status_logo_icon.textContent = 'activated';
    
} else {
    
    schema_status_logo_icon.style.background = '#112e76';
    schema_status_logo_icon.textContent = 'not activated';
    
}

if (checkbox_sl_activate.checked ) {

    schema_status_sitelinks_icon.style.background = '#ff7601';
    schema_status_sitelinks_icon.textContent = 'activated';
    
} else {
    
    schema_status_sitelinks_icon.style.background = '#112e76';
    schema_status_sitelinks_icon.textContent = 'not activated';
    
}

if (checkbox_woocommerce_activate.checked ) {

    schema_status_woocommerce_icon.style.background = '#ff7601';
    schema_status_woocommerce_icon.textContent = 'activated';
    
} else {
    
    schema_status_woocommerce_icon.style.background = '#112e76';
    schema_status_woocommerce_icon.textContent = 'not activated';
    
}

// checkbox on click listeners to update if it is activated on dashboard
// Local business checkbox + activated icon
checkbox_local_display.addEventListener('click', function handleClick() {
    
if (checkbox_local_display.checked ) {

    schema_status_local_business_icon.style.background = '#ff7601';
    schema_status_local_business_icon.textContent = 'activated';
    
} else {
    
    schema_status_local_business_icon.style.background = '#112e76';
    schema_status_local_business_icon.textContent = 'not activated';
    
}
  
});

// Logo checkbox + activated icon
checkbox_logo_activate.addEventListener('click', function handleClick() {
    
if (checkbox_logo_activate.checked ) {

    schema_status_logo_icon.style.background = '#ff7601';
    schema_status_logo_icon.textContent = 'activated';
    
} else {
    
    schema_status_logo_icon.style.background = '#112e76';
    schema_status_logo_icon.textContent = 'not activated';
    
}
  
});

// Sitelinks checkbox + activated icon
checkbox_sl_activate.addEventListener('click', function handleClick() {
    
if (checkbox_sl_activate.checked ) {

    schema_status_sitelinks_icon.style.background = '#ff7601';
    schema_status_sitelinks_icon.textContent = 'activated';
    
} else {
    
    schema_status_sitelinks_icon.style.background = '#112e76';
    schema_status_sitelinks_icon.textContent = 'not activated';
    
}
  
});

// WooCommerce checkbox + activated icon
checkbox_woocommerce_activate.addEventListener('click', function handleClick() {
    
if (checkbox_woocommerce_activate.checked ) {

    schema_status_woocommerce_icon.style.background = '#ff7601';
    schema_status_woocommerce_icon.textContent = 'activated';
    
} else {
    
    schema_status_woocommerce_icon.style.background = '#112e76';
    schema_status_woocommerce_icon.textContent = 'not activated';
    
}
  
});