Нумерованная постраничная навигация Блогспот, Blogger


Пост (в основном) для пользователей:
Blogger, Блоггер (Blogspot, Блогспот)

Постепенно выполняю заявки читателей. Речь сегодня пойдет о нумерованной постраничной навигации для Блогспот, Blogger.
Вот так она выглядит


Признаюсь честно, было нелегко оформить код одним блоком, что бы без "ковыряний" в шаблоне и других "телодвижений" можно было внедрить виджет одним действием. Однако получилось и теперь вы можете в  Дизайн - Добавить гаджет - HTML/JavaScript, добавить следующий код:

<style>.showpageArea a {
text-decoration:underline;
}
.showpageNum a {
border:1px solid #CCCCCC;
margin:0 3px;
padding:3px 7px;
text-decoration:none;
}
.showpageNum a:hover {
background-color:#CCCCCC;
border:1px solid #CCCCCC;
}
.showpagePoint {
-moz-background-clip:border;
-moz-background-inline-policy:continuous;
-moz-background-origin:padding;
background:#CCCCCC none repeat scroll 0 0;
border:1px solid #CCCCCC;
color:#333333;
margin:0 3px;
padding:3px 7px;
text-decoration:none;
}
.showpageOf {
margin:0 3px 0 0;
padding:3px 7px;
text-decoration:none;
}
.showpage a {
border:1px solid #CCCCCC;
padding:3px 7px;
text-decoration:none;
}
.showpage a:hover {
text-decoration:none;
}
.showpageNum a:link, .showpage a:link {
color:#333333;
text-decoration:none;
}</style><script type='text/javascript'>
var home_page_url = location.href;
var pageCount=2;
var displayPageNum=3;
var upPageWord ='Назад';
var downPageWord ='Вперёд';
function showpageCount(json) {
var thisUrl = home_page_url;
var htmlMap = new Array();
var thisNum = 1;
var postNum=1;
var itemCount = 0;
var fFlag = 0;
var eFlag = 0;
var html= '';
var upPageHtml ='';
var downPageHtml ='';
for(var i=0, post; post = json.feed.entry[i]; i++) {
var timestamp1 = post.published.$t.substring(0,19)+post.published.$t.substring(23,29);
timestamp = encodeURIComponent(timestamp1);
var title = post.title.$t;
if(title!=''){
if(itemCount==0 || (itemCount % pageCount ==(pageCount-1))){
if(thisUrl.indexOf(timestamp)!=-1 ){
  thisNum = postNum;
}


if(title!='') postNum++;
htmlMap[htmlMap.length] = '/search?updated-max='+timestamp+'&max-results='+pageCount;
}
}
itemCount++;


}


for(var p =0;p< htmlMap.length;p++){
if(p>=(thisNum-displayPageNum-1) && p<(thisNum+displayPageNum)){
if(fFlag ==0 && p == thisNum-2){
if(thisNum==2){
 upPageHtml = '<span class="showpage"><a href="/">'+ upPageWord +'</a></span>';
}else{
 upPageHtml = '<span class="showpage"><a href="'+htmlMap[p]+'">'+ upPageWord +'</a></span>';
}


fFlag++;
}


if(p==(thisNum-1)){
html += '<span class="showpagePoint">'+thisNum+'</span>';
}else{
if(p==0){
  html += '<span class="showpageNum"><a href="/">1</a></span>';


}else{
 html += '<span class="showpageNum"><a href="'+htmlMap[p]+'">'+ (p+1) +'</a></span>';
}
}


if(eFlag ==0 && p == thisNum){
downPageHtml = '<span class="showpage"> <a href="'+htmlMap[p]+'">'+ downPageWord +'</a></span>';
eFlag++;
}
}
}


if(thisNum>1){
html = ''+upPageHtml+' '+html +' ';
}


html = '<div class="showpageArea"><span  class="showpageOf"> Страниц ('+(postNum-1)+')</span>'+html;


if(thisNum<(postNum-1)){
html += downPageHtml;
}


if(postNum==1) postNum++;
html += '</div>';


var pageArea = document.getElementsByName("pageArea");
var blogPager = document.getElementById("blog-pager");


if(postNum <= 2){
html ='';
}


for(var p =0;p< pageArea.length;p++){
pageArea[p].innerHTML = html;
}


if(pageArea&&pageArea.length>0){
html ='';
}


if(blogPager){
blogPager.innerHTML = html;
}


}


