Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.08 KB | None | 0 0
  1. {% extends 'dashboard/base.html' %}
  2.  
  3. {% block title %}Sigma{% endblock title %}
  4. {% block name %}Newsfeed{% endblock name %}
  5.  
  6. {% block style %}
  7. <style>
  8. select {
  9. text-align-last:center;
  10. }
  11. .pageheader-title {
  12. align-self: center;
  13. margin-bottom: 0px;
  14. }
  15. </style>
  16. {% endblock style %}
  17.  
  18. {% block scripts %}
  19. {{super()}}
  20. <script>
  21. var transactions = {{week_transactions|tojson|safe}};
  22. </script>
  23.  
  24. <script>
  25.  
  26. function thought() {
  27. $.get("/category/transact", {
  28. name: "Thot",
  29. target: current_user.id,
  30. delta_source: 0,
  31. delta_target: 1,
  32. description: $("#input-text").val()
  33. }, function(data) {
  34. toastr.success("Thot shared");
  35. setTimeout(onChange, 2000);
  36. }).fail(function( jqXHR, textStatus, errorThrown ) {
  37. toastr.error(jqXHR.responseText);
  38. });
  39. }
  40.  
  41. function showFeed() {
  42. var feed = $("#feed");
  43. feed.html("");
  44. for (var i = 0; i < amount && i < transactions.length; i++) {
  45. var course = transactions[i];
  46. // We only know how to display:
  47. // One of source or target deltas is 0
  48. // source and target deltas are negatives of each other
  49. /*if (tx.delta_source != 0 && tx.delta_target != 0 && tx.delta_source != -tx.delta_target) {
  50. continue;
  51. }*/
  52. var cardColor = "positive-card";//tx.category == "Thot" ? "thought-card" : tx.delta_target >= 0 ? "positive-card" : "negative-card";
  53. var row = $("<div>", {class: "row"});
  54. var col = $("<div>", {class: "col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12"});
  55. var card = $("<div>", {class: "card thin-card-container " + cardColor});
  56. var cardHeader = $("<div>", {class: "card-header thin-card"});
  57. var cardBody = $("<div>", {class: "card-body thin-card"});
  58.  
  59. cardHeader.text(course["course_id"] + " " + course["course_name"] + " | " + " \u2192 ");
  60. cardBody.text(course["course_description"]);
  61.  
  62. card.append(cardHeader);
  63. if (course["course_description"] != "") {
  64. card.append(cardBody);
  65. }
  66. col.append(card);
  67. row.append(col);
  68. feed.append(row);
  69. }
  70. }
  71.  
  72. function init() {
  73. toastr.options = {
  74. "closeButton": false,
  75. "debug": false,
  76. "newestOnTop": false,
  77. "progressBar": false,
  78. "positionClass": "toast-bottom-center",
  79. "preventDuplicates": false,
  80. "onclick": null,
  81. "showDuration": "300",
  82. "hideDuration": "1000",
  83. "timeOut": "3000",
  84. "extendedTimeOut": "1000",
  85. "showEasing": "swing",
  86. "hideEasing": "linear",
  87. "showMethod": "fadeIn",
  88. "hideMethod": "fadeOut",
  89. "escapeHtml": true
  90. };
  91. showFeed();
  92. toastr.success("test");
  93. }
  94.  
  95. $(document).ready(init);
  96. </script>
  97. {% endblock scripts %}
  98.  
  99. {% block content %}
  100. <div class="dashboard-wrapper">
  101. <div class="dashboard-ecommerce">
  102. <div class="container-fluid dashboard-content">
  103. <div class="row">
  104. <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
  105. <div class="card thin-card-container" style="margin-bottom: 10px">
  106. <h5 class="card-header thin-card">Share a Thot</h5>
  107. <div class="card-body thin-card">
  108. <form onsubmit="thought(); return false;">
  109. <div class="form-group" style="margin-bottom: 0px">
  110. <label>My thot</label>
  111. <input type="text" class="form-control" id="input-text">
  112. <div style="height:10px"></div>
  113. <button type="submit" class="btn btn-primary btn-lg btn-block">Share</button>
  114. </div>
  115. </form>
  116. </div>
  117. </div>
  118. </div>
  119. </div>
  120. <div class="row">
  121. <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
  122. <div class="page-header" style="display:flex; justify-content: space-between">
  123. <h2 class="pageheader-title">Courses</h2>
  124. <select class="form-control" id="num-show" onchange="showFeed();" style="max-width:150px;">
  125. <!--<option value="100">Weekly 100</option>
  126. <option value="500">Weekly 500</option>
  127. <option value="1000000000">1 Week</option>
  128. <option value="-1">1 Month</option>
  129. <option value="-2">Everything</option>-->
  130. </select>
  131. </div>
  132. </div>
  133. </div>
  134. <div id="feed"></div>
  135. <!-- ============================================================== -->
  136. <!-- end pageheader -->
  137. <!-- ============================================================== -->
  138.  
  139. </div>
  140. </div>
  141. </div>
  142. {% endblock content %}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement