summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArun Persaud <arun@nubati.net>2012-06-03 10:28:12 -0700
committerArun Persaud <arun@nubati.net>2012-06-03 10:28:12 -0700
commita941f0edd18b218cdfd31bfd17e3d672d94f9f52 (patch)
tree508b736fff7d68e6626d012bb7295c2f4768a093
parent6a253bce9766ec2128d27d7fd02194dd7ed4afaf (diff)
downloadphoto-tags-a941f0edd18b218cdfd31bfd17e3d672d94f9f52.tar.gz
photo-tags-a941f0edd18b218cdfd31bfd17e3d672d94f9f52.tar.bz2
photo-tags-a941f0edd18b218cdfd31bfd17e3d672d94f9f52.zip
added init function for code that needs to be called after the script has been loaded
-rw-r--r--index.php2
-rw-r--r--js/photo-tags.js49
2 files changed, 28 insertions, 23 deletions
diff --git a/index.php b/index.php
index a2de85a..353a848 100644
--- a/index.php
+++ b/index.php
@@ -85,6 +85,7 @@ page <span class="index"></span>
<script src = "<?php echo $webbase.autoversion("/js/photo-tags.js")?>"></script>
<script type="text/javascript" >
+
/*hand parameters over to javascript*/
var page=<?php echo $page ?>;
var N=<?php echo $N ?>;
@@ -94,6 +95,7 @@ var count=0;
var dbprefix="<?php echo $dbprefix ?>".replace(/\//g,"\/");
var webbase = "<?php echo $webbase?>";
+init();
load_content();
update_page_index();
diff --git a/js/photo-tags.js b/js/photo-tags.js
index 7fce2f2..c178fe1 100644
--- a/js/photo-tags.js
+++ b/js/photo-tags.js
@@ -1,30 +1,33 @@
var pics = d3.select(".pics").select("ul");
-/* populate data list with tags*/
-d3.json(webbase+"/getjson.php?S", function(json) {
- d3.select("#MyTags").selectAll("option").data(json)
- .enter().append("option").attr("value",function(d) {return d.name});
+function init()
+{
+ /* populate data list with tags*/
+ d3.json(webbase+"/getjson.php?S", function(json) {
+ d3.select("#MyTags").selectAll("option").data(json)
+ .enter().append("option").attr("value",function(d) {return d.name});
+ });
+
+ /* update form to point to new link */
+ d3.select("input").on("keyup", function(d) {
+ d3.select('form').attr("action",webbase+"/tag/"+document.getElementById('MyTagsInput').value.replace(" ","+"));
});
-/* update form to point to new link */
-d3.select("input").on("keyup", function(d) {
- d3.select('form').attr("action",webbase+"/tag/"+document.getElementById('MyTagsInput').value.replace(" ","+"));
-});
-
-if (T!="")
- {
- var mycurrenttags = T.split(",");
-
- d3.select("#currenttags").select("button").remove();
- d3.select("#currenttags").selectAll("button")
- .data(mycurrenttags).enter()
- .append("button").attr("type","button").text( function(d) {return d;} );
- }
- else
- {
- d3.select("#currenttags").select("button").remove();
- d3.select("#currenttags").append("span").text( ' none');
- };
+ if (T!="")
+ {
+ var mycurrenttags = T.split(",");
+
+ d3.select("#currenttags").select("button").remove();
+ d3.select("#currenttags").selectAll("button")
+ .data(mycurrenttags).enter()
+ .append("button").attr("type","button").text( function(d) {return d;} );
+ }
+ else
+ {
+ d3.select("#currenttags").select("button").remove();
+ d3.select("#currenttags").append("span").text( ' none');
+ };
+}
function load_content() {
// d3.select(".debug").text("T,P,N = *"+T+"* *"+page+"* *"+N+"*");