diff options
author | Arun Persaud <arun@nubati.net> | 2011-11-26 22:10:38 -0800 |
---|---|---|
committer | Arun Persaud <apersaud@lbl.gov> | 2011-11-26 22:11:13 -0800 |
commit | 197867206e97f0b8d85cff0ef7f1bf88a33fd7aa (patch) | |
tree | 68f764d5b604848afbb55ede501c6327451934fc | |
parent | fe9797bd60e0027fac4bb989619eec1e428aabd0 (diff) | |
download | photo-tags-197867206e97f0b8d85cff0ef7f1bf88a33fd7aa.tar.gz photo-tags-197867206e97f0b8d85cff0ef7f1bf88a33fd7aa.tar.bz2 photo-tags-197867206e97f0b8d85cff0ef7f1bf88a33fd7aa.zip |
updated showing of page index
* only show page +-5 pages + first and last
* don't make current page a link
-rw-r--r-- | index.php | 42 |
1 files changed, 38 insertions, 4 deletions
@@ -83,16 +83,50 @@ function myreload(a) { d3.json(url, function(json) { - /* update index */ + /* update index, show only page +-5 pages max */ s="page "; - n = json[0][0].total/N; - for(i=1;i<=n+1;i++) + n = Math.floor(json[0][0].total/N); + + if(a>7) { s+=" <a href=\"<?php echo $webbase?>"; if(T!="") s+="/tag/"+T; - s+="/page/"+i+"\">"+i+"</a>"; + s+="/page/1\">1</a>..."; + start = a-5; + } + else + start=1; + + for(i=start;i<=Math.min(n+1,a+5);i++) + { + if(i==a) + s+= " "+i+" "; + else + { + s+=" <a href=\"<?php echo $webbase?>"; + if(T!="") + s+="/tag/"+T; + s+="/page/"+i+"\">"+i+"</a>"; + } } + + if(a+5<n) + { + s+="... <a href=\"<?php echo $webbase?>"; + if(T!="") + s+="/tag/"+T; + s+="/page/"+(n+1)+"\">"+(n+1)+"</a>"; + } + else if(a+5==n) + { + s+=" <a href=\"<?php echo $webbase?>"; + if(T!="") + s+="/tag/"+T; + s+="/page/"+(n+1)+"\">"+(n+1)+"</a>"; + }; + + d3.select(".index").html(s); /* update pics */ |