function showpageCount2(json) {


var thisUrl = home_page_url;
var htmlMap = new Array();
var isLablePage = thisUrl.indexOf("/search/label/")!=-1;
var thisLable = isLablePage ? thisUrl.substr(thisUrl.indexOf("/search/label/")+14,thisUrl.length) : "";
thisLable = thisLable.indexOf("?")!=-1 ? thisLable.substr(0,thisLable.indexOf("?")) : thisLable;
var thisNum = 1;
var postNum=1;
var itemCount = 0;
var fFlag = 0;
var eFlag = 0;
var html= '';
var upPageHtml ='';
var downPageHtml ='';


var labelHtml = '<span class="showpageNum"><a href="/search/label/'+thisLable+'?&max-results='+pageCount+'">';
var thisUrl = home_page_url;


for(var i=0, post; post = json.feed.entry[i]; i++) {


var timestamp1 = post.published.$t.substring(0,19)+post.published.$t.substring(23,29);
timestamp = encodeURIComponent(timestamp1);


var title = post.title.$t;


if(title!=''){
if(itemCount==0 || (itemCount % pageCount ==(pageCount-1))){
if(thisUrl.indexOf(timestamp)!=-1 ){
 thisNum = postNum;
}


if(title!='') postNum++;
htmlMap[htmlMap.length] = '/search/label/'+thisLable+'?updated-max='+timestamp+'&max-results='+pageCount;


}
}
itemCount++;
}


for(var p =0;p< htmlMap.length;p++){
if(p>=(thisNum-displayPageNum-1) && p<(thisNum+displayPageNum)){
if(fFlag ==0 && p == thisNum-2){
if(thisNum==2){
 upPageHtml = labelHtml + upPageWord +'</a></span>';
}else{
 upPageHtml = '<span class="showpage"><a href="'+htmlMap[p]+'">'+ upPageWord +'</a></span>';
}


fFlag++;
}


if(p==(thisNum-1)){
html += '<span class="showpagePoint">'+thisNum+'</span>';
}else{
if(p==0){
 html = labelHtml+'1</a></span>';
}else{
 html += '<span class="showpageNum"><a href="'+htmlMap[p]+'">'+ (p+1) +'</a></span>';
}
}


if(eFlag ==0 && p == thisNum){
downPageHtml = '<span class="showpage"> <a href="'+htmlMap[p]+'">'+ downPageWord +'</a></span>';
eFlag++;
}
}
}


if(thisNum>1){
if(!isLablePage){
html = ''+upPageHtml+' '+html +' ';
}else{
html = ''+upPageHtml+' '+html +' ';
}
}


html = '<div class="showpageArea"><span  class="showpageOf"> Pages ('+(postNum-1)+')</span>'+html;


if(thisNum<(postNum-1)){
html += downPageHtml;
}


if(postNum==1) postNum++;
html += '</div>';


var pageArea = document.getElementsByName("pageArea");
var blogPager = document.getElementById("blog-pager");


if(postNum <= 2){
html ='';
}


for(var p =0;p< pageArea.length;p++){
pageArea[p].innerHTML = html;
}


if(pageArea&&pageArea.length>0){
html ='';
}


if(blogPager){
blogPager.innerHTML = html;
}


}


</script>
<script type='text/javascript'>


var thisUrl = home_page_url;
if (thisUrl.indexOf("/search/label/")!=-1){
if (thisUrl.indexOf("?updated-max")!=-1){
var lblname1 = thisUrl.substring(thisUrl.indexOf("/search/label/")+14,thisUrl.indexOf("?updated-max"));
}else{
var lblname1 = thisUrl.substring(thisUrl.indexOf("/search/label/")+14,thisUrl.indexOf("?&max"));
}
}


var home_page = "/";
if (thisUrl.indexOf("?q=")==-1){
if (thisUrl.indexOf("/search/label/")==-1){
document.write('<script src="'+home_page+'feeds/posts/summary?alt=json-in-script&callback=showpageCount&max-results=99999" ><\/script>')
}else{document.write('<script src="'+home_page+'feeds/posts/full/-/'+lblname1+'?alt=json-in-script&callback=showpageCount2&max-results=99999" ><\/script>')
}
}
</script>


Можно изменить следующие параметры:
var displayPageNum=2 - количество страниц, которые будут показаны на виджете.
var pageCount=4- количество сообщений на одной странице.

Еще один вариант постраничной навигации (как на этом блоге)

