From 48e4f17090a9193a23c1ed8b01f7b92688e4c28d Mon Sep 17 00:00:00 2001 From: Michael Green <84688932+michael-j-green@users.noreply.github.com> Date: Sun, 20 Oct 2024 02:10:59 +1100 Subject: [PATCH] Fixed ratings loading in the preferences --- gaseous-server/wwwroot/pages/game.js | 2 +- gaseous-server/wwwroot/scripts/preferences.js | 42 +++++++++++++++---- 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/gaseous-server/wwwroot/pages/game.js b/gaseous-server/wwwroot/pages/game.js index 68b99fd..3c74733 100644 --- a/gaseous-server/wwwroot/pages/game.js +++ b/gaseous-server/wwwroot/pages/game.js @@ -410,7 +410,7 @@ function LoadGamePlatforms() { let platformContainer = document.getElementById('gamesummaryplatformscontent'); platformContainer.innerHTML = ''; for (let i = 0; i < result.length; i++) { - let logoUrl = '/api/v1/Platforms/' + result[i].id + '/platformlogo/original/logo.png'; + let logoUrl = '/api/v1.1/Platforms/' + result[i].id + '/platformlogo/original/logo.png'; // create platform container let platformItem = document.createElement('div'); diff --git a/gaseous-server/wwwroot/scripts/preferences.js b/gaseous-server/wwwroot/scripts/preferences.js index fb5330e..2bfc792 100644 --- a/gaseous-server/wwwroot/scripts/preferences.js +++ b/gaseous-server/wwwroot/scripts/preferences.js @@ -181,16 +181,40 @@ class PreferencesWindow { "Adult" ]; for (let j = 0; j < ratingGroupsOrder.length; j++) { - let ageGroupValue = AgeRatingGroups[ratingGroupsOrder[j]]; - let iconIdList = ageGroupValue[key.toLowerCase()]; + let ratingGroup = ratingGroupsOrder[j]; + let ageGroupValue = AgeRatingGroups[ratingGroup]; + let ageGroupValueLower = {}; + for (const [key, value] of Object.entries(ageGroupValue)) { + ageGroupValueLower[key.toLowerCase()] = value; + } + + let iconIdList = ageGroupValueLower[key.toLowerCase()]; + console.log(key.toLowerCase()); + if (key == 'clasS_IND' || key == 'CLASS_IND') { + console.log("here"); + } // loop the age rating icons - for (let i = 0; i < iconIdList.length; i++) { - let icon = document.createElement('img'); - // icon.src = "/images/Ratings/" + key + "/" + AgeRatingStrings[iconIdList[i]] + ".svg"; - icon.src = "/images/Ratings/" + key + "/" + iconIdList[i] + ".svg"; - icon.title = AgeRatingStrings[iconIdList[i]]; - icon.classList.add("rating_image_mini"); - classificationIcons.appendChild(icon); + if (iconIdList) { + for (const [i, value] of Object.entries(iconIdList)) { + console.log(" " + iconIdList[i]); + let icon = document.createElement('img'); + + // get age rating strings + let iconId = iconIdList[i]; + let ageRatingString; + for (const [x, y] of Object.entries(AgeRatingStrings)) { + if (AgeRatingStrings[x] == iconId) { + ageRatingString = AgeRatingStrings[x]; + break; + } + } + + icon.src = "/images/Ratings/" + key + "/" + ageRatingString + ".svg"; + icon.title = ageRatingString; + icon.alt = ageRatingString; + icon.classList.add("rating_image_mini"); + classificationIcons.appendChild(icon); + } } } classificationItemBox.appendChild(classificationIcons);