added information when displaying a single picture
authorArun Persaud <arun@nubati.net>
Sat, 17 Nov 2012 20:06:08 +0000 (12:06 -0800)
committerArun Persaud <arun@nubati.net>
Sat, 17 Nov 2012 20:06:08 +0000 (12:06 -0800)
* description, if available
* time
* tags (clickable)

getjson.php
js/photo-tags.js

index 432b32468fdd6f0a6d3c03cae71f2a4bd4830f1a..63daf0bc33d9b8c181e5d8ac1df70874e0a161a5 100644 (file)
@@ -67,9 +67,16 @@ if (isset($_REQUEST["S"]))
  else if (isset($_REQUEST["ID"]) && !isset($_REQUEST["C"]))
   {
     $id  = intval($_REQUEST["ID"]);
-    $result = $DB->query("SELECT base_uri, filename, id FROM photos".
+    $result = $DB->query("SELECT base_uri, filename, id, description, time FROM photos".
                         " WHERE id=$id");
   }
+ else if (isset($_REQUEST["IDT"]))
+   {  /* tags of a single image */
+    $id  = intval($_REQUEST["IDT"]);
+    $result = $DB->query("SELECT t.name as name FROM photo_tags pt ".
+                        " LEFT JOIN tags t on t.id=pt.tag_id".
+                        " WHERE pt.photo_id=$id");
+  }
  else if (isset($_REQUEST["CLOUD"]))
   {
     $result = $DB->query("SELECT t.name as name, count(*) as count FROM photo_tags pt ".
index 8db5df9e9f2feb06c06e5c5c2dac2ff6ac089440..4b8d397f4c2f0c1125f00b63994449421415f89e 100644 (file)
@@ -60,18 +60,41 @@ function load_content() {
       /* if ID is set, just show one pictures, else create an array of pictures */
       if (ID>=0)
        {
-         var singlepicspace=pics.selectAll("li").data(picdata, function(d){return ID;}).enter().append("li").append("div").attr("class","singlepic");
-         singlepicspace.append("img").attr("class","left").attr("src",webbase+"/icons/left.png");
-         singlepicspace.append("img")
-           .attr("class","large")
-           .attr("src",function(d) {
-               s = d.base_uri+'/'+d.filename;
-               s = s.replace('file:\/\/'+dbprefix,webbase+'/Photos-small/');
-               return s;
-             });
-         singlepicspace.append("img").attr("class","right").attr("src",webbase+"/icons/right.png");
-
-         update_thumbnails();
+           var singlepicspace=pics.selectAll("li").data(picdata, function(d){return ID;}).
+               enter().append("li").append("div").attr("class","singlepic");
+           singlepicspace.append("img").attr("class","left").attr("src",webbase+"/icons/left.png");
+           singlepicspace.append("img")
+               .attr("class","large")
+               .attr("src",function(d) {
+                   s = d.base_uri+'/'+d.filename;
+                   s = s.replace('file:\/\/'+dbprefix,webbase+'/Photos-small/');
+                   return s;
+               });
+           singlepicspace.append("img").attr("class","right").attr("src",webbase+"/icons/right.png");
+           /* show description and time of photo */
+           singlepicspace.append("p")
+               .text(function(d) {
+                   var date = new Date(d.time*1000);
+                   if (d.description=="")
+                       return "Time: "+date.toUTCString();
+                   else
+                       return "Description: "+d.description + "Time: "+date.toUTCString();
+               });
+           /* show tags */
+           tags="";
+           d3.json(webbase+"/getjson.php?IDT="+ID, function(jsontag) {
+               singlepicspace.append("p").selectAll("span").data(jsontag)
+                   .enter().append("span")
+                   .attr("class","btn btn-small")
+                   .text( function(t) {
+                       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});
+           });
+
+           update_thumbnails();
        }
       else
        {