Randomt Post Plus Thumbnail Blogspot Menggunakan Jquery


Kali ini kita akan mencoba membuat widget blogspot berupa Random Post dengan menggunakan Jquery :

  <style>
div.img {
    margin: 5px;
    border: 1px solid #ccc;
    float: left;
    width: 180px;
}

div.img:hover {

    border: 1px solid #777;
}

div.img img {

    width: 100%;
    height: 100px;
}

div.desc {

    padding: 15px;
    text-align: center;
    font-size:small;
}
  </style>

<div id="result"></div>

<script type='text/javaScript'> 
//<![CDATA[
var rdp_numposts = 8; 
var rdp_snippet_length = 150; 
var rdp_info = '0'; 
var rdp_comment = 'Comments'; 
var rdp_disable = 'Turn off comments'; 
var rdp_current = []; 
var rdp_total_posts = 0; 
var rdp_current = new Array(rdp_numposts); 

function totalposts(a){rdp_total_posts=a.feed.openSearch$totalResults.$t}
document.write('<script type="text/javascript" src="https://www-selebritis-info.blogspot.com/feeds/posts/default?alt=json-in-script&max-results=0&callback=totalposts"><\/script>');

function getvalue(){for(var b=0;b<rdp_numposts;b++){var d=false;var c=get_random();
for(var a=0;a<rdp_current.length;a++){if(rdp_current[a]==c){d=true;break}}if(d){b--}else{rdp_current[b]=c}}}
function get_random(){var a=1+Math.round(Math.random()*(rdp_total_posts-1));
return a}; 
//]]>
</script> 

<script type='text/javaScript'> 
//<![CDATA[
function random_posts(n){a=location.href;y=a.indexOf("?m=0");
for(var f=0;f<rdp_numposts;f++){var l=n.feed.entry[f];
var m=l.title.$t;if("content" in l){
var o=l.content.$t}else{
if("summary" in l){
var o=l.summary.$t}else{var o=""}}o=o.replace(/<[^>]*>/g,"");
if(o.length<rdp_snippet_length){var k=o}else{o=o.substring(0,rdp_snippet_length);var b=o.lastIndexOf(" ");
k=o.substring(0,b)+"&#133;"}for(var e=0;e<l.link.length;e++){if("thr$total" in l){var h=l.thr$total.$t+" "+rdp_comment}else{h=rdp_disable}
if(l.link[e].rel=="alternate"){var d=l.link[e].href;
if(y!=-1){d=d+"?m=0"}var g=l.published.$t;
if("media$thumbnail" in l){var c=l.media$thumbnail.url}else{c="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg67tj7PIIMHgygdPTL18T8Zt65EH45-AjnUrUoH3iDMxeODm2SSgiV993Iisq6Mn922AhdORvNk9lzM1JczgVfM6_YtO-47ShLLqPuCIi8wtSf-ncq8hKNhEF59L7lxSDkDxXrZ7FJoZ4/s1600/no_image.jpg"}
}}
$('#result').append('<div class="img"><a href="' + d + '"><img src="'+c+'" alt="Fjords" width="300" height="200"></a><div class="desc">'+m.substr(0, 20));
}}
getvalue();
for(var i=0;i<rdp_numposts;i++){
document.write('<script type="text/javascript" src="https://www-selebritis-info.blogspot.com/feeds/posts/default?alt=json-in-script&start-index='+rdp_current[i]+'&max-results=1&callback=random_posts"><\/script>')
}; 
//]]>
</script> 

Smoga bisa dikembangkan lagi oleh sobat blogger smua....
Previous
Next Post »