From: Michael Orlitzky Date: Fri, 19 Feb 2010 14:43:59 +0000 (-0500) Subject: Created a MapUtils object to contain the post_data function. X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=01fd7fbb997f6e7017c92005702f4b80c9dbafb1;p=dead%2Fcensus-tools.git Created a MapUtils object to contain the post_data function. --- diff --git a/www/maps/maps/public/javascripts/maputils.js b/www/maps/maps/public/javascripts/maputils.js index 45f976d..3d1f2e5 100644 --- a/www/maps/maps/public/javascripts/maputils.js +++ b/www/maps/maps/public/javascripts/maputils.js @@ -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(); + } + } diff --git a/www/maps/maps/templates/javascript/routing.mako b/www/maps/maps/templates/javascript/routing.mako index 3d28f3b..49e10b7 100644 --- a/www/maps/maps/templates/javascript/routing.mako +++ b/www/maps/maps/templates/javascript/routing.mako @@ -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.