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.

39 lines
1.4 KiB

6 years ago
6 years ago
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. </head>
  8. <body>
  9. <script>
  10. $.get("https://127.0.0.1:5000/ratings", function(dataStr, status){
  11. data = $.parseJSON(dataStr)
  12. if (status == "success") {
  13. data.forEach(function(element) {
  14. var a = document.createElement('a');
  15. var linkText = document.createTextNode(element["name"]);
  16. a.appendChild(linkText);
  17. a.title = element["name"];
  18. a.href = "javascript:results(" + element["id"] + ");";
  19. document.body.appendChild(a);
  20. document.body.appendChild(document.createElement("br"));
  21. });
  22. }
  23. });
  24. function results(id) {
  25. $.get("https://127.0.0.1:5000/ratings/" + id, function(dataStr, status){
  26. data = $.parseJSON(dataStr)
  27. if (status == "success") {
  28. var results = document.getElementById("results")
  29. results.innerHTML = '';
  30. for (var key in data["rates"]) {
  31. results.innerHTML += "<p>" + data["rates"][key]["note"] + "</p> " + data["rates"][key]["score"] + "/10 <br><br>"
  32. }
  33. }
  34. });
  35. }
  36. </script>
  37. <div id="results"></div>
  38. </body>
  39. </html>