$(function() { var html = $('html, body'), results = $('results'), domainPing = $('#domain-ping'); $('#search').on('submit', function() { // Scroll to result area on form submit html.delay(1100).animate({ scrollTop: $('#search').offset().top }, 800, 'easeInOutExpo'); // Remove the old result on next run $('#results').empty(); // Get the url var url = $('#url').val().toLowerCase(); url = url.replace('https://', '').replace('http://', '').replace('www.', '').replace('/', ''); newUrl = url.substr(0, 1).toUpperCase() + url.substr(1); // Show a notification domainPing.text(lang['pinging'] + " " + newUrl); $('#loader').show("slide", { direction: "right" }, 1000); // do the intial ping $.get('process.php?init=true', function(siteNum) { console.log('first hit'); // show a error if no urls are found if(siteNum.available < 1) { error = $('
' + newUrl + " " + lang["status_error"] + '
').hide(); error.appendTo('#results').show("slide", { direction: "right" }, 1000); return; } handles = []; count = 0; // process all pings for(i = 1; i <= siteNum.available; i++) { handle = $.get('process.php', { 'domain' : url, 'hit_on' : i }, function(data) { if(data.site != "ERROR: ") { className = 'alert alert-'; if(data.status_msg === 'success') { className += 'primary'; count = count + 1; } else if(data.status_msg === 'error') { className += 'error'; } template = $('
' + data.site + '
').hide(); template.appendTo('#results').show("slide", { direction: "right" }, 1000); } }, "json"); handles.push(handle); } // Show number of backlinks processed $.when.apply($, handles).then(function(){ $("#animator, #domain-ping").hide(); domainPing.text( count + lang['after_ping'] + newUrl); domainPing.show("slide", { direction: "right" }, 1000); }); }, "json"); }); // Back to top $('.backtotop').click(function(){ html.animate({scrollTop:0}, 'slow'); }); });