/** * Load related posts */ (function($) { var getEndpointURL; // Utility get related posts JSON endpoint from URLs /** * Utility get related posts JSON endpoint from URLs * * @param string URL (optional) * @return string endpoint URL */ getEndpointURL = function( URL ) { var locationObject = document.location; if ( 'string' == typeof( URL ) && URL.match( /^https?:\/\// ) ) { locationObject = document.createElement( 'a' ); locationObject.href = URL; } if ( '' == locationObject.search ) { return locationObject.pathname + '?relatedposts'; } else { return locationObject.pathname + locationObject.search + '&relatedposts'; } }; getAnchor = function( post ) { if ( '' == post.excerpt ) var anchor_title = post.title; else var anchor_title = post.title + "\n\n" + post.excerpt; return [ '', '' ]; } generateMinimalHtml = function( posts ) { var html = ''; $.each( posts, function( index, post ) { var anchor = getAnchor( post ); var classes = 'jp-relatedposts-post jp-relatedposts-post' + index; html += '
'; html += ''; html += ''; html += '
'; } ); return ''; } generateVisualHtml = function( posts ) { var html = ''; $.each( posts, function( index, post ) { var anchor = getAnchor( post ); var classes = 'jp-relatedposts-post jp-relatedposts-post' + index; if ( '' == post.img.src ) classes += ' jp-relatedposts-post-nothumbs'; else classes += ' jp-relatedposts-post-thumbs'; html += '