<style type="text/css">a.showpageNum { background:transparent url('http://i1133.photobucket.com/albums/m596/abu-farhan/gbtn-bg.png') repeat-x;
  border:1px solid #97a7af;
  margin:0px 1px 0 1px;padding:3px 8px;
  text-decoration:none;
  color:#333;line-height:14px;cursor:pointer;white-space:nowrap;
  -webkit-border-radius:3px;-moz-border-radius:3px;
}
a.showpageNum:hover {
  border: 1px solid #cccccc;
  background: #f6edd9;
}
.showpagePoint {
  color: #fff;
  text-shadow: 0 1px 2px #333;
  padding: 0px 5px;
  margin: 0px 2px;
  border: 1px solid #cccccc;
  background: #666;
}
.showpageOf {
  margin-right: 8px;
  text-shadow: 1px 1px 1px #fff;
}</style>
<script style='text/javascript'>
var postperpage=10;
var numshowpage=3;
var upPageWord="◄ Назад";
var downPageWord="Вперед ►";
var home_page="/";
var urlactivepage=location.href;
</script><script type='text/javascript'>
var home_page=&quot;/&quot;;
var urlactivepage=location.href;
var upPageWord ='◄';
var downPageWord ='►';
</script>
<script type="text/javascript">
//<![CDATA[
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('4 H;4 l;4 k;4 r;15();D 16(a){4 b=\'\';I=J(M/2);3(I==M-I){M=I*2+1}B=k-I;3(B<1)B=1;h=J(a/m)+1;3(h-1==a/m)h=h-1;E=B+M-1;3(E>h)E=h;b+="<N 5=\'1o\'>Страница "+k+\' из \'+h+"</N>";4 c=J(k)-1;3(k>1){3(k==2){3(l=="s"){b+=\'<a 6="\'+C+\'" 5="i">\'+O+\'</a>\'}7{b+=\'<a 6="/u/v/\'+r+\'?&9-n=\'+m+\'" 5="i">\'+O+\'</a>\'}}7{3(l=="s"){b+=\'<a 6="#" x="K(\'+c+\');y z" 5="i">\'+O+\'</a>\'}7{b+=\'<a 6="#" x="L(\'+c+\');y z" 5="i">\'+O+\'</a>\'}}}3(B>1){3(l=="s"){b+=\'<a 6="\'+C+\'" 5="i">1</a>\'}7{b+=\'<a 6="/u/v/\'+r+\'?&9-n=\'+m+\'" 5="i">1</a>\'}}3(B>2){b+=\' ... \'}17(4 d=B;d<=E;d++){3(k==d){b+=\'<N 5="1p">\'+d+\'</N>\'}7 3(d==1){3(l=="s"){b+=\'<a 6="\'+C+\'" 5="i">1</a>\'}7{b+=\'<a 6="/u/v/\'+r+\'?&9-n=\'+m+\'" 5="i">1</a>\'}}7{3(l=="s"){b+=\'<a 6="#" x="K(\'+d+\');y z" 5="i">\'+d+\'</a>\'}7{b+=\'<a 6="#" x="L(\'+d+\');y z" 5="i">\'+d+\'</a>\'}}}3(E<h-1){b+=\'...\'}3(E<h){3(l=="s"){b+=\'<a 6="#" x="K(\'+h+\');y z" 5="i">\'+h+\'</a>\'}7{b+=\'<a 6="#" x="L(\'+h+\');y z" 5="i">\'+h+\'</a>\'}}4 e=J(k)+1;3(k<h){3(l=="s"){b+=\'<a 6="#" x="K(\'+e+\');y z" 5="i">\'+18+\'</a>\'}7{b+=\'<a 6="#" x="L(\'+e+\');y z" 5="i">\'+18+\'</a>\'}}b+=\'\';4 f=A.1q("1r");4 g=A.1s("1t-1u");17(4 p=0;p<f.P;p++){f[p].1a=b}3(f&&f.P>0){b=\'\'}3(g){g.1a=b}}D 11(a){4 b=a.1b;4 c=J(b.1v$1w.$t,10);16(c)}D 15(){4 a=w;3(a.j("/u/v/")!=-1){3(a.j("?Q-9")!=-1){r=a.F(a.j("/u/v/")+14,a.j("?Q-9"))}7{r=a.F(a.j("/u/v/")+14,a.j("?&9"))}}3(a.j("?q=")==-1&&a.j(".1x")==-1){3(a.j("/u/v/")==-1){l="s";3(w.j("#G=")!=-1){k=w.F(w.j("#G=")+8,w.P)}7{k=1}A.1c("<o R=\\""+C+"S/T/U?9-n=1&V=W-X-o&Y=11\\"><\\/o>")}7{l="v";3(a.j("&9-n=")==-1){m=1y}3(w.j("#G=")!=-1){k=w.F(w.j("#G=")+8,w.P)}7{k=1}A.1c(\'<o R="\'+C+\'S/T/U/-/\'+r+\'?V=W-X-o&Y=11&9-n=1" ><\\/o>\')}}}D K(a){Z=(a-1)*m;H=a;4 b=A.1d(\'1e\')[0];4 c=A.1f(\'o\');c.1g=\'1h/1i\';c.1j("R",C+"S/T/U?1k-1l="+Z+"&9-n=1&V=W-X-o&Y=12");b.1m(c)}D L(a){Z=(a-1)*m;H=a;4 b=A.1d(\'1e\')[0];4 c=A.1f(\'o\');c.1g=\'1h/1i\';c.1j("R",C+"S/T/U/-/"+r+"?1k-1l="+Z+"&9-n=1&V=W-X-o&Y=12");b.1m(c)}D 12(a){13=a.1b.1z[0];4 b=13.1n.$t.F(0,19)+13.1n.$t.F(1A,1B);4 c=1C(b);3(l=="s"){4 d="/u?Q-9="+c+"&9-n="+m+"#G="+H}7{4 d="/u/v/"+r+"?Q-9="+c+"&9-n="+m+"#G="+H}1D.6=d}',62,102,'|||if|var|class|href|else||max||||||||maksimal|showpageNum|indexOf|nomerhal|jenis|postperpage|results|script|||lblname1|page||search|label|urlactivepage|onclick|return|false|document|mulai|home_page|function|akhir|substring|PageNo|nopage|nomerkiri|parseInt|redirectpage|redirectlabel|numshowpage|span|upPageWord|length|updated|src|feeds|posts|summary|alt|json|in|callback|jsonstart||hitungtotaldata|finddatepost|post||halamanblogger|loophalaman|for|downPageWord||innerHTML|feed|write|getElementsByTagName|head|createElement|type|text|javascript|setAttribute|start|index|appendChild|published|showpageOf|showpagePoint|getElementsByName|pageArea|getElementById|blog|pager|openSearch|totalResults|html|20|entry|23|29|encodeURIComponent|location'.split('|'),0,{}))
//]]>
</script>


