From 1e5be07e6e5a5ff087658d5a1a8e25017593bc35 Mon Sep 17 00:00:00 2001 From: Atharva Karanjekar Date: Wed, 12 Jun 2024 12:29:48 +0530 Subject: [PATCH] Minor UI changes --- js/anime_about.js | 52 +++++++++++++++++++++++++++++++++++++++++++---- js/index.js | 41 ++++++++++++++++++++++++++++++++++--- 2 files changed, 86 insertions(+), 7 deletions(-) diff --git a/js/anime_about.js b/js/anime_about.js index 5234b5b..e812bc0 100644 --- a/js/anime_about.js +++ b/js/anime_about.js @@ -13,7 +13,6 @@ function localStorageFunc(str) { localStorage.setItem("end year", str.endDate.year); localStorage.setItem("end month", str.endDate.month); localStorage.setItem("end day", str.endDate.day); - localStorage.setItem("format", str.format); localStorage.setItem("duration", str.duration); localStorage.setItem("episodes", str.episodes); localStorage.setItem("popularity", str.popularity); @@ -133,9 +132,22 @@ function localStorageFunc(str) { } localStorage.setItem("relation ids", relationIdList); + + const format = { + "TV_SHORT": "TV Short", + "MOVIE": "Movie", + "SPECIAL": "Special", + "MUSIC": "Music", + "MANGA": "Manga", + "NOVEL": "Novel", + "ONE_SHOT": "One-shot" + } + + str.format = format[str.format] || str.format; + localStorage.setItem("format", str.format); } -function nullFuncSearch(str) { +function nullfunc(str) { if (str === null) { return "N/A"; } @@ -153,8 +165,31 @@ function animeContainer(str) { image.src = str.coverImage.extraLarge; const format = nullfunc(str.format); + + const formatMap = { + "TV_SHORT": "TV Short", + "MOVIE": "Movie", + "SPECIAL": "Special", + "MUSIC": "Music", + "MANGA": "Manga", + "NOVEL": "Novel", + "ONE_SHOT": "One-shot" + } + + const updatedFormatString = formatMap[format] || format; + const episodes = nullfunc(str.episodes); const season = nullfunc(str.season); + + const seasonMap = { + "WINTER": "Winter", + "SPRING": "Spring", + "SUMMER": "Summer", + "FALL": "Fall", + }; + + const updatedSeasonString = seasonMap[season] || season; + const endDate = nullfunc(str.endDate.year); const averageScore = nullfunc(str.averageScore); @@ -164,14 +199,14 @@ function animeContainer(str) {

${str.title.romaji}

- + @@ -191,6 +226,15 @@ function animeContainer(str) { }); } +function nullFuncSearch(str) { + if (str === null) { + return "N/A"; + } + else { + return str; + } +} + //-----------------------------------------------Adding event listeners to search button------------------------------------------------- diff --git a/js/index.js b/js/index.js index 02f2362..b3b1340 100644 --- a/js/index.js +++ b/js/index.js @@ -14,7 +14,6 @@ function localStorageFunc(str) { localStorage.setItem("end year", str.endDate.year); localStorage.setItem("end month", str.endDate.month); localStorage.setItem("end day", str.endDate.day); - localStorage.setItem("format", str.format); localStorage.setItem("duration", str.duration); localStorage.setItem("episodes", str.episodes); localStorage.setItem("popularity", str.popularity); @@ -134,6 +133,19 @@ function localStorageFunc(str) { } localStorage.setItem("relation ids", relationIdList); + + const format = { + "TV_SHORT": "TV Short", + "MOVIE": "Movie", + "SPECIAL": "Special", + "MUSIC": "Music", + "MANGA": "Manga", + "NOVEL": "Novel", + "ONE_SHOT": "One-shot" + } + + str.format = format[str.format] || str.format; + localStorage.setItem("format", str.format); } function nullfunc(str) { @@ -154,8 +166,31 @@ function animeContainer(str) { image.src = str.coverImage.extraLarge; const format = nullfunc(str.format); + + const formatMap = { + "TV_SHORT": "TV Short", + "MOVIE": "Movie", + "SPECIAL": "Special", + "MUSIC": "Music", + "MANGA": "Manga", + "NOVEL": "Novel", + "ONE_SHOT": "One-shot" + } + + const updatedFormatString = formatMap[format] || format; + const episodes = nullfunc(str.episodes); const season = nullfunc(str.season); + + const seasonMap = { + "WINTER": "Winter", + "SPRING": "Spring", + "SUMMER": "Summer", + "FALL": "Fall", + }; + + const updatedSeasonString = seasonMap[season] || season; + const endDate = nullfunc(str.endDate.year); const averageScore = nullfunc(str.averageScore); @@ -165,14 +200,14 @@ function animeContainer(str) {

${str.title.romaji}

  ${format} (${episodes} Episodes)  ${updatedFormatString} (${episodes} Episodes)
  
- ${season} ${endDate} + ${updatedSeasonString} ${endDate}
- +
  ${format} (${episodes} Episodes)  ${updatedFormatString} (${episodes} Episodes)
  
- ${season} ${endDate} + ${updatedSeasonString} ${endDate}