free web
free web
free web
[ Tin mới · Thành viên · Nội quy · Tìm kiếm · RSS ]
  • Page 1 of 1
  • 1
Forum » Giao lưu chia sẻ kinh nghiệm về website » Tổng hợp code và javascript » Code tiện ích thống kê bài viết đẹp cho blogger
Code tiện ích thống kê bài viết đẹp cho blogger
Admin-8x Date: Thứ năm, 04.May.2017, 4:44 AM | Message # 1
Offline
Avatar
Cấp độ: ₷oáiҪa
Bài viết: 36
Đăng nhập vào blogger sau đó coppy và chèn code sau vào mục thêm tiện ích trong blogger, chỉnh sửa lại các link trong code thành link trang của bạn nhé.




Code
<style scoped="" type="text/css">
#toc-outer {
  color:black;
  font:normal 13px Times New roman,Sans-Serif;
  height:auto;
  margin:0 auto;
  overflow:hidden;
  padding:0;
  text-align:left;
}

#loadingscript {
  padding:0px 0px;
  height:37px;
  text-indent:-9999px;
  color:transparent;
  background:white url('no') no-repeat 50% 50%;
}

.itemposts {
    float: left;
    height: auto;
    overflow: hidden;
    width: 99%;
    box-shadow: 1px 1px 9px #C3C3C3;
    background: none repeat scroll 0% 0% #F9F9F9;
    border: 1px solid #FFF;
    margin: 0px 3px 6px;
    padding: 0px 3px;
}

.itemposts h6 {
    border-bottom: 1px solid #CCC;
    color: #333;
    font: bold 15px Times New roman;
    height: 22px;
    overflow: hidden;
    text-transform: none;
    margin: 6px 0px 2px;
    padding: 0px 2px !important;
}
.itemposts h6 a{color: #1E8504;}
.itemposts h6 a:hover {
  color:#38f;
  text-decoration:none;
}

.itemposts img {
  background-color:#D8FDD7;
  border:1px solid #18A704;
  -moz-border-radius:3px;
  -webkit-border-radius:3px;
  border-radius:3px;
  float:left;
  height:80px;
  margin:0 7px 5px 0;
  padding:3px;
  width:90px;
  z-indent:99999px;
}

.itemposts .iteminside {}

.itemposts .itemfoot {
    border-top: 1px solid #CCC;
    clear: both;
    overflow: hidden;
    padding: 4px 5px;
}

.itemposts .itemfoot a.itemrmore {
  color:#58AA00;
  float:right;
  font-weight:bold;
  text-decoration:none;
}

.itemposts .itemfoot a.itemrmore:hover {text-decoration:underline}

#itempager {
  clear:both;
  padding:10px 0;
}

#pagination,

#totalposts {
  color:#6600D5;
  display:block;
  font:bold 10px Times New roman,Arial,Sans-Serif;
  margin-bottom:10px;
  text-align:center;
  padding:0;
}

#pagination span, #pagination a {
    color: #15BB0E;
    display: inline;
    margin: 0px 1px;
    padding: 0px 5px;
    text-indent: 0px;
    background-color: #FFD6A3;
    background-image: linear-gradient(#E9E9E9 10%, #E9E9E9 25%, #F5F4F3 50;
    border: 1px solid #76DA0B;
    text-decoration: none;
    border-radius: 5px;
}
#pagination a:hover {background-color:#333}

#pagination span.actual {background-color:black}

#pagination span.hidden {display:none}
</style>
<script>
var showPostDate   = true,
    showComments   = true,
    idMode         = true,
    sortByLabel    = false,
    labelSorter    = "Blogspot-tips",
    loadingText    = "Loading...",
    totalPostLabel = "Tổng số bài viết:",
    jumpPageLabel  = "page",
    commentsLabel  = "comment",
    rmoreText      = "Chi tiết►",
    prevText       = "previous",
    nextText       = "next",
    siteUrl        = "http://8x-pro.blogspot.com/",
    postPerPage   = 5,
    numChars       = 350,
    imgBlank       = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAAA3NCSVQICAjb4U/gAAAADElEQVQImWOor68HAAL+AX7vOF2TAAAAAElFTkSuQmCC";
