From 989cbdf748f65da15dfb6fa69e3f3c90b7d130b9 Mon Sep 17 00:00:00 2001 From: Dniel97 Date: Tue, 21 Nov 2023 23:54:02 +0100 Subject: [PATCH] idac: added TA eval ranks to the frontend --- titles/idac/frontend.py | 3 +++ titles/idac/frontend/js/idac_scripts.js | 20 ++++++++++++++++++++ titles/idac/frontend/ranking/js/scripts.js | 9 ++++----- 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/titles/idac/frontend.py b/titles/idac/frontend.py index 19c51ff..266897a 100644 --- a/titles/idac/frontend.py +++ b/titles/idac/frontend.py @@ -24,6 +24,7 @@ class RankingData: rank: int, name: str, record: int, + eval_id: int, store: str, style_car_id: int, update_date: str, @@ -32,6 +33,7 @@ class RankingData: self.name: str = name self.record: str = record self.store: str = store + self.eval_id: int = eval_id self.style_car_id: int = style_car_id self.update_date: str = update_date @@ -245,6 +247,7 @@ class IDACRankingFrontend(FE_Base): name=profile["username"], record=rank["goal_time"], store=arcade["name"], + eval_id=rank["eval_id"], style_car_id=rank["style_car_id"], update_date=str(rank["play_dt"]), ) diff --git a/titles/idac/frontend/js/idac_scripts.js b/titles/idac/frontend/js/idac_scripts.js index bae2396..e652337 100644 --- a/titles/idac/frontend/js/idac_scripts.js +++ b/titles/idac/frontend/js/idac_scripts.js @@ -1,6 +1,26 @@ // Declare a global variable to store the JSON data var constData; +function evaluateRank(evalId) { + if (evalId >= 1 && evalId <= 4) { + return "Rookie"; + } else if (evalId >= 5 && evalId <= 8) { + return "Regular"; + } else if (evalId >= 9 && evalId <= 12) { + return "Specialist"; + } else if (evalId >= 13 && evalId <= 16) { + return "Expert"; + } else if (evalId >= 17 && evalId <= 20) { + return "Professional"; + } else if (evalId >= 21 && evalId <= 24) { + return "Master"; + } else if (evalId == 25) { + return "Master+"; + } else { + return "Invalid"; + } + } + function formatGoalTime(milliseconds) { // Convert the milliseconds to a time string var minutes = Math.floor(milliseconds / 60000); diff --git a/titles/idac/frontend/ranking/js/scripts.js b/titles/idac/frontend/ranking/js/scripts.js index 297d79e..900061b 100644 --- a/titles/idac/frontend/ranking/js/scripts.js +++ b/titles/idac/frontend/ranking/js/scripts.js @@ -19,16 +19,15 @@ function loadRanking(courseId, pageNumber = 1) { var total_pages = data.total_pages; // Generate the HTML table - var tableHtml = '
'; + var tableHtml = '
#NameCarTimeStoreDate
'; $.each(data.ranking, function (i, ranking) { tableHtml += ''; tableHtml += ''; - tableHtml += ''; - tableHtml += ''; + tableHtml += ''; tableHtml += ''; + tableHtml += ''; // Ignore the Store and Date columns on small screens - tableHtml += ''; - tableHtml += ''; + tableHtml += ''; tableHtml += ''; }); tableHtml += '
#Name/CarTimeEvalStore/Date
' + ranking.rank + '' + ranking.name + '' + getCarName(ranking.style_car_id) + '' + ranking.name + '
' + getCarName(ranking.style_car_id) + '
' + formatGoalTime(ranking.record) + '' + evaluateRank(ranking.eval_id) + '' + ranking.store + '' + ranking.update_date + '' + ranking.store + '
' + ranking.update_date + '
';