Mirror of Quill
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.

100 lines
3.8 KiB

  1. <div class="narrow">
  2. <?= partial('partials/header') ?>
  3. <div style="clear: both;">
  4. <div class="alert alert-success hidden" id="test_success"><strong>Success! We found a Location header in the response!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div>
  5. <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div>
  6. </div>
  7. <form role="form" style="margin-top: 20px;" id="note_form">
  8. <div class="form-group" style="margin-top: 18px;">
  9. <label>Event Name</label>
  10. <input type="text" class="form-control" id="event_name" placeholder="" value="">
  11. </div>
  12. <div class="form-group" id="start_date" style="margin-top: 18px;">
  13. <label>Start Date/Time</label>
  14. <div class="form-group">
  15. <input type="text" class="form-control date" placeholder="<?= date('Y-m-d') ?>" value="" style="max-width: 40%; margin-right: 4px; float: left;">
  16. <input type="text" class="form-control time" placeholder="14:30" value="" style="max-width: 40%; margin-right: 4px; float: left;">
  17. <input type="text" class="form-control timezone" placeholder="-08:00" style="max-width: 15%;">
  18. </div>
  19. </div>
  20. <div class="form-group" id="end_date" style="margin-top: 18px;">
  21. <label>End Date/Time (Optional)</label>
  22. <div class="form-group">
  23. <input type="text" class="form-control date" placeholder="<?= date('Y-m-d') ?>" value="" style="max-width: 40%; margin-right: 4px; float: left;">
  24. <input type="text" class="form-control time" placeholder="14:30" value="" style="max-width: 40%; margin-right: 4px; float: left;">
  25. <input type="text" class="form-control timezone" placeholder="-08:00" style="max-width: 15%;">
  26. </div>
  27. </div>
  28. <div class="form-group" style="margin-top: 18px;">
  29. <label>Location</label>
  30. <input type="text" class="form-control" id="event_location" placeholder="" value="">
  31. </div>
  32. <div class="form-group" style="margin-top: 18px;">
  33. <label for="note_category">Tags (comma-separated)</label>
  34. <input type="text" id="note_category" value="" class="form-control">
  35. </div>
  36. <div style="float: right; margin-top: 6px;">
  37. <button class="btn btn-success" id="btn_post">Post</button>
  38. </div>
  39. </form>
  40. </div>
  41. <script>
  42. $(function(){
  43. var d = new Date();
  44. $("#start_date .timezone").val(tz_seconds_to_offset(d.getTimezoneOffset() * 60 * -1));
  45. });
  46. $("#btn_post").click(function(){
  47. var event_start = $("#start_date .date").val()+"T"+$("#start_date .time").val()+$("#start_date .timezone").val();
  48. var event_end;
  49. if($("#end_date .date").val()) {
  50. event_end = $("#end_date .date").val()+"T"+$("#end_date .time").val()+$("#end_date .timezone").val();
  51. }
  52. var properties = {
  53. name: $("#event_name").val(),
  54. start: event_start,
  55. location: $("#event_location").val(),
  56. category: csv_to_array($("#note_category").val())
  57. };
  58. if(event_end) {
  59. properties.end = event_end;
  60. }
  61. $.post("/micropub/postjson", {
  62. data: JSON.stringify({
  63. "type": "h-event",
  64. "properties": properties
  65. })
  66. }, function(response){
  67. if(response.location != false) {
  68. $("#test_success").removeClass('hidden');
  69. $("#test_error").addClass('hidden');
  70. $("#post_href").attr("href", response.location);
  71. $("#note_form").slideUp(200, function(){
  72. $(window).scrollTop($("#test_success").position().top);
  73. });
  74. } else {
  75. $("#test_success").addClass('hidden');
  76. $("#test_error").removeClass('hidden');
  77. }
  78. });
  79. return false;
  80. });
  81. </script>