Skip to content

Instantly share code, notes, and snippets.

@meSingh
Created May 21, 2013 11:42
Show Gist options
  • Save meSingh/5619236 to your computer and use it in GitHub Desktop.
Save meSingh/5619236 to your computer and use it in GitHub Desktop.
This is the PingClan v1.2 bugfix. Please replace the code in your /views/default/assets/js/custom.js file with this code.
$(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 = $('<div class="alert alert-error">' + newUrl + " " + lang["status_error"] + '</div>').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 != "<strong>ERROR: </strong>")
{
className = 'alert alert-';
if(data.status_msg === 'success')
{
className += 'primary';
count = count + 1;
}
else if(data.status_msg === 'error')
{
className += 'error';
}
template = $('<div class="' + className + '">' + data.site + '</div>').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');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment