show search tags, current tags, and tags of the current pic in one line
authorArun Persaud <arun@nubati.net>
Sat, 17 Nov 2012 23:28:14 +0000 (15:28 -0800)
committerArun Persaud <arun@nubati.net>
Sat, 17 Nov 2012 23:28:14 +0000 (15:28 -0800)
index.php
js/photo-tags.js

index a4fe2b7f44a7b8eaa27e0f4e98e4e7c7db1ce9f6..7cf15c01024d74cd75405c055f52f71f835822fc 100644 (file)
--- a/index.php
+++ b/index.php
@@ -71,13 +71,15 @@ function autoversion($file)
 
 <div class="tagsearch">
 <form class="form-search" method="get" action="">
- <label>Search for tag:</label> <input class="input-medium search-query" list="MyTags" id="MyTagsInput" type="text" value="" />
-  <datalist id="MyTags">
-  </datalist>
- <p> Current tags:<span id="currenttags"></span>
-  <a class="next btn btn-small btn-info" onclick="tagcloud()">tag cloud</a>
-  <a class="btn btn-small btn-success" href='<?php echo $webbase?>'>all</a>
- </p>
+  <p>
+    <label>Search for tag:</label> <input class="input-medium search-query" list="MyTags" id="MyTagsInput" type="text" value="" />
+    <datalist id="MyTags">
+    </datalist>
+    Current tags:<span id="currenttags"></span>
+    <a class="next btn btn-small btn-info" onclick="tagcloud()">tag cloud</a>
+    <a class="btn btn-small btn-success" href='<?php echo $webbase?>'>all</a>
+    <span id="pictags"></span>
+  </p>
 </form>
 </div>
 
index 238575d12cf17611c3919afbbead29dc414789e0..b657fbef1630dce5969e1490eb8407d45c64bd7d 100644 (file)
@@ -81,17 +81,21 @@ function load_content() {
                        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)
+               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-success",true)})
-                   .on("mouseout", function(d){ d3.select(this).classed("btn-success",false)})
-                   .on("click", function(d) { document.location.href=webbase+'/tag/'+d.name});
+                   .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();