/** * Handle LOAD MORE events * */ var ajax_url = "http://www.domusacademy.com/wp-admin/admin-ajax.php"; function getParameterByName(name) { name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(location.search); return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); } jQuery(function(){ jQuery('.banner-button').click(function(){ //alert(jQuery('#idnlist').val()); jQuery.post(ajax_url, { pshowed : jQuery('#idnlist').val(), action : 'load_more_hp', offset : jQuery('.banner-button').attr('iteration'), type : jQuery('body').attr('class'), reference : jQuery('body').attr('id'), y : getParameterByName('y'), m : getParameterByName('m') }, returnPosts, 'JSON'); }); }); //var returnPosts = function(data) function returnPosts(data) { //alert(data.endpoint); //alert(data.moreids); if (document.getElementById('idnlist')) { document.getElementById('idnlist').value = document.getElementById('idnlist').value + data.moreids; } //alert(document.getElementById('idnlist').value); var temp = jQuery('[loadmore] div[content="collection"]').html(); jQuery('[loadmore] div[content="collection"]').html(temp + data.contenuto); if(jQuery('body').attr('id') == 'home') var posts_per_page = 4; else var posts_per_page = 10; var offset = (parseInt(jQuery('.banner-button').attr('iteration')) + posts_per_page); jQuery('.banner-button').attr('iteration', offset); if(data.endpoint == true) { jQuery('a.banner-button').remove(); } jQuery('[ellipsable]').dotdotdot({ watch: "window" }); }