По заявкам читателей, постраничная навигация без слов.

<style type="text/css">a.showpageNum { background:transparent url('http://i1133.photobucket.com/albums/m596/abu-farhan/gbtn-bg.png') repeat-x;
  border:1px solid #97a7af;
  margin:0px 1px 0 1px;padding:3px 8px;
  text-decoration:none;
  color:#333;line-height:14px;cursor:pointer;white-space:nowrap;
  -webkit-border-radius:3px;-moz-border-radius:3px;
}
a.showpageNum:hover {
  border: 1px solid #cccccc;
  background: #f6edd9;
}
.showpagePoint {
  color: #fff;
  text-shadow: 0 1px 2px #333;
  padding: 0px 5px;
  margin: 0px 2px;
  border: 1px solid #cccccc;
  background: #666;
}
.showpageOf {
  margin-right: 8px;
  text-shadow: 1px 1px 1px #fff;
}</style>
<script style='text/javascript'>
var postperpage=10;
var numshowpage=3;
var upPageWord="◄ ";
var downPageWord=" ►";
var home_page="/";
var urlactivepage=location.href;
</script><script type='text/javascript'>
var home_page=&quot;/&quot;;
var urlactivepage=location.href;
var upPageWord ='◄';
var downPageWord ='►';
</script>
<script type="text/javascript">
//<![CDATA[
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('4 H;4 l;4 k;4 r;15();D 16(a){4 b=\'\';I=J(M/2);3(I==M-I){M=I*2+1}B=k-I;3(B<1)B=1;h=J(a/m)+1;3(h-1==a/m)h=h-1;E=B+M-1;3(E>h)E=h;b+="<N 5=\'1o\'></N>";4 c=J(k)-1;3(k>1){3(k==2){3(l=="s"){b+=\'<a 6="\'+C+\'" 5="i">\'+O+\'</a>\'}7{b+=\'<a 6="/u/v/\'+r+\'?&9-n=\'+m+\'" 5="i">\'+O+\'</a>\'}}7{3(l=="s"){b+=\'<a 6="#" x="K(\'+c+\');y z" 5="i">\'+O+\'</a>\'}7{b+=\'<a 6="#" x="L(\'+c+\');y z" 5="i">\'+O+\'</a>\'}}}3(B>1){3(l=="s"){b+=\'<a 6="\'+C+\'" 5="i">1</a>\'}7{b+=\'<a 6="/u/v/\'+r+\'?&9-n=\'+m+\'" 5="i">1</a>\'}}3(B>2){b+=\' ... \'}17(4 d=B;d<=E;d++){3(k==d){b+=\'<N 5="1p">\'+d+\'</N>\'}7 3(d==1){3(l=="s"){b+=\'<a 6="\'+C+\'" 5="i">1</a>\'}7{b+=\'<a 6="/u/v/\'+r+\'?&9-n=\'+m+\'" 5="i">1</a>\'}}7{3(l=="s"){b+=\'<a 6="#" x="K(\'+d+\');y z" 5="i">\'+d+\'</a>\'}7{b+=\'<a 6="#" x="L(\'+d+\');y z" 5="i">\'+d+\'</a>\'}}}3(E<h-1){b+=\'...\'}3(E<h){3(l=="s"){b+=\'<a 6="#" x="K(\'+h+\');y z" 5="i">\'+h+\'</a>\'}7{b+=\'<a 6="#" x="L(\'+h+\');y z" 5="i">\'+h+\'</a>\'}}4 e=J(k)+1;3(k<h){3(l=="s"){b+=\'<a 6="#" x="K(\'+e+\');y z" 5="i">\'+18+\'</a>\'}7{b+=\'<a 6="#" x="L(\'+e+\');y z" 5="i">\'+18+\'</a>\'}}b+=\'\';4 f=A.1q("1r");4 g=A.1s("1t-1u");17(4 p=0;p<f.P;p++){f[p].1a=b}3(f&&f.P>0){b=\'\'}3(g){g.1a=b}}D 11(a){4 b=a.1b;4 c=J(b.1v$1w.$t,10);16(c)}D 15(){4 a=w;3(a.j("/u/v/")!=-1){3(a.j("?Q-9")!=-1){r=a.F(a.j("/u/v/")+14,a.j("?Q-9"))}7{r=a.F(a.j("/u/v/")+14,a.j("?&9"))}}3(a.j("?q=")==-1&&a.j(".1x")==-1){3(a.j("/u/v/")==-1){l="s";3(w.j("#G=")!=-1){k=w.F(w.j("#G=")+8,w.P)}7{k=1}A.1c("<o R=\\""+C+"S/T/U?9-n=1&V=W-X-o&Y=11\\"><\\/o>")}7{l="v";3(a.j("&9-n=")==-1){m=1y}3(w.j("#G=")!=-1){k=w.F(w.j("#G=")+8,w.P)}7{k=1}A.1c(\'<o R="\'+C+\'S/T/U/-/\'+r+\'?V=W-X-o&Y=11&9-n=1" ><\\/o>\')}}}D K(a){Z=(a-1)*m;H=a;4 b=A.1d(\'1e\')[0];4 c=A.1f(\'o\');c.1g=\'1h/1i\';c.1j("R",C+"S/T/U?1k-1l="+Z+"&9-n=1&V=W-X-o&Y=12");b.1m(c)}D L(a){Z=(a-1)*m;H=a;4 b=A.1d(\'1e\')[0];4 c=A.1f(\'o\');c.1g=\'1h/1i\';c.1j("R",C+"S/T/U/-/"+r+"?1k-1l="+Z+"&9-n=1&V=W-X-o&Y=12");b.1m(c)}D 12(a){13=a.1b.1z[0];4 b=13.1n.$t.F(0,19)+13.1n.$t.F(1A,1B);4 c=1C(b);3(l=="s"){4 d="/u?Q-9="+c+"&9-n="+m+"#G="+H}7{4 d="/u/v/"+r+"?Q-9="+c+"&9-n="+m+"#G="+H}1D.6=d}',62,102,'|||if|var|class|href|else||max||||||||maksimal|showpageNum|indexOf|nomerhal|jenis|postperpage|results|script|||lblname1|page||search|label|urlactivepage|onclick|return|false|document|mulai|home_page|function|akhir|substring|PageNo|nopage|nomerkiri|parseInt|redirectpage|redirectlabel|numshowpage|span|upPageWord|length|updated|src|feeds|posts|summary|alt|json|in|callback|jsonstart||hitungtotaldata|finddatepost|post||halamanblogger|loophalaman|for|downPageWord||innerHTML|feed|write|getElementsByTagName|head|createElement|type|text|javascript|setAttribute|start|index|appendChild|published|showpageOf|showpagePoint|getElementsByName|pageArea|getElementById|blog|pager|openSearch|totalResults|html|20|entry|23|29|encodeURIComponent|location'.split('|'),0,{}))
//]]>
</script>

Доска почета

Плюсани блог!