You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB

  1. <div class="narrow">
  2. <?= partial('partials/header') ?>
  3. <div style="clear: both;" class="notice-pad">
  4. <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div>
  5. <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div>
  6. </div>
  7. <form role="form" style="margin-top: 20px;" id="note_form">
  8. <div class="form-group">
  9. <label>Flight Number (e.g. <code>AS387</code>)</label>
  10. <input type="text" id="flight" class="form-control" value="AS387">
  11. </div>
  12. <div style="float: right; margin-top: 6px;">
  13. <button class="btn btn-success" id="btn_post">Check In</button>
  14. </div>
  15. </form>
  16. </div>
  17. <script>
  18. $(function(){
  19. $("#btn_post").click(function(){
  20. if($(this).text() == "Find Flight") {
  21. $.post("/flight", {
  22. action: "find",
  23. flight: $("#flight").val()
  24. }, function(data){
  25. });
  26. } else {
  27. $("#btn_post").addClass("loading disabled").text("Working...");
  28. $.post("/flight", {
  29. action: "checkin",
  30. flight: $("#flight").val()
  31. }, function(response){
  32. if(response.location != false) {
  33. $("#test_success").removeClass('hidden');
  34. $("#test_error").addClass('hidden');
  35. $("#post_href").attr("href", response.location);
  36. $("#note_form").addClass("hidden");
  37. } else {
  38. $("#test_success").addClass('hidden');
  39. $("#test_error").removeClass('hidden');
  40. $("#btn_post").removeClass("loading disabled").text("Check In");
  41. }
  42. });
  43. }
  44. return false;
  45. });
  46. });
  47. </script>