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.

90 lines
2.4 KiB

4 years ago
4 years ago
3 years ago
4 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
3 years ago
4 years ago
  1. {% extends "bootstrap/base.html" %}
  2. {% block title %}tia.paste{% endblock %}
  3. {% block styles %}
  4. {{super()}}
  5. <link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}">
  6. {% endblock %}
  7. {% block navbar %}
  8. {% include "fragments/navbar.j2" %}
  9. {% endblock %}
  10. {% block content %}
  11. {% import "fragments/table.j2" as table %}
  12. <iframe id="apps" src="https://technicalincompetence.club/frame" width="305" height="400" class="shadow-lg overlay-frame" style="display: none;"></iframe>
  13. <div id="overlay" style="display: none;" onclick="showApps();"></div>
  14. <div class="container" style="margin-top: 15px">
  15. <div class="col-lg-12">
  16. <div id="success-alert" class="alert alert-success" role="alert" style="display: none;"></div>
  17. <div id="error-alert" class="alert alert-danger" role="alert" style="display: none;"></div>
  18. <h1>Your Pastes</h1>
  19. <br>
  20. <h3>Shortened Urls</h3>
  21. {{ table.build(links, 'links') }}
  22. <br>
  23. <h3>Pastes</h3>
  24. {{ table.build(pastes, 'pastes') }}
  25. <br>
  26. <h3>Images</h3>
  27. {{ table.build(images, 'images') }}
  28. </div>
  29. </div>
  30. {% endblock %}
  31. {% block scripts %}
  32. {{ super() }}
  33. <script>
  34. function showError(error) {
  35. hideSuccess();
  36. $('#error-alert').text(error);
  37. $('#error-alert').show();
  38. }
  39. function showSuccess(message) {
  40. hideError();
  41. $('#success-alert').html(message);
  42. $('#success-alert').show();
  43. }
  44. function hideError() {
  45. $('#error-alert').hide();
  46. }
  47. function hideSuccess() {
  48. $('#success-alert').hide();
  49. }
  50. function showApps () {
  51. $("#apps").toggle();
  52. $("#overlay").toggle();
  53. }
  54. const deleteEntry = (game, table) => {
  55. fetch('/delete', {
  56. method: 'POST',
  57. headers: { "Content-Type": "application/json; charset=utf-8" },
  58. body: JSON.stringify({'table': table, 'id': game})
  59. })
  60. .then(res => res.json()) // parse response as JSON (can be res.text() for plain response)
  61. .then(response => {
  62. // here you do what you want with response
  63. console.log(response);
  64. if (response.success) {
  65. showSuccess(response.msg);
  66. hideError();
  67. document.querySelector('#' + table + "-" + game).remove();
  68. } else {
  69. showError(response.msg);
  70. hideSuccess();
  71. }
  72. })
  73. .catch(err => {
  74. console.log(err);
  75. showError('An error occured!');
  76. hideSuccess();
  77. });
  78. };
  79. </script>
  80. {% endblock %}