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.

117 lines
3.6 KiB

4 years ago
  1. {% extends "bootstrap/base.html" %}
  2. {% block title %}Read TI Later{% endblock %}
  3. {% block styles %}
  4. {{super()}}
  5. <link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}">
  6. {% endblock %}
  7. {% block navbar %}
  8. <div id="navbar" class="navbar navbar-expand-lg sticky-top navbar-dark bg-dark">
  9. <div class="navbar-brand">Read TI Later</div>
  10. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown"
  11. aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
  12. <span class="navbar-toggler-icon"></span>
  13. </button>
  14. <div class="collapse navbar-collapse" id="navbarNavDropdown">
  15. <ul class="navbar-nav">
  16. <li class="nav-item">
  17. <a class="nav-link" href="{{ url_for('index') }}">My List</a>
  18. </li>
  19. <li class="nav-item">
  20. <a class="nav-link" href="{{ url_for('archived') }}">Archived</a>
  21. </li>
  22. </ul>
  23. <form class="form-inline ml-auto">
  24. <a class="btn btn-primary" href="/logout" role="button">Logout</a>
  25. </form>
  26. </div>
  27. </div>
  28. {% endblock %}
  29. {% block content %}
  30. <div class="wrapper">
  31. <!-- Sidebar -->
  32. <div id="sidebar">
  33. <ul class="list-unstyled components">
  34. <li>
  35. <a href="/">My List</a>
  36. </li>
  37. <li>
  38. <a href="/archived">Archived</a>
  39. </li>
  40. </ul>
  41. </div>
  42. <!-- Page Content -->
  43. <div id="content">
  44. <div id="error-alert" class="alert alert-danger" role="alert" style="display: none;">
  45. This is a danger alert—check it out!
  46. </div>
  47. <form>
  48. <div class="row justify-content-center">
  49. <div class="col-lg-8">
  50. <label for="formGroupExampleInput4">URL</label>
  51. <input id="link-form" type="text" class="form-control" placeholder="https://example.com">
  52. <br>
  53. <button type="button" class="btn btn-primary" onclick="addUrl();">Add</button>
  54. <br>
  55. <br>
  56. </div>
  57. <div style="position:fixed; bottom: 20px;">
  58. <p style="text-align: center;">Would you rather save on the go? Try our bookmarklet!</p>
  59. <code>
  60. javascript:(function(){var%20url%20=%20location.href;var%20otherWindow=window.open('about:blank','_blank');otherWindow.opener=null;otherWindow.location='{{ request.url_root }}add?close=1&url='+encodeURIComponent(url);})();
  61. </code>
  62. </div>
  63. </div>
  64. </form>
  65. </div>
  66. </div>
  67. {% endblock %}
  68. {% block scripts %}
  69. {{ super() }}
  70. <script>
  71. function addUrl() {
  72. url = $('#link-form').val();
  73. if (url.trim().length === 0) {
  74. showError('URL is required');
  75. return false;
  76. }
  77. $.ajax({
  78. url: '/add',
  79. method: 'POST',
  80. data: { "url": url },
  81. success: function(data) {
  82. if (data !== 'Error')
  83. window.location.reload();
  84. else
  85. showError('URL cannot be empty');
  86. }
  87. });
  88. }
  89. function showError(error) {
  90. hideSuccess();
  91. $('#error-alert').text(error);
  92. $('#error-alert').show();
  93. }
  94. function showArticle(message) {
  95. hideError();
  96. $('#article').html(message);
  97. $('#article img').css('max-width', '100%')
  98. $('#article').show();
  99. }
  100. function hideError(error) {
  101. $('#error-alert').hide();
  102. }
  103. function hideArticle(error) {
  104. $('#article').hide();
  105. }
  106. </script>
  107. {% endblock %}