var pics = d3.select(".pics").select("ul");
+var page;
+var maxpage;
function init()
{
d3.select('form').attr("action",webbase+"/tag/"+document.getElementById('MyTagsInput').value.replace(" ","+"));
});
+ d3.select("#currenttags").select("a").remove();
if (T!="")
{
var mycurrenttags = T.split(",");
- d3.select("#currenttags").select("button").remove();
- d3.select("#currenttags").selectAll("button")
+ d3.select("#currenttags").selectAll("a")
.data(mycurrenttags).enter()
- .append("button").attr("type","button").text( function(d) {return d;} );
- }
- else
- {
- d3.select("#currenttags").select("button").remove();
- d3.select("#currenttags").append("span").text( ' none');
+ .append("a").attr("class","btn btn-small").text( function(d) {return d;} )
+ .on("mouseover", function(d){ d3.select(this).classed("btn-danger",true)})
+ .on("mouseout", function(d){ d3.select(this).classed("btn-danger",false)})
+ .attr("href", function(d) { return removeTag(T.split(","),d) });
};
}
+function removeTag(alltags,removetag)
+{
+ /* return a link to a page with 'removetag' removed from the array of tags*/
+ var index = alltags.indexOf(removetag);
+ alltags.splice(index, 1);
+ if (alltags.length)
+ return webbase+'/tag/'+alltags.join(",");
+ else
+ return webbase;
+}
+
+
function load_content() {
- // d3.select(".debug").text("T,P,N = *"+T+"* *"+page+"* *"+N+"*");
+ // d3.select(".debug").text("T,P,N = *"+T+"* *"+page+"* *"+N+"*");
if (ID>=0)
url = webbase+"/getjson.php?ID="+ID;
if (ID>=0)
{
var singlepicspace=pics.selectAll("li").data(picdata, function(d){return ID;}).enter().append("li").append("div").attr("class","singlepic");
- singlepicspace.append("div").attr("class","left").append("img").attr("src",webbase+"/icons/left.png");
+ singlepicspace.append("img").attr("class","left").attr("src",webbase+"/icons/left.png");
singlepicspace.append("img")
.attr("class","large")
.attr("src",function(d) {
s = s.replace('file:\/\/'+dbprefix,webbase+'/Photos-small/');
return s;
});
- singlepicspace.append("div").attr("class","right").append("img").attr("src",webbase+"/icons/right.png");
+ singlepicspace.append("img").attr("class","right").attr("src",webbase+"/icons/right.png");
update_thumbnails();
}
return s;
});
};
+ checkbutton();
+ update_permalink()
});
- checkbutton();
- update_permalink()
}
function update_permalink() {
}
function prev_page() {
- if (page>=2) page=page-1;
- load_content();
+ if (page>1) page=page-1;
+ load_content();
+ update_page_index();
}
function next_page() {
- page=page+1;
- load_content();
+ if (page<maxpage) page=page+1;
+ load_content();
+ update_page_index();
}
function prev_pic() {
/* update pics */
d3.json(url, function(json) {
svgelement.selectAll("text").data(json).enter().append("text")
- .style("font-size", function(d){return (Math.log(d.count+1)/2.0)+"em"})
+ .style("font-size", function(d){return (Math.log(d.count+1)/3.0+0.5)+"em"})
.text(function(d) { return d.name+" "; })
.on("mouseover", function(d){ d3.select(this).style("color","red")} )
- .on("mouseout", function(d){ d3.select(this).style("color","white")} )
+ .on("mouseout", function(d){ d3.select(this).style("color","black")} )
.on("click", function(d) { document.location.href=webbase+'/tag/'+d.name })
});
}
var thumbs= d3.select(".nextprev").select("ul").selectAll("li").data(json2, function(d) {return d.id;});
+ thumbs.exit().select("img").transition().duration(1000).style("height","0px").transition().duration(1050).remove();
+ thumbs.exit().transition().duration(1050).remove();
thumbs.enter().append("li")
.append("a")
.on("click", function(d) {
s = s.replace('file:\/\/'+dbprefix,webbase+'/Photos-tiny/');
return s;
})
- .style("height","0")
- .transition().duration(1000)
+ .style("height","0px")
+ .transition().duration(500)
.style("height","100px");
- thumbs.exit().select("img").transition().duration(1000).style("height","0");
- thumbs.exit().transition().duration(1050).remove();
-
/* resort elements */
d3.select(".nextprev").select("ul").selectAll("li").sort(function(a,b){return a.id-b.id;});
- d3.select(".nextprev").select("ul").selectAll("li").select("a").select("img").classed("current",false);
d3.select(".nextprev").select("ul").selectAll("li").select("a").select("img").classed("current",function(d){return (d.id==IDcurr);});
else
{ d3.select(".pagination ul li:first-child").classed("disabled", false);};
- if (count<N)
+ if (page==maxpage)
{ d3.select(".pagination ul li:last-child").classed("disabled", true);}
else
- { d3.select(".pagination ul li:last-child").classed("disabled", false);}
+ { d3.select(".pagination ul li:last-child").classed("disabled", false);};
}
function update_page_index()
n = Math.floor( json[0].total/N ); /* how many pages */
nr = Math.floor( (json[0].row-1)/N ); /* which row are we in? rowid starts at 1 not 0 */
+ maxpage=n+1;
+
if(nr > 0) page = nr+1;
var mydata = new Array(); // add json data {page: <nr>, name: <name>} ; at end reform array into real json and use d3 to parse it
if(n>0)
{
mydata.push('{ page:0.1, name:"Prev"}');
- if(page>7)
+ if(page>4)
{
mydata.push('{ page:1, name:"1"}');
mydata.push('{ page:1.5, name:"..."}');
mydata.push('{ page:'+(n+1)+', name:"'+(n+1)+'"}');
mydata.push('{ page:'+(n+2.1)+', name:"Next"}');
- };
+ }
+ else
+ {
+ mydata.push('{ page:0.1, name:"Prev"}');
+ mydata.push('{ page:1.1, name:"Next"}');
+ }
+
mydata = "["+mydata.join(",")+"]";
mydata = eval('(' + mydata + ')');
d3.select(".pagination").select("ul").selectAll("li").classed("active", false);
d3.select(".pagination").select("ul").selectAll("li").classed("active", function(d) {return ( d.page == page ); });
+ checkbutton();
} );
+
}