extends layout

block headers
  script(src="http://code.jquery.com/jquery-1.8.2.js")
  script(src="#{host}/js/libplanconverter.js")

block content
  header
    h3 planconverterjs demo application
  #main
    form(id="upload_form",enctype='multipart/form-data')
      input(type='file', name='f')
      input(type='button', id="upload_button", value='Upload')
  #ans
  script(type="text/javascript")
    $("#upload_button").click(function() {
      $("#ans").html("")
      planconverterjs.get_data($("#upload_form")[0],
        function(fp,err) {
          if (err !== null) {
            alert("error");
          } else {
            $("#ans").append(fp.to_table("table"));
          }
        }
      );
    });

extends layout

block headers
  script(src="http://code.jquery.com/jquery-1.8.2.js")
  script(src="#{host}/js/libplanconverter.js")

block content
  header
    h3 planconverterjs demo application
  #main
    form(id="upload_form",enctype='multipart/form-data')
      p
        | Load flight plan: 
        input(type='file', name='f')
        input(type='button', id="upload_button", value='Upload')

  #answer
    h3 flight plan
    #ans
    form(id="fp_form", action='#{host}/jsontopln', method='POST')
      p
        | FP type: 
        select(name='fs')
          option(value='fsx') fsx
          option(value='fs9') fs9
        br
        | Filename 
        input(type='text', name='fn', value='plan.pln')
        br
        input(type='hidden', name='fp', id='fp_form_fp')
        input(type='submit', id='fp_submit', value='Download')


  script(type="text/javascript")
    var global_fp = null;
    $("#upload_button").click(function() {
      $("#ans").html("")
      planconverterjs.get_data($("#upload_form")[0],
        function(fp,err) {
          if (err !== null) {
            alert("error");
          } else {
            $("#ans").append(fp.to_table("table"));
            global_fp = fp;
          }
        }
      );
    });
    $("#fp_form").submit(function () {
      $("#fp_form_fp").val(JSON.stringify(global_fp));
    });

Update the main demo to allow downloading plans.
Update the main demo to allow downloading plans.
