added init function for code that needs to be called after the script has been loaded
authorArun Persaud <arun@nubati.net>
Sun, 3 Jun 2012 17:28:12 +0000 (10:28 -0700)
committerArun Persaud <arun@nubati.net>
Sun, 3 Jun 2012 17:28:12 +0000 (10:28 -0700)
index.php
js/photo-tags.js

index a2de85a..353a848 100644 (file)
--- 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();
 
index 7fce2f2..c178fe1 100644 (file)
@@ -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+"*");