+ /**
+ copyright 2012,2013 Arun Persaud <arun@nubati.net>
+
+ This file is part of photo-tags.
+
+ Photo-tags is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Photo-tags is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Photo-tags. If not, see <http://www.gnu.org/licenses/>.
+
+ **/
+
var pics = d3.select(".pics").select("ul");
var page;
var maxpage;
.text(function(d) {
var date = new Date(d.time*1000);
if (d.description=="")
- return "Time: "+date.toUTCString();
+ return " "+date.toUTCString();
else
- return "Description: "+d.description + "Time: "+date.toUTCString();
+ return " "+d.description + " "+date.toUTCString();
});
/* show tags */
- tags="";
d3.json(webbase+"/getjson.php?IDT="+ID, function(jsontag) {
- singlepicspace.append("p").selectAll("span").data(jsontag)
+ tags=0;
+ d3.select("#pictags").selectAll("span").remove();
+ d3.select("#pictags").selectAll("span").data(jsontag)
.enter().append("span")
.attr("class","btn btn-small")
.text( function(t) {
+ tags=1;
return t.name;
})
- .on("mouseover", function(d){ d3.select(this).classed("btn-danger",true)})
- .on("mouseout", function(d){ d3.select(this).classed("btn-danger",false)})
- .on("click", function(d) { document.location.href=webbase+'/tag/'+d.name});
+ .on("mouseover", function(d){ d3.select(this).classed("btn-success",true)})
+ .on("mouseout", function(d){ d3.select(this).classed("btn-success",false)})
+ .on("click", function(d){ document.location.href=webbase+'/tag/'+d.name});
+ if(tags)
+ d3.select("#pictags").insert("span",":first-child").text("tags in current picture:");
});
update_thumbnails();
update_page_index();
}
-function prev_pic() {
-}
-
-function next_pic() {
-}
-
function load_pic(myid) {
ID=myid;
update_page_index();
- update_thumbnails();
load_content();
}
/* 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",function(d){return (d.id==IDcurr);});
+ d3.select(".nextprev").select("ul").selectAll("li").select("a").select("img")
+ .classed("current",function(d){return (d.id==IDcurr);});
/* add links for left/right arrows */
if (IDprev != -1 )
- d3.select(".left").on("click", function() { load_pic(IDprev); });
+ d3.select(".left" ).on("click", function() { load_pic(IDprev); });
if (IDnext != -1 )
- d3.select(".right").on("click", function() { load_pic(IDnext); });
-
- });
+ d3.select(".right").on("click", function() { load_pic(IDnext); });
+
+ /* keyboard shortcuts */
+ $(document)
+ .keydown( function (e) {
+ if(e.which == 37 && IDprev != -1) { $(document).unbind('keydown'); load_pic(IDprev); }
+ if(e.which == 39 && IDnext != -1) { $(document).unbind('keydown'); load_pic(IDnext); }
+ });
+ });
}
function checkbutton()