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.

149 lines
4.2 KiB

  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. <nav class="navbar navbar-expand-lg sticky-top navbar-dark bg-dark">
  13. <div class="navbar-brand">Technical Incompetence</div>
  14. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown"
  15. aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
  16. <span class="navbar-toggler-icon"></span>
  17. </button>
  18. <div class="collapse navbar-collapse" id="navbarNavDropdown">
  19. <ul class="navbar-nav">
  20. <li class="nav-item">
  21. <a class="nav-link" href="/">Home</a>
  22. </li>
  23. <li class="nav-item active">
  24. <a class="nav-link" href="#">Games <span class="sr-only">(current)</span></a>
  25. </li>
  26. </ul>
  27. <form class="form-inline ml-auto">
  28. {% if account_url is defined and account_url != '' %}
  29. <a class="btn btn-primary" href="{{ account_url }}" role="button">My Account</a>
  30. {% endif %}
  31. </form>
  32. </div>
  33. </nav>
  34. {% endblock %}
  35. {% block content %}
  36. <div class="container" style="margin-top: 15px">
  37. {% if search['active'] == True %}
  38. <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 col-xl-12">
  39. <input type="text" class="form-control" id="search-box" placeholder="Search">
  40. </div>
  41. <br><br>
  42. {% endif %}
  43. {% if countdown is defined %}
  44. {% include "countdown.j2" %}
  45. {% endif %}
  46. <p>{{ description }}</p>
  47. <div class="row">
  48. {% for app in apps %}
  49. {% include "card.j2" %}
  50. {% endfor %}
  51. </div>
  52. <div class="row">
  53. {% include "card_list.j2" %}
  54. </div>
  55. <br>
  56. </div>
  57. {% include "new_game_modal.j2" %}
  58. {% endblock %}
  59. {% block scripts %}
  60. {{ super () }}
  61. {% if countdown is defined %}
  62. <script>
  63. const deadline = "{{ countdown['timestamp'] }}";
  64. const tripName = "{{ countdown['name'] }}";
  65. </script>
  66. <script src="{{url_for('.static', filename='clock.js')}}"></script>
  67. {% endif %}
  68. <script>
  69. $("#search-box").keyup(function(event) {
  70. if (event.keyCode === 13) {
  71. window.location = '{{ search['search_url'] }}' + $('#search-box').val();
  72. }
  73. });
  74. $( ".card" ).hover(
  75. function() {
  76. if (!$(this).attr('id')) {
  77. $(this).addClass('shadow-lg').css('cursor', 'pointer');
  78. $(this).addClass('card-hover');
  79. }
  80. }, function() {
  81. $(this).removeClass('shadow-lg');
  82. $(this).removeClass('card-hover');
  83. });
  84. function goToLink(link) {
  85. window.location = link;
  86. }
  87. function addGame() {
  88. game_title = $('#game-title').val();
  89. game_link = $('#game-link').val();
  90. if (game_title.trim().length === 0) {
  91. showError('Title is required');
  92. return false;
  93. }
  94. if (game_link.trim().length === 0) {
  95. showError('Link is required');
  96. return false;
  97. }
  98. $.ajax({
  99. url: '/add',
  100. method: 'POST',
  101. data: { "game_title": game_title,
  102. "game_link": game_link },
  103. success: function(data) {
  104. if (data !== 'Error') {
  105. $('#game-title').val('');
  106. $('#game-link').val('');
  107. window.location.reload();
  108. } else {
  109. showError('Something went wrong!');
  110. }
  111. }
  112. });
  113. }
  114. function deleteGame(game_id) {
  115. $.ajax({
  116. url: '/delete',
  117. method: 'POST',
  118. data: { "game_id": game_id },
  119. success: function(data) {
  120. if (data !== 'Error') {
  121. window.location.reload();
  122. } else {
  123. showError('Something went wrong!');
  124. }
  125. }
  126. });
  127. }
  128. function showError(error) {
  129. hideSuccess();
  130. $('#error-alert').text(error);
  131. $('#error-alert').show();
  132. }
  133. function hideError(error) {
  134. $('#error-alert').hide();
  135. }
  136. </script>
  137. {% endblock %}