Commits

Luke Plant committed 365114e

Added download plan feature

  • Participants
  • Parent commits 47f29ba

Comments (0)

Files changed (2)

File static/connections.js

     return true;
 }
 
+function downloadFile (data, name) {
+    $("#file-data-raw").val(data);
+    $("#file-name").val(name);
+    $('#download-container').append('<iframe height="1", width="1" frameborder="0" src="' + $SCRIPT_ROOT + '/download-form/"></iframe>');
+}
+
 $(document).ready(function () {
 
     var $tbl = $("#connections");
             alert("There is no data entered yet");
             return;
         }
-        $("#file-data-raw").val(getRawConnectionsData());
-        $("#file-name").val("connections.txt");
-        $('#download-container').append('<iframe height="1", width="1" frameborder="0" src="' + $SCRIPT_ROOT + '/download-form/"></iframe>');
+        downloadFile(getRawConnectionsData(), "connections.txt")
     }
 
     function uploadConnections () {

File static/plans.js

 
         if (solutionData.solution != undefined) {
             var data = solutionData.solution;
-            var $tbl = $("<table class='plan'><thead><tr><th colspan='2'>Plan</th></tr></thead><tbody></tbody><tfoot><tr><td colspan='2'><a class='remove-plan' href='#'>Remove</a></td></tr></tfoot></table>");
+            var $tbl = $("<table class='plan'><thead><tr><th colspan='2'>Plan</th></tr></thead><tbody></tbody><tfoot><tr><td colspan='2'><a class='remove-plan' href='#'>Remove</a> <a class='save-plan' href='#'>Download</a></td></tr></tfoot></table>");
             for (i in data) {
                 var row = data[i];
                 for (j in row) {
         $(ev.target).closest("table").remove();
     });
 
+    $("#plans").on("click", ".save-plan", function (ev) {
+        ev.preventDefault();
+        $tbl = $(ev.target).closest("table").clone();
+        $tbl.find("tfoot").remove();
+        downloadFile("<table>" + $tbl.html() + "</table>", "plan.html");
+    });
+
 });