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.

77 lines
2.5 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 style="margin-top: 20px;" id="weight_form">
  8. <div class="form-group">
  9. <label for="exercise_activity">Activity</label>
  10. <select id="exercise_activity" class="form-control">
  11. <option value="indoor-cycling">Indoor Cycling</option>
  12. </select>
  13. </div>
  14. <div class="form-group">
  15. <label for="exercise_minutes">Minutes</label>
  16. <input type="number" id="exercise_minutes" class="form-control">
  17. </div>
  18. <div class="form-group">
  19. <label for="exercise_heartrate">Avg Heart Rate</label>
  20. <input type="number" id="exercise_heartrate" class="form-control">
  21. </div>
  22. <div class="form-group">
  23. <label for="date">Date and Time</label>
  24. <input type="text" id="date" class="form-control" value="<?= date('Y-m-d H:i:s') ?>">
  25. </div>
  26. <div style="float: right; margin-top: 6px;">
  27. <button class="btn btn-success" id="btn_post">Post</button>
  28. </div>
  29. </form>
  30. <div style="clear: both;"></div>
  31. </div>
  32. <script>
  33. $(function(){
  34. var d = new Date();
  35. var tzOffset = tz_seconds_to_offset(d.getTimezoneOffset() * 60 * -1);
  36. $("#date").val( $("#date").val() + " " + tzOffset);
  37. $("#btn_post").click(function(){
  38. $("#btn_post").addClass("loading disabled");
  39. $.post("/exercise", {
  40. activity: $("#exercise_activity").val(),
  41. minutes: $("#exercise_minutes").val(),
  42. heartrate: $("#exercise_heartrate").val(),
  43. published: $("#date").val()
  44. }, function(response){
  45. if(response.location != false) {
  46. $("#test_success").removeClass('hidden');
  47. $("#test_error").addClass('hidden');
  48. $("#post_href").attr("href", response.location);
  49. window.location = response.location;
  50. } else {
  51. $("#test_success").addClass('hidden');
  52. $("#test_error").removeClass('hidden');
  53. if(response.error_details) {
  54. $("#test_error").text(response.error_details);
  55. }
  56. $("#btn_post").removeClass("loading disabled");
  57. }
  58. });
  59. return false;
  60. });
  61. });
  62. </script>