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.

64 lines
2.4 KiB

6 years ago
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Ratings</title>
  6. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  7. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  8. </head>
  9. <body>
  10. <div id="main" class="container">
  11. <h1>Ratings</h1><br>
  12. </div>
  13. <br>
  14. <div id="results" class="container">
  15. </div>
  16. <script>
  17. $.get("https://127.0.0.1:5000/ratings", function(dataStr, status){
  18. data = $.parseJSON(dataStr)
  19. if (status == "success") {
  20. data.forEach(function(element) {
  21. var a = document.createElement('a');
  22. var linkText = document.createTextNode(element["name"]);
  23. a.appendChild(linkText);
  24. a.title = element["name"];
  25. a.href = "javascript:results(" + element["id"] + ");";
  26. document.getElementById("main").appendChild(a);
  27. document.getElementById("main").appendChild(document.createElement("br"));
  28. });
  29. }
  30. });
  31. function results(id) {
  32. $.get("https://127.0.0.1:5000/ratings/" + id, function(dataStr, status){
  33. data = $.parseJSON(dataStr)
  34. if (status == "success") {
  35. var results = document.getElementById("results")
  36. results.innerHTML = '';
  37. for (var key in data["rates"]) {
  38. var blockquote = document.createElement('blockquote');
  39. blockquote.className = "blockquote text-right";
  40. var text = document.createElement('p');
  41. text.className = "mb-0";
  42. text.innerHTML = data["rates"][key]["note"] + '<br>' + data["rates"][key]["score"] + '/10';
  43. var by = document.createElement('footer');
  44. by.className = "blockquote-footer";
  45. $.get("https://127.0.0.1:5000/users/" + key, function(dataStr, status) {
  46. data = $.parseJSON(dataStr)
  47. by.innerHTML = data["realname"]
  48. });
  49. blockquote.appendChild(text);
  50. blockquote.appendChild(by);
  51. results.appendChild(blockquote);
  52. }
  53. }
  54. });
  55. }
  56. </script>
  57. </body>
  58. </html>