<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Ratings</title>
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
$.get("https://127.0.0.1:5000/ratings", function(dataStr, status){
|
|
data = $.parseJSON(dataStr)
|
|
if (status == "success") {
|
|
data.forEach(function(element) {
|
|
var a = document.createElement('a');
|
|
var linkText = document.createTextNode(element["name"]);
|
|
a.appendChild(linkText);
|
|
a.title = element["name"];
|
|
a.href = "javascript:results(" + element["id"] + ");";
|
|
document.body.appendChild(a);
|
|
document.body.appendChild(document.createElement("br"));
|
|
});
|
|
}
|
|
});
|
|
|
|
function results(id) {
|
|
$.get("https://127.0.0.1:5000/ratings/" + id, function(dataStr, status){
|
|
data = $.parseJSON(dataStr)
|
|
if (status == "success") {
|
|
var results = document.getElementById("results")
|
|
results.innerHTML = '';
|
|
for (var key in data["rates"]) {
|
|
results.innerHTML += "<p>" + data["rates"][key]["note"] + "</p> " + data["rates"][key]["score"] + "/10 <br><br>"
|
|
}
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
<div id="results"></div>
|
|
</body>
|
|
</html>
|