small whitespace cleanup
[photo-tags.git] / js / photo-tags.js
index ea6e4c58c40bed3fde7f13a489670bdfa640b14e..8db5df9e9f2feb06c06e5c5c2dac2ff6ac089440 100644 (file)
@@ -15,17 +15,32 @@ function init()
       d3.select('form').attr("action",webbase+"/tag/"+document.getElementById('MyTagsInput').value.replace(" ","+"));
   });
 
-  d3.select("#currenttags").select("button").remove();
+  d3.select("#currenttags").select("a").remove();
   if (T!="")
     {
       var mycurrenttags = T.split(",");
 
-      d3.select("#currenttags").selectAll("button")
+      d3.select("#currenttags").selectAll("a")
         .data(mycurrenttags).enter()
-        .append("button").attr("class","btn btn-small").text( function(d) {return d;} );
+        .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+"*");
 
@@ -130,11 +145,11 @@ function tagcloud() {
   /* 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("click", function(d) { document.location.href=webbase+'/tag/'+d.name })
+       .on("mouseover", function(d){ d3.select(this).style("color","red")  })
+       .on("mouseout",  function(d){ d3.select(this).style("color","black")})
+       .on("click", function(d) { document.location.href=webbase+'/tag/'+d.name});
     });
 }