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.

61 lines
1.8 KiB

10 years ago
  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">
  9. <label for="note_url">URL to Repost (<code>repost-of</code>)</label>
  10. <input type="text" id="note_url" value="<?= $this->url ?>" class="form-control">
  11. </div>
  12. <div style="float: right; margin-top: 6px;">
  13. <button class="btn btn-success" id="btn_post">Post</button>
  14. </div>
  15. </form>
  16. <div style="clear: both;"></div>
  17. </div>
  18. <script>
  19. $(function(){
  20. // ctrl-s to save
  21. $(window).on('keydown', function(e){
  22. if(e.keyCode == 83 && e.ctrlKey){
  23. $("#btn_post").click();
  24. }
  25. });
  26. $("#btn_post").click(function(){
  27. $.post("/repost", {
  28. url: $("#note_url").val()
  29. }, function(data){
  30. var response = JSON.parse(data);
  31. if(response.location != false) {
  32. $("#test_success").removeClass('hidden');
  33. $("#test_error").addClass('hidden');
  34. $("#post_href").attr("href", response.location);
  35. window.location = response.location;
  36. } else {
  37. $("#test_success").addClass('hidden');
  38. $("#test_error").removeClass('hidden');
  39. }
  40. });
  41. return false;
  42. });
  43. });
  44. </script>