summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--getjson.php6
-rw-r--r--index.php21
2 files changed, 27 insertions, 0 deletions
diff --git a/getjson.php b/getjson.php
index 83360e6..07294ba 100644
--- a/getjson.php
+++ b/getjson.php
@@ -29,6 +29,12 @@ if (isset($_REQUEST["S"]))
$result = $DB->query("SELECT base_uri, filename, id FROM photos".
" WHERE id=$id");
}
+ else if (isset($_REQUEST["CLOUD"]))
+ {
+ $result = $DB->query("SELECT t.name as name, count(*) as count FROM photo_tags pt ".
+ " LEFT JOIN tags t on t.id=pt.tag_id".
+ " GROUP BY t.id");
+ }
else
{
if (isset($_REQUEST["P"]))
diff --git a/index.php b/index.php
index 82378b4..aa799b9 100644
--- a/index.php
+++ b/index.php
@@ -55,6 +55,7 @@ else
</datalist>
</form>
Current tags:<span id="currenttags"></span>
+ <button class="next" type="button" onclick="cloud()">tag cloud</button>
</div>
<div class="pics"> </div>
@@ -180,6 +181,26 @@ function right() {
load_content(page);
}
+function cloud() {
+
+ url = "<?php echo $webbase?>/getjson.php?CLOUD=1";
+
+ pics.selectAll("li").remove();
+
+ var svgelement=pics.append("li")
+ .append("svg").attr("width",400).attr("height",400);
+
+ /* 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)+"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='<?php echo $webbase?>/tag/'+d.name })
+ });
+}
+
function checkbutton()
{