]> gitweb.michael.orlitzky.com - dead/census-tools.git/commitdiff
Created a MapUtils object to contain the post_data function.
authorMichael Orlitzky <michael@orlitzky.com>
Fri, 19 Feb 2010 14:43:59 +0000 (09:43 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Fri, 19 Feb 2010 14:43:59 +0000 (09:43 -0500)
www/maps/maps/public/javascripts/maputils.js
www/maps/maps/templates/javascript/routing.mako

index 45f976d30e3332b87fcf6549f1eb0d8539009da0..3d1f2e5cecba3cd9d067f71f1a78aefbaae5a038 100644 (file)
@@ -1,17 +1,21 @@
-function post_data(url, data) {
-  /* Create a new form, and add it to the DOM. Then, create a hidden
-     input control as a child of the form which contains the data that
-     we'd like to post. Finally, add the form to the document's body,
-     and submit it. */
-  var new_form = document.createElement("form");
-  new_form.method = "post";
-  new_form.action = url;
-  var new_input = document.createElement("input");
-  new_input.setAttribute("id", "data");
-  new_input.setAttribute("name", "data");
-  new_input.setAttribute("type", "hidden");
-  new_input.setAttribute("value", data);
-  new_form.appendChild(new_input);
-  document.body.appendChild(new_form);
-  new_form.submit();
+function MapUtils() {
+  
+  this.post_data = function(url, data) {
+    /* Create a new form, and add it to the DOM. Then, create a hidden
+       input control as a child of the form which contains the data that
+       we'd like to post. Finally, add the form to the document's body,
+       and submit it. */
+    var new_form = document.createElement("form");
+    new_form.method = "post";
+    new_form.action = url;
+    var new_input = document.createElement("input");
+    new_input.setAttribute("id", "data");
+    new_input.setAttribute("name", "data");
+    new_input.setAttribute("type", "hidden");
+    new_input.setAttribute("value", data);
+    new_form.appendChild(new_input);
+    document.body.appendChild(new_form);
+    new_form.submit();
+  }
+
 }
index 3d28f3b4978ce66f48abe852497038437db3bcdd..49e10b74d21274cbd867f153e7560053b0401272 100644 (file)
@@ -49,7 +49,8 @@ function routing_callback(result, status) {
   if (completed_requests == total_requests) {
     // Close the array, and do something with the result.
     json_string += ']';
-    post_data('/directions/json_to_kml', json_string)
+    mu = new MapUtils();
+    mu.post_data('/directions/json_to_kml', json_string);
   }
   else {
     // Continue the array.