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.

88 lines
2.5 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">
  9. <label for="note_url">URL to Favorite (<code>like-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. <hr>
  18. <div style="text-align: right;" id="bookmarklet">
  19. Bookmarklet: <a href="javascript:<?= js_bookmarklet('partials/favorite-bookmarklet', $this) ?>" class="btn btn-default btn-xs">favorite</a>
  20. </div>
  21. </div>
  22. <script>
  23. $(function(){
  24. var autosubmit = window.location.search.match('autosubmit=true');
  25. if(autosubmit) {
  26. $(".footer, #bookmarklet").hide();
  27. }
  28. // ctrl-s to save
  29. $(window).on('keydown', function(e){
  30. if(e.keyCode == 83 && e.ctrlKey){
  31. $("#btn_post").click();
  32. }
  33. });
  34. $("#btn_post").click(function(){
  35. var syndications = [];
  36. $("#syndication-container button.btn-info").each(function(i,btn){
  37. syndications.push($(btn).data('syndication'));
  38. });
  39. $.post("/favorite", {
  40. url: $("#note_url").val()
  41. }, function(data){
  42. var response = JSON.parse(data);
  43. if(response.location != false) {
  44. if(autosubmit) {
  45. $("#btn_post").hide();
  46. } else {
  47. $("#test_success").removeClass('hidden');
  48. $("#test_error").addClass('hidden');
  49. $("#post_href").attr("href", response.location);
  50. }
  51. window.location = response.location;
  52. } else {
  53. $("#test_success").addClass('hidden');
  54. $("#test_error").removeClass('hidden');
  55. }
  56. });
  57. return false;
  58. });
  59. if(autosubmit) {
  60. $("#btn_post").click();
  61. }
  62. bind_syndication_buttons();
  63. });
  64. <?= partial('partials/syndication-js') ?>
  65. </script>