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.

105 lines
3.9 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</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. $("#note_category").tokenfield({
  47. createTokensOnBlur: true,
  48. beautify: true
  49. });
  50. $("#btn_post").click(function(){
  51. var event_start = $("#start_date .date").val()+"T"+$("#start_date .time").val()+$("#start_date .timezone").val();
  52. var event_end;
  53. if($("#end_date .date").val()) {
  54. event_end = $("#end_date .date").val()+"T"+$("#end_date .time").val()+$("#end_date .timezone").val();
  55. }
  56. var properties = {
  57. name: $("#event_name").val(),
  58. start: event_start,
  59. location: $("#event_location").val(),
  60. category: tokenfieldToArray("#note_category")
  61. };
  62. if(event_end) {
  63. properties.end = event_end;
  64. }
  65. $.post("/micropub/postjson", {
  66. data: JSON.stringify({
  67. "type": "h-event",
  68. "properties": properties
  69. })
  70. }, function(response){
  71. if(response.location != false) {
  72. $("#test_success").removeClass('hidden');
  73. $("#test_error").addClass('hidden');
  74. $("#post_href").attr("href", response.location);
  75. $("#note_form").slideUp(200, function(){
  76. $(window).scrollTop($("#test_success").position().top);
  77. });
  78. } else {
  79. $("#test_success").addClass('hidden');
  80. $("#test_error").removeClass('hidden');
  81. }
  82. });
  83. return false;
  84. });
  85. </script>