Gerbong247-Logo-1.png

Menampilkan Posting Lainnya

Pasang daftar posting lainnya tujuan utamanya supaya pengunjung bisa punya pilihan kalo masih ingin menjelajah.

Gerbong247-PostFooterPostingLainnya.png

Sintaks Posting Lainnya

          &#8667; Posting Lainnya:<br/>
<div id='random-post-container'>Memuat...</div>
<script>
// Feed configuration
var homePage = &#39;//gerbong247.blogspot.com&#39;,
 maxResults = 5,
 containerId = &#39;random-post-container&#39;;
// Function to generate random number limited from `min` to `max`
// Used to create a valid and safe random feed `start-index`
function getRandomInt(min, max) {
 return Math.floor(Math.random() * (max - min + 1)) + min;
}
// Function to shuffle arrays
// Used to randomize order of the generated JSON feed
function shuffleArray(arr) {
 var i = arr.length, j, temp;
 if (i === 0) return false;
 while (--i) {
 j = Math.floor(Math.random() * (i + 1));
 temp = arr[i];
 arr[i] = arr[j];
 arr[j] = temp;
 }
 return arr;
}
// Get a random start index
function createRandomPostsStartIndex(json) {
 var startIndex = getRandomInt(1, (json.feed.openSearch$totalResults.$t - maxResults));
 if (window.console &amp;&amp; window.console.log) console.log(&#39;Get the post feed start from &#39; + startIndex + &#39; until &#39; + (startIndex + maxResults));
 document.write(&#39;&lt;scr&#39; + &#39;ipt src=&quot;&#39; + homePage + &#39;/feeds/posts/summary?alt=json-in-script&amp;orderby=updated&amp;start-index=&#39; + startIndex + &#39;&amp;max-results=&#39; + maxResults + &#39;&amp;callback=randomPosts&quot;&gt;&lt;/scr&#39; + &#39;ipt&gt;&#39;);
}
// Widget&#39;s main function
function randomPosts(json) {
 var link, ct = document.getElementById(containerId),
 entry = shuffleArray(json.feed.entry),
 skeleton = &quot;&lt;ul&gt;&quot;;
 for (var i = 0, len = entry.length; i &lt; len; i++) {
 for (var j = 0, jen = entry[i].link.length; j &lt; jen; j++) {
 if (entry[i].link[j].rel == &quot;alternate&quot;) {
 link = entry[i].link[j].href;
 break;
 }
 }
 skeleton += &#39;&lt;li&gt;&lt;a href=&quot;&#39; + link + &#39;&quot;&gt;&#39; + entry[i].title.$t + &#39;&lt;/a&gt;&lt;/li&gt;&#39;;
 }
 ct.innerHTML = skeleton + &#39;&lt;/ul&gt;&#39;;
}
document.write(&#39;&lt;scr&#39; + &#39;ipt src=&quot;&#39; + homePage + &#39;/feeds/posts/summary?alt=json-in-script&amp;max-results=0&amp;callback=createRandomPostsStartIndex&quot;&gt;&lt;/scr&#39; + &#39;ipt&gt;&#39;);
</script>

Referensi: dte.web.id


Gerbong247 Oleh

2022-

Blog Ini Dihosting Di Blogger.com