vendredi 26 août 2016

How to make this javascript, show random post by it's label?

I have searching about random post and it's show Math.random() function, but because my lack of knowledge about javascripting so I need your help to make this javascript work on random, thanks.

<script type='text/javascript'>
//<![CDATA[[
  function CompletedProject(json) {
    for (var i = 0; i < json.feed.entry.length; i++) {
      var judulPost = json.feed.entry[i].title.$t;
      var thumbPost = json.feed.entry[i].media$thumbnail.url;
      //var linkPost = json.feed.entry[i].link[1].href;
      var linkPost;  
    // Get rel=alternate for truly post url
    for (var j=0; j < json.feed.entry[i].link.length; j++)
    {
      if (json.feed.entry[i].link[j].rel == 'alternate')
      {
        linkPost = json.feed.entry[i].link[j].href;
        break;
      }
    }

      var showcompleted = '<div class="ani-item"><a href="'+linkPost+'"><img alt="'+judulPost+'" class="shine" data-original="'+thumbPost+'"/><h4>'+judulPost+'</h4></a></div>';
      document.write(showcompleted);
    }
  }
//]]>
</script>

  <script src='/feeds/posts/default/-/Complete?alt=json-in-script&amp;callback=CompletedProject'/>




Aucun commentaire:

Enregistrer un commentaire