removed unnecessary fetch-requests

main
Lang, Simon 3 months ago
parent 031a8bb2a0
commit d4233c07b8
  1. 17
      public/elotracker/chart-integration.js

@ -90,17 +90,10 @@ window.onload = async function(){
let puuid = chart.id.split("-");
puuid.splice(0,2);
puuid = puuid.join("-");
fetch(`get.php?puuid=${puuid}`, {
method: "GET",
})
.then(res => res.json())
.then(result => {
let entries = result["entries"];
let account = result["accounts"];
let xValues = [];
let yValues = [];
for (const entriesKey in entries) {
let points = rank_to_points(entries[entriesKey]["tier"], entries[entriesKey]["rank"], entries[entriesKey]["points"]);
for (const entriesKey in player_entries[puuid]) {
let points = rank_to_points(player_entries[puuid][entriesKey]["tier"], player_entries[puuid][entriesKey]["rank"], player_entries[puuid][entriesKey]["points"]);
xValues.push(entriesKey);
yValues.push(points);
}
@ -109,7 +102,7 @@ window.onload = async function(){
data: {
labels: xValues,
datasets: [{
label: `${account["gameName"]}#${account["tagLine"]}`,
label: `${player_accounts[puuid]["gameName"]}#${player_accounts[puuid]["tagLine"]}`,
fill: false,
borderColor: "rgba(150,150,175)",
backgroundColor: "rgba(150,150,175)",
@ -122,7 +115,7 @@ window.onload = async function(){
tooltip: {
callbacks: {
label: function(context) {
return format_rank(entries[context.label]["tier"],entries[context.label]["rank"],entries[context.label]["points"])
return format_rank(player_entries[puuid][context.label]["tier"],player_entries[puuid][context.label]["rank"],player_entries[puuid][context.label]["points"])
},
beforeTitle: function (context) {
return context[0].dataset.label;
@ -143,8 +136,6 @@ window.onload = async function(){
},
}
});
})
.catch(e => console.error(e))
}
};

Loading…
Cancel
Save