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.

135 lines
3.6 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. {% extends "bootstrap/base.html" %}
  2. {% block title %}Technical Incompetence - Home{% endblock %}
  3. {% block styles %}
  4. {{super()}}
  5. <link rel="icon" type="image/png" href="{{url_for('.static', filename='favicon.png')}}" />
  6. <link rel="stylesheet" href="{{url_for('.static', filename='style.css')}}">
  7. {% if countdown is defined %}
  8. <link rel="stylesheet" href="{{url_for('.static', filename='clock.css')}}">
  9. {% endif %}
  10. {% endblock %}
  11. {% block navbar %}
  12. {% include "fragments/navbar.j2" %}
  13. {% endblock %}
  14. {% block content %}
  15. <iframe id="apps" src="https://technicalincompetence.club/frame" width="305" height="400" class="shadow-lg overlay-frame" style="display: none;"></iframe>
  16. <div id="overlay" style="display: none;" onclick="showApps();"></div>
  17. <div class="container" style="margin-top: 15px">
  18. {% if search['active'] == True %}
  19. <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
  20. <input type="text" class="form-control" id="search-box" placeholder="Search">
  21. </div>
  22. <br><br>
  23. {% endif %}
  24. {% if countdown is defined %}
  25. {% include "fragments/countdown.j2" %}
  26. {% endif %}
  27. <p>{{ description }}</p>
  28. <div class="row">
  29. {% for app in games %}
  30. {% include "fragments/card.j2" %}
  31. {% endfor %}
  32. </div>
  33. <div class="row">
  34. {% include "fragments/card_list.j2" %}
  35. </div>
  36. <br>
  37. </div>
  38. {% include "fragments/new_game_modal.j2" %}
  39. {% endblock %}
  40. {% block scripts %}
  41. {{ super () }}
  42. {% if countdown is defined %}
  43. <script>
  44. const deadline = "{{ countdown['timestamp'] }}";
  45. const tripName = "{{ countdown['name'] }}";
  46. </script>
  47. <script src="{{url_for('.static', filename='clock.js')}}"></script>
  48. {% endif %}
  49. <script>
  50. $("#search-box").keyup(function(event) {
  51. if (event.keyCode === 13) {
  52. window.location = '{{ search['search_url'] }}' + $('#search-box').val();
  53. }
  54. });
  55. $( ".card" ).hover(
  56. function() {
  57. if (!$(this).attr('id')) {
  58. $(this).addClass('shadow-lg').css('cursor', 'pointer');
  59. $(this).addClass('card-hover');
  60. }
  61. }, function() {
  62. $(this).removeClass('shadow-lg');
  63. $(this).removeClass('card-hover');
  64. });
  65. function goToLink(link) {
  66. window.location = link;
  67. }
  68. function showApps () {
  69. $("#apps").toggle();
  70. $("#overlay").toggle();
  71. }
  72. function addGame() {
  73. game_title = $('#game-title').val();
  74. game_link = $('#game-link').val();
  75. if (game_title.trim().length === 0) {
  76. showError('Title is required');
  77. return false;
  78. }
  79. if (game_link.trim().length === 0) {
  80. showError('Link is required');
  81. return false;
  82. }
  83. $.ajax({
  84. url: '/add',
  85. method: 'POST',
  86. data: { "game_title": game_title,
  87. "game_link": game_link },
  88. success: function(data) {
  89. if (data !== 'Error') {
  90. $('#game-title').val('');
  91. $('#game-link').val('');
  92. window.location.reload();
  93. } else {
  94. showError('Something went wrong!');
  95. }
  96. }
  97. });
  98. }
  99. function deleteGame(game_id) {
  100. $.ajax({
  101. url: '/delete',
  102. method: 'POST',
  103. data: { "game_id": game_id },
  104. success: function(data) {
  105. if (data !== 'Error') {
  106. window.location.reload();
  107. } else {
  108. showError('Something went wrong!');
  109. }
  110. }
  111. });
  112. }
  113. function showError(error) {
  114. hideSuccess();
  115. $('#error-alert').text(error);
  116. $('#error-alert').show();
  117. }
  118. function hideError(error) {
  119. $('#error-alert').hide();
  120. }
  121. </script>
  122. {% endblock %}