var cached = 0; var input_array; function search_box() { var html = `
`; document.getElementById('cache').innerHTML = html; } $(document).on('submit', '#stats_form', function(){ cache(); }); function cache() { var timeout_input = document.getElementById('timeout').value * 1000; var input = document.getElementById('p_identity_multiple').value; input_array = input.split(','); var html = ` `; document.getElementById('cache').innerHTML = html; call_stats(0, timeout_input); } function call_stats(i, timeout_input) { get_stats(input_array[i].trim()); if(i < input_array.length-1) { setTimeout(function(){ i += 1; call_stats(i, timeout_input); }, timeout_input); } } function cache_log(p_identity, result) { if(result) { document.getElementById('cache_results').innerHTML += '' + p_identity + '
'; } else { document.getElementById('cache_results').innerHTML += '' + p_identity + '
'; } cached += 1; if(cached == input_array.length) { document.getElementById('loading_icon').style.display = "none"; } } function get_stats(p_identity) { stats_form = { "p_identity" : p_identity }; var stats_data = JSON.stringify(stats_form); var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var result = JSON.parse(this.responseText); if(result.error) { cache_log(p_identity, false); } else { cache_log(p_identity, true); } } }; xhttp.withCredentials = true; xhttp.open("post", "api/get_stats.php", ); xhttp.send(stats_data); return; } function topFunction() { document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera } function get_config_cache() { config_form = { "password" : "" }; var config_data = JSON.stringify(config_form); var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var result = JSON.parse(this.responseText); if(result.password) { login_menu(); } else { alert(result.message); } } }; xhttp.withCredentials = true; xhttp.open("post", "api/get_config.php"); xhttp.send(config_data); } function get_config() { current_password = document.getElementById('password').value; config_form = { "password" : current_password }; var config_data = JSON.stringify(config_form); var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { var result = JSON.parse(this.responseText); if(result.error) { alert(result.message); } else { if(!result.data.use_cache) { alert("You have disabled cache in the configuration!"); } search_box(); } } }; xhttp.withCredentials = true; xhttp.open("post", "api/get_config.php"); xhttp.send(config_data); } function login_menu() { topFunction(); var html = ''; document.getElementById("cache").innerHTML = html; }