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.
 
 
 

65 lines
2.4 KiB

<!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>
<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">
</head>
<body>
<div id="main" class="container">
<h1>Ratings</h1><br>
</div>
<br>
<div id="results" class="container">
</div>
<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.getElementById("main").appendChild(a);
document.getElementById("main").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"]) {
var blockquote = document.createElement('blockquote');
blockquote.className = "blockquote text-right";
var text = document.createElement('p');
text.className = "mb-0";
text.innerHTML = data["rates"][key]["note"] + '<br>' + data["rates"][key]["score"] + '/10';
var by = document.createElement('footer');
by.className = "blockquote-footer";
$.get("https://127.0.0.1:5000/users/" + key, function(dataStr, status) {
data = $.parseJSON(dataStr)
by.innerHTML = data["realname"]
});
blockquote.appendChild(text);
blockquote.appendChild(by);
results.appendChild(blockquote);
}
}
});
}
</script>
</body>
</html>