</script>
<script type='text/javascript'>
var minpage=6;var maxpage=10;var firstpage=0;var pagernum=0;var postsnum=0;var actualpage=1;document.write('<div id="toc-outer"><div id="results"></div><div id="itempager" style="position:relative;"><div id="pagination"></div><div id="totalposts"></div><a title="Taufik Nurrohman" style="display:block!important;visibility:visible!important;opacity:1!important;position:absolute;bottom:10px;right:14px;font:normal bold 8px Arial,Sans-Serif!important;color:#666;text-shadow:0 1px 0 rgba(255,255,255,.1);text-decoration:none;" href="http://www.mybloggertricks.org" target="_blank"></a></div></div>');var _results=document.getElementById('results');var _pagination=document.getElementById('pagination');var _totalposts=document.getElementById('totalposts');function showPagePosts(json){var entry,posttitle,posturl,postimg,postsumm,replies,monthnames,timepub,output="";if(pagernum===0){postsnum=parseInt(json.feed.openSearch$totalResults.$t);pagernum=parseInt(postsnum/postPerPage)+ 1;}
for(var i=0;i<postPerPage;i++){if("entry"in json.feed){if(i==json.feed.entry.length)break;entry=json.feed.entry[i];posttitle=entry.title.$t;for(var k=0,elen=entry.link.length;k<elen;k++){if(entry.link[k].rel=="alternate"){posturl=entry.link[k].href;break;}}
for(var l=0,clen=entry.link.length;l<clen;l++){if(entry.link[l].rel=="replies"&&entry.link[l].type=="text/html"){var commentsnum=entry.link[l].title.split(" ")[0];break;}}
postsumm=("summary"in entry)?entry.summary.$t.replace(/<br ?\/?>/ig," ").replace(/<.*?>/g,"").replace(/[<>]/g,""):"";if(postsumm.length>numChars){postsumm=(numChars>0&&numChars!==false)?postsumm.substring(0,numChars)+'...':"";}
var _postdate=entry.published.$t,_cdyear=_postdate.substring(0,4),_cdmonth=_postdate.substring(5,7),_cdday=_postdate.substring(8,10);monthnames=(idMode)?["Jan","Feb","Mar","Apr","Mei","Jun","Jul","Agt","Sep","Okt","Nov","Des"]:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];timepub=(showPostDate)?_cdday+' '+ monthnames[parseInt(_cdmonth,10)- 1]+' '+ _cdyear+' - ':'';replies=(showComments)?commentsnum+' '+ commentsLabel:'';postimg=("media$thumbnail"in entry)?entry.media$thumbnail.url:imgBlank;output+='<div class="itemposts">';output+='<h6><a href="'+ posturl+'" title="'+ posttitle+'">'+ posttitle+'</a></h6>';output+='<div class="iteminside"><a href="'+ posturl+'"><img src="'+ postimg+'" /></a>';output+='<span class="summary">'+ postsumm+'</span></div>';output+='<div style="clear:both;"></div><div class="itemfoot">'+ timepub+ replies+'<a class="itemrmore" href="'+ posturl+'">'+ rmoreText+'</a></div>';output+='</div>';}}
_results.innerHTML=output;_create_pagination();}
function _create_pagination(){output="";var starter=0;output+=((actualpage>1)?'<a title="'+ prevText+'" class="prevjson" href="javascript:_init_script('+(actualpage- 1)+')">'+ prevText+'</a>':'<span class="prevjson hidden">'+ prevText+'</span>')+'<em style="font:inherit;color:inherit;" class="pagernumber">';if(pagernum<(maxpage+ 1)){for(starter=1;starter<=pagernum;starter++){output+=(starter==actualpage)?'<span class="actual">'+ starter+'</span>':'<a href="javascript:_init_script('+ starter+')">'+ starter+'</a>';}}else if(pagernummaxpage- 1)){if(actualpage<minpage){for(starter=1;starter<(maxpage- 2);starter++){output+=(starter==actualpage)?'<span class="actual">'+ starter+'</span>':'<a href="javascript:_init_script('+ starter+')">'+ starter+'</a>';}
output+=' ... ';output+='<a href="javascript:_init_script('+ parseInt(pagernum- 1)+')">'+ parseInt(pagernum- 1)+'</a>';output+='<a href="javascript:_init_script('+ pagernum+')">'+ pagernum+'</a>';}else if(pagernum-(minpage- 1)>actualpage&&actualpageminpage- 1)){output+='<a href="javascript:_init_script(1)">1</a>';output+='<a href="javascript:_init_script(2)">2</a>';output+=' ... ';for(starter=actualpage- 2;starter<=actualpage+ 2;starter++){output+=(starter==actualpage)?'<span class="actual">'+ starter+'</span>':'<a href="javascript:_init_script('+ starter+')">'+ starter+'</a>';}
output+=' ... ';output+='<a href="javascript:_init_script('+(pagernum- 1)+')">'+ parseInt(pagernum- 1)+'</a>';output+='<a href="javascript:_init_script('+ pagernum+')">'+ pagernum+'</a>';}else{output+='<a href="javascript:_init_script(1)">1</a>';output+='<a href="javascript:_init_script(2)">2</a>';output+=' ... ';for(starter=pagernum-(minpage+ 1);starter<=pagernum;starter++){output+=(starter==actualpage)?'<span class="actual">'+ starter+'</span>':'<a href="javascript:_init_script('+ starter+')">'+ starter+'</a>';}}}
output+='</em>'+((actualpage<starter- 1)?'<a title="'+ nextText+'" class="nextjson" href="javascript:_init_script('+(actualpage+ 1)+')">'+ nextText+'</a>':'<span class="nextjson hidden">'+ nextText+'</span>');_pagination.innerHTML=output;_totalposts.innerHTML=totalPostLabel+' '+ postsnum+' - '+ jumpPageLabel+' '+((actualpage*postPerPage)-(postPerPage- 1))+((actualpage<starter- 1)?' - '+(actualpage*postPerPage):"");}
function _init_script(n){var parameter=(n*postPerPage)-(postPerPage- 1),old,s,head=document.getElementsByTagName('head')[0],url=(sortByLabel)?siteUrl+'/feeds/posts/summary/-/'+ labelSorter+'?start-index='+ parameter:siteUrl+'/feeds/posts/summary?start-index='+ parameter;if(firstpage==1){document.documentElement.scrollTop=_results.offsetTop- 30;document.body.scrollTop=_results.offsetTop- 30;old=document.getElementById("TEMPORAL");old.parentNode.removeChild(old);}
_results.innerHTML='<div id="loadingscript">'+ loadingText+'</div>';_pagination.innerHTML='';_totalposts.innerHTML='';s=document.createElement('script');s.type='text/javascript';s.src=url+'&max-results='+ postPerPage+'&orderby=published&alt=json-in-script&callback=showPagePosts';s.id='TEMPORAL';head.appendChild(s);firstpage=1;actualpage=n;}
window.onload=function(){_init_script(1);};
</script>

Thêm code tiện ích bài viết ngẫu nhiên cho blogger

Code
<style>#random-posts img{float:left;margin-right:10px;border:1px solid #999;background:#FFF;width:36px;height:36px;padding:3px}
</style>
<ul id='random-posts'>
<script type='text/javaScript'>
var rdp_numposts=5;
var rdp_snippet_length=150;
var rdp_info='yes';
var rdp_comment='Nhận xét';
var rdp_disable='Tắt Nhận xét';
var rdp_current=[];var rdp_total_posts=0;var rdp_current=new Array(rdp_numposts);function totalposts(json){rdp_total_posts=json.feed.openSearch$totalResults.$t}document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=totalposts\"><\/script>');function getvalue(){for(var i=0;i<rdp_numposts;i++){var found=false;var rndValue=get_random();for(var j=0;j<rdp_current.length;j++){if(rdp_current[j]==rndValue){found=true;break}};if(found){i--}else{rdp_current[i]=rndValue}}};function get_random(){var ranNum=1+Math.round(Math.random()*(rdp_total_posts-1));return ranNum};
</script>
<script type='text/javaScript'>
function random_posts(json){a=location.href;y=a.indexOf('?m=0');for(var i=0;i<rdp_numposts;i++){var entry=json.feed.entry[i];var rdp_posttitle=entry.title.$t;if('content'in entry){var rdp_get_snippet=entry.content.$t}else{if('summary'in entry){var rdp_get_snippet=entry.summary.$t}else{var rdp_get_snippet="";}};rdp_get_snippet=rdp_get_snippet.replace(/<[^>]*>/g,"");if(rdp_get_snippet.length<rdp_snippet_length){var rdp_snippet=rdp_get_snippet}else{rdp_get_snippet=rdp_get_snippet.substring(0,rdp_snippet_length);var space=rdp_get_snippet.lastIndexOf(" ");rdp_snippet=rdp_get_snippet.substring(0,space)+"…";};for(var j=0;j<entry.link.length;j++){if('thr$total'in entry){var rdp_commentsNum=entry.thr$total.$t+' '+rdp_comment}else{rdp_commentsNum=rdp_disable};if(entry.link[j].rel=='alternate'){var rdp_posturl=entry.link[j].href;if(y!=-1){rdp_posturl=rdp_posturl+'?m=0'}var rdp_postdate=entry.published.$t;if('media$thumbnail'in entry){var rdp_thumb=entry.media$thumbnail.url}else{rdp_thumb="http://lh3.ggpht.com/--Z8SVBQZ4X8/TdDxPVMl_sI/AAAAAAAAAAA/jhAgjCpZtRQ/no-image.png"}}};document.write('<li>');document.write('<img alt="'+rdp_posttitle+'" src="'+rdp_thumb+'"/>');document.write('<div><a href="'+rdp_posturl+'" rel="nofollow" title="'+rdp_snippet+'">'+rdp_posttitle+'</a></div>');if(rdp_info=='yes'){document.write('<span>'+rdp_postdate.substring(8,10)+'/'+rdp_postdate.substring(5,7)+'/'+rdp_postdate.substring(0,4)+' - '+rdp_commentsNum)+'</span>'}document.write('<div style="clear:both"></div></li>')}};getvalue();for(var i=0;i<rdp_numposts;i++){document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index='+rdp_current[i]+'&max-results=1&callback=random_posts\"><\/script>')};
</script>
</ul>

Chúc bạn thành công
Files đính kèm: 1587521.jpg(79.3 Kb)


Sống với niềm tin và đam mê sẽ sớm có được thành công,
Không hoang tưởng cũng không kiêu ngạo, thành công sẽ vững bền.
 
Forum » Giao lưu chia sẻ kinh nghiệm về website » Tổng hợp code và javascript » Code tiện ích thống kê bài viết đẹp cho blogger
  • Page 1 of 1
  • 1
Search: