This widget will display the titles of your posts randomly below
Here are the steps to install this widget to your blog
1)
Copy the code below and place on a colored line merah.Untuk change the
number of posts display on the widget, you can change the value 5 to the
value you want.
<style type="text/css"> <! -. Random_post_content {width: 100%;}.
Random_post_content img {width: 32px; height: 32px;
background-position: center; margin: 7px; padding: 2px; border: thin
solid # 888;}. Random_post_content_item {border-top: thin dashed # 888;}. Random_post_content_item table,. Random_post_content_item tr,. Random_post_content_item td {vertical-align: middle;}. Random_post_content_item table {margin-bottom: 2px; margin-top: 3px;}. Random_post_content_item: hover {background-color: # 4A3829;}. Random_post_title a {text-transform: uppercase; font-size: 12px; text-decoration: none; font-weight: bold}. Random_post_info a {font-size: 11px; text-decoration: none;}. Random_post_content_item: hover. Random_post_title a {color: # FFFFCC;}. Random_post_content_item: hover. Random_post_info a {color: # 888;}. Random_post_content_item: hover. Random_post_title a: hover {color: # FFCC00;}. Random_post_content_item: hover. Random_post_info a: hover {text-decoration: underline;}-> </ Style>
<div class="random_post_content" id="random_posts_id"> </ div>
<script type="text/javascript"> <! -
Random_Max var = 5;Total_Posts_Number var = 0;Rand_Posts_Title var = [];Rand_Posts_Url var = [];Rand_Posts_Author var = [];Rand_Posts_Comment_Number var = [];Rand_Posts_Thumbnail var = [];Rand_Posts_Snippet var = [];
function
Vbs_Random_Post (json) {var entry; var re = / <\ S [^>] *> /
g; var str; var banner_begin_index; var banner_end_index: for (var i =
0; i <Random_Max; i + +) {entry = json.feed.entry
[i]; Rand_Posts_Title [i] = entry.title. $ t: for (var k = 0; k
<entry.link.length; k + +) {if (entry.link [k]. rel = =
'alternate') {Rand_Posts_Url [i] = entry.link [k]. href; break;}}
Rand_Posts_Author [i] = entry.author [0]. name. $ t;
Rand_Posts_Comment_Number [i] = parseInt (entry. thr
$ total. $ t) if ("content" in entry) {Rand_Posts_Snippet [i] =
entry.content. $ t;} else if ("summary" in entry) {Rand_Posts_Snippet
[i] = entry.summary. $ t;}
else Rand_Posts_Snippet [i] = ""; if (Rand_Posts_Snippet [i]. search
("bp.blogspot.com")! = -1) Rand_Posts_Thumbnail [i] = $ thumbnail.url
entry.media; else {str =
"src \ u003d \" "; banner_begin_index = Rand_Posts_Snippet [i]. search
(str) if (banner_begin_index == -1) {Rand_Posts_Thumbnail [i] = =
Rand_Posts_Snippet [i]. Substrings (banner_begin_index + str.length);
str = "\" "; banner_end_index = Rand_Posts_Thumbnail [i]. Search (str);
Rand_Posts_Thumbnail [i] = Rand_Posts_Thumbnail [i]. Substrings (0,
banner_end_index) ;}}
Rand_Posts_Snippet [i] = Rand_Posts_Snippet [i]. replace (re, "") if
(Rand_Posts_Snippet [i]. length> 140) {Rand_Posts_Snippet [i] =
Rand_Posts_Snippet [i]. substrings (0, 140) + '...';}} Install_Random_Posts ();}
Install_Random_Posts
function () {var str_out = "": for (var i = 0; i <Random_Max; i + +)
{str_out + = '<div class="recent_post_content_item">'; str_out + =
'<table width = "0% "border
=" 0 "> '; str_out + =' <tr> '; str_out + =' <td> ';
str_out + =' <a href =" '+ Rand_Posts_Url [i] +' "title =" '+ Rand_Posts_Snippet
[i] + '">'; str_out + = '<img src="' + +'" width="32px"
Rand_Posts_Thumbnail[i] height="32px"/>'; str_out + = '</ a> ';
str_out + =' </ td> '; str_out + =' <td> '; str_out + ='
<div class="recent_post_title"> '; str_out + =' <a href = "'+
Rand_Posts_Url [i] +
'"title ="' + Rand_Posts_Snippet [i] + '">'; str_out + =
Rand_Posts_Title [i]; str_out + = '</ a>'; str_out + = '</
div>'; str_out + = ' <div
class="recent_post_info"> '; str_out + =' <a href="' +'" title="'
Rand_Posts_Url[i] + + + Rand_Posts_Snippet[i]'"> '; str_out + =' By
'+ Rand_Posts_Author
[i] + '-' + Rand_Posts_Comment_Number [i] + 'comments'; str_out + =
'</ a>'; str_out + = '</ div>'; str_out + = '</ td>';
str_out + =
'</ tr>'; str_out + = '</ table>'; str_out + = '</
div>';} document.getElementById ('random_posts_id'). innerHTML =
str_out;}
Vbs_Get_Post_Num
function (json) {Total_Posts_Number = json.feed.openSearch $
totalResults. $ t: if (Total_Posts_Number <= Random_Max) {var
START_INDEX = 1; Random_Max = Total_Posts_Number;} else {var START_INDEX
= 1 + Math.floor (Math. random () * (Total_Posts_Number - Random_Max));}
Document.write ('<script type = "text / JavaScript" src =
"http://URL-blog-anda.blogspot.com/feeds/posts/default?start-index =' +
START_INDEX + '& max-results =
'+ Random_Max + "& orderby = published & alt = json-in-script
& callback = Vbs_Random_Post"> <\ / script>');}
-> </ Script><Script type = "text / JavaScript" -> </ Script>
2) Then, log in to your blogger account, dashboard> design> page elements> Add a Gadget> HTML / Java Script.3) After that, paste the above code and press save4) Completion
0 komentar:
Posting Komentar