- // if parent is also the category, they are less options to display
- if (parent.id === category.id) {
-
- if (parent.parent === challenge.parent) {
-
- // returns only the challenges, as it is the key-capstone
- return
-
- }
-
- // else return challenge and parent (key-capstone)
- return
+ );
}
+ // else return challenge and parent (key-capstone)
+ return (
+
+ );
+ }
- let temporaryChallenge = parent
+ // if a challenge has more than 2 parent-challenges, this array will be filled
+ let moreChallenges = [];
- // max 10 tries
- while (temporaryChallenge.parent > 10 || tries > 5) {
+ // if the challenges parent is not a key-capstone, loop until it is found
+ if (parent.parent > 10) {
+ let tries = 0;
- // set temp to the parent of the temp before
- temporaryChallenge = getChallenge(temporaryChallenge.parent);
+ let temporaryChallenge = parent;
- //console.log(temporaryChallenge); // debug
- moreChallenges.push(generateObject(getChallenge(temporaryChallenge.id)))
+ // max 10 tries
+ while (temporaryChallenge.parent > 10 || tries > 5) {
+ // set temp to the parent of the temp before
+ temporaryChallenge = getChallenge(temporaryChallenge.parent);
- tries++;
+ //console.log(temporaryChallenge); // debug
+ moreChallenges.push(generateObject(getChallenge(temporaryChallenge.id)));
- }
+ tries++;
}
-
-
- // Returns the right section of the challenge page, containing all the paths the current challenge has
- return
-
Capstones
-
-
- {checkExists(category.tags.isCapstone) ?
-
- : null}
-
-
-
-
- {category.translation.name}
-
-
-
- {moreChallenges}
-
- {generateObject(parent)}
-
- {generateObject(challenge, true, challenge.id)}
-
- {checkExists(challenge.tags.isCapstone) ?
-
{capstonetext}
- : null}
+ }
+
+ // Returns the right section of the challenge page, containing all the paths the current challenge has
+ return (
+
-
-}
\ No newline at end of file
+ );
+}
diff --git a/src/module/Challenge.js b/src/module/Challenge.js
index 5828334..dce32be 100644
--- a/src/module/Challenge.js
+++ b/src/module/Challenge.js
@@ -1,15 +1,15 @@
import { Component, Fragment } from "react";
-import Error from "./Error"
-import get from "../func/get"
-import { getCache } from "../func/getCheckCache"
-import css from "../css/user.module.css"
-import { serverToHumanReadable, serverToMachineReadable } from "../func/server"
-import Timestamp from "react-timestamps"
-import { beautifyNum } from "../func/beautify.js"
+import Error from "./Error";
+import get from "../func/get";
+import { getCache } from "../func/getCheckCache";
+import css from "../css/user.module.css";
+import { serverToHumanReadable, serverToMachineReadable } from "../func/server";
+import Timestamp from "react-timestamps";
+import { beautifyNum } from "../func/beautify.js";
import { intToTier } from "../func/tierFunctions";
import { LazyLoadImage } from "react-lazy-load-image-component";
import goTo from "../func/goTo.js";
-import start from "../css/start.module.css"
+import start from "../css/start.module.css";
// import showChallengePath from "../func/showChallengePath.js"
// import ShowChildChallenges from "../func/getChildChallenges";
import { checkExists } from "../func/arrayManipulationFunctions.js";
@@ -18,8 +18,8 @@ import config from "../config";
import { capitalize, strtolower, strtoupper } from "../func/stringManipulation";
import Wrapper from "./Wrapper";
//import VipBadge from "./VipBadge";
-import VipBadge from "./VipBadge"
-import Ad from "./Ad"
+import VipBadge from "./VipBadge";
+import Ad from "./Ad";
import { withTranslation } from "react-i18next";
import { Chart } from "chart.js/auto";
@@ -27,640 +27,863 @@ import { Chart } from "chart.js/auto";
//import excss from "../css/aboutChallenge.module.css"
class Challenge extends Component {
- constructor(props) {
- super(props)
- this.params = this.props.params
- this.regions = config.regions
- this.tiers = config.tiers
-
- let tempRegion = props.query.toLowerCase();
- if (!tempRegion) {
- tempRegion = "world"
- }
-
- this.challenge = "null"
-
- this.load = this.load.bind(this)
- this.error = this.error.bind(this)
-
- this.loadChallenge = this.loadChallenge.bind(this)
-
- this.changeFilter = this.changeFilter.bind(this)
- this.showChallenge = this.showChallenge.bind(this)
-
- let challengePlaceholder = {
- text: false,
- title: [],
- icon: 1,
- timestamp: Date.now() / 1000,
- challenge: {
- id: 0,
- parent: 0,
- translation: {
- name: "Loading",
- description: "Loading"
- }
- },
- }
-
- const tempChallenge = getCache(`https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`)
-
- if (tempChallenge !== false) {
- this.challenge = tempChallenge
- challengePlaceholder = tempChallenge
- document.title = "'" + tempChallenge.challenge.translation.name + "' Challenge Overview and Leaderboard"
- }
-
-
- this.state = {
- totalLength: 250,
- message: -1,
- filter: tempRegion,
- challenge: challengePlaceholder,
- translation: props.t
- }
-
+ constructor(props) {
+ super(props);
+ this.params = this.props.params;
+ this.regions = config.regions;
+ this.tiers = config.tiers;
+
+ let tempRegion = props.query.toLowerCase();
+ if (!tempRegion) {
+ tempRegion = "world";
}
-
- error() {
- this.setState({
- message:
,
- })
+ this.challenge = "null";
+
+ this.load = this.load.bind(this);
+ this.error = this.error.bind(this);
+
+ this.loadChallenge = this.loadChallenge.bind(this);
+
+ this.changeFilter = this.changeFilter.bind(this);
+ this.showChallenge = this.showChallenge.bind(this);
+
+ let challengePlaceholder = {
+ text: false,
+ title: [],
+ icon: 1,
+ timestamp: Date.now() / 1000,
+ challenge: {
+ id: 0,
+ parent: 0,
+ translation: {
+ name: "Loading",
+ description: "Loading",
+ },
+ },
+ };
+
+ const tempChallenge = getCache(
+ `https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`
+ );
+
+ if (tempChallenge !== false) {
+ this.challenge = tempChallenge;
+ challengePlaceholder = tempChallenge;
+ document.title =
+ "'" +
+ tempChallenge.challenge.translation.name +
+ "' Challenge Overview and Leaderboard";
}
- showChallenge(r) {
- document.title = "'" + r.challenge.translation.name + "' Challenge Overview, Thresholds and Leaderboards"
- this.setState({ challenge: r })
+ this.state = {
+ totalLength: 250,
+ message: -1,
+ filter: tempRegion,
+ challenge: challengePlaceholder,
+ translation: props.t,
+ };
+ }
+
+ error() {
+ this.setState({
+ message:
,
+ });
+ }
+
+ showChallenge(r) {
+ document.title =
+ "'" +
+ r.challenge.translation.name +
+ "' Challenge Overview, Thresholds and Leaderboards";
+ this.setState({ challenge: r });
+ }
+
+ componentDidUpdate() {
+ if (this.props.params !== this.params) {
+ this.params = this.props;
+ //window.location.reload()
+ const props = this.props;
+
+ this.params = this.props.params;
+ this.regions = config.regions;
+ this.tiers = config.tiers;
+
+ let tempRegion = props.query.toLowerCase();
+ if (!this.regions.includes(tempRegion)) {
+ tempRegion = "world";
+ }
+
+ this.challenge = "null";
+
+ this.load = this.load.bind(this);
+ this.error = this.error.bind(this);
+
+ this.loadChallenge = this.loadChallenge.bind(this);
+
+ this.changeFilter = this.changeFilter.bind(this);
+ this.showChallenge = this.showChallenge.bind(this);
+
+ let challengePlaceholder = {
+ text: false,
+ title: [],
+ icon: 1,
+ timestamp: Date.now() / 1000,
+ challenge: {
+ id: 0,
+ parent: 0,
+ translation: {
+ name: "Loading",
+ description: "Loading",
+ },
+ },
+ };
+
+ const tempChallenge = getCache(
+ `https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`
+ );
+
+ if (tempChallenge !== false) {
+ this.challenge = tempChallenge;
+ challengePlaceholder = tempChallenge;
+ document.title =
+ "'" +
+ tempChallenge.challenge.translation.name +
+ "' Challenge Overview and Leaderboard";
+ }
+
+ this.setState({
+ totalLength: 250,
+ message: -1,
+ filter: tempRegion,
+ challenge: challengePlaceholder,
+ translation: props.t,
+ });
+
+ if (this.challenge === "null") {
+ this.load();
+ }
+ } else {
+ this.chart();
}
-
- componentDidUpdate() {
- if (this.props.params !== this.params) {
- this.params = this.props;
- //window.location.reload()
- const props = this.props;
-
- this.params = this.props.params
- this.regions = config.regions
- this.tiers = config.tiers
-
- let tempRegion = props.query.toLowerCase();
- if (!this.regions.includes(tempRegion)) {
- tempRegion = "world"
- }
-
- this.challenge = "null"
-
- this.load = this.load.bind(this)
- this.error = this.error.bind(this)
-
- this.loadChallenge = this.loadChallenge.bind(this)
-
- this.changeFilter = this.changeFilter.bind(this)
- this.showChallenge = this.showChallenge.bind(this)
-
- let challengePlaceholder = {
- text: false,
- title: [],
- icon: 1,
- timestamp: Date.now() / 1000,
- challenge: {
- id: 0,
- parent: 0,
- translation: {
- name: "Loading",
- description: "Loading"
- }
- },
- }
-
- const tempChallenge = getCache(`https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`)
-
- if (tempChallenge !== false) {
- this.challenge = tempChallenge
- challengePlaceholder = tempChallenge
- document.title = "'" + tempChallenge.challenge.translation.name + "' Challenge Overview and Leaderboard"
- }
-
-
- this.setState({
- totalLength: 250,
- message: -1,
- filter: tempRegion,
- challenge: challengePlaceholder,
- translation: props.t
- });
-
- if (this.challenge === "null") {
- this.load();
- }
+ }
+
+ chart() {
+ try {
+ let chartStatus = Chart.getChart("average");
+ if (checkExists(chartStatus)) {
+ chartStatus.destroy();
+ }
+
+ const label = (tootltipItems) => {
+ if (tootltipItems[0].label === "Today") {
+ return "Todays data might be inaccurate, as it is calculated live. ";
}
- else {
- this.chart()
- }
- }
-
- chart() {
- try {
- let chartStatus = Chart.getChart("average");
- if (checkExists(chartStatus)) {
- chartStatus.destroy();
- }
- const label = (tootltipItems) => {
-
- if (tootltipItems[0].label === "Today") {
-
- return "Todays data might be inaccurate, as it is calculated live. "
-
- }
-
- return "";
-
- }
-
- const data = {
- labels: [
- "6 days ago",
- "5 days ago",
- "4 days ago",
- "3 days ago",
- "2 days ago",
- "Yesterday",
- "Today"
- ],
- datasets: [{
- label: 'Ø points per game',
- backgroundColor: getComputedStyle(document.documentElement).getPropertyValue('--selected'),
- borderColor: getComputedStyle(document.documentElement).getPropertyValue('--selected'),
- data: this.state.challenge.progress
- }]
- };
-
- const chartConfig = {
- type: 'line',
- data: data,
- options: {
- animation: false,
- radius: 7,
- plugins: {
- tooltip: {
- callbacks: {
- footer: label,
- }
- },
- legend: {
- display: false
- }
- },
- scales: {
- x: {
- ticks: {
- display: false,
- },
- grid: {
- display: false,
- drawBorder: false,
- color: getComputedStyle(document.documentElement).getPropertyValue('--dark3'),
- }
- },
- y: {
- ticks: {
- display: false,
- },
- grid: {
- display: false,
- drawBorder: false,
- color: getComputedStyle(document.documentElement).getPropertyValue('--dark3'),
- },
- }
- }
- }
- };
-
- // render chart
- new Chart(
- document.getElementById("average"),
- chartConfig
- );
- } catch (e) {
- console.warn(e);
- }
+ return "";
+ };
+
+ const data = {
+ labels: [
+ "6 days ago",
+ "5 days ago",
+ "4 days ago",
+ "3 days ago",
+ "2 days ago",
+ "Yesterday",
+ "Today",
+ ],
+ datasets: [
+ {
+ label: "Ø points per game",
+ backgroundColor: getComputedStyle(
+ document.documentElement
+ ).getPropertyValue("--selected"),
+ borderColor: getComputedStyle(
+ document.documentElement
+ ).getPropertyValue("--selected"),
+ data: this.state.challenge.progress,
+ },
+ ],
+ };
+
+ const chartConfig = {
+ type: "line",
+ data: data,
+ options: {
+ animation: false,
+ radius: 7,
+ plugins: {
+ tooltip: {
+ callbacks: {
+ footer: label,
+ },
+ },
+ legend: {
+ display: false,
+ },
+ },
+ scales: {
+ x: {
+ ticks: {
+ display: false,
+ },
+ grid: {
+ display: false,
+ drawBorder: false,
+ color: getComputedStyle(
+ document.documentElement
+ ).getPropertyValue("--dark3"),
+ },
+ },
+ y: {
+ ticks: {
+ display: false,
+ },
+ grid: {
+ display: false,
+ drawBorder: false,
+ color: getComputedStyle(
+ document.documentElement
+ ).getPropertyValue("--dark3"),
+ },
+ },
+ },
+ },
+ };
+
+ // render chart
+ new Chart(document.getElementById("average"), chartConfig);
+ } catch (e) {
+ console.warn(e);
}
+ }
- componentDidMount() {
- if (this.challenge === "null") {
- this.load();
- }
- // else {
- // this.chart();
- // }
+ componentDidMount() {
+ if (this.challenge === "null") {
+ this.load();
}
-
-
- load() {
- document.title = "Loading..."
- get(`https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`, this.loadChallenge, this.error);
+ // else {
+ // this.chart();
+ // }
+ }
+
+ load() {
+ document.title = "Loading...";
+ get(
+ `https://challenges.darkintaqt.com/api/v5/c/?id=${this.params.id}`,
+ this.loadChallenge,
+ this.error
+ );
+ }
+
+ loadChallenge(challenge) {
+ this.challenge = challenge;
+ if (this.challenge !== "null") {
+ this.showChallenge(this.challenge);
}
-
- loadChallenge(challenge) {
- this.challenge = challenge;
- if (this.challenge !== "null") {
- this.showChallenge(this.challenge)
+ }
+
+ changeFilter(e) {
+ var isRightMB = false;
+ var isMB2 = false;
+ e.preventDefault();
+
+ if ("which" in e)
+ // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
+ isRightMB = e.which === 3;
+ isMB2 = e.which === 2;
+
+ let filter = "world";
+
+ if (e.target.id === "world") {
+ let url = new URL(window.location);
+ url.search = "";
+ window.history.replaceState({}, "", url);
+ } else {
+ filter = e.target.id;
+
+ if (isRightMB || e.ctrlKey || e.altKey) {
+ filter = "";
+ for (let i = 0; i < this.regions.length; i++) {
+ const region = this.regions[i];
+
+ if (region !== e.target.id) {
+ filter += region + ";";
+ }
}
- }
-
-
- changeFilter(e) {
-
- var isRightMB = false;
- var isMB2 = false;
- e.preventDefault();
-
- if ("which" in e) // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
- isRightMB = e.which === 3;
- isMB2 = e.which === 2;
-
-
- let filter = "world";
-
- if (e.target.id === "world") {
- let url = new URL(window.location)
- url.search = "";
- window.history.replaceState({}, "", url)
- } else {
-
- filter = e.target.id;
-
- if (isRightMB || e.ctrlKey || e.altKey) {
-
- filter = "";
- for (let i = 0; i < this.regions.length; i++) {
- const region = this.regions[i];
-
- if (region !== e.target.id) {
- filter += region + ";"
- }
-
- }
-
+ } else if (e.shiftKey || isMB2) {
+ const tempFilter = this.state.filter.split(";");
+ if (tempFilter.includes(filter)) {
+ if (tempFilter.length > 1) {
+ var index = tempFilter.indexOf(filter);
+ if (index !== -1) {
+ tempFilter.splice(index, 1);
}
- else if (e.shiftKey || isMB2) {
-
- const tempFilter = this.state.filter.split(";")
- if (tempFilter.includes(filter)) {
-
- if (tempFilter.length > 1) {
- var index = tempFilter.indexOf(filter);
- if (index !== -1) {
- tempFilter.splice(index, 1);
- }
-
- filter = tempFilter.join(";");
- } else {
- filter = this.state.filter;
- }
-
- } else {
-
- console.log(tempFilter)
-
- if (tempFilter[0] !== "world") {
-
- filter = this.state.filter + ";" + filter
-
- }
-
- }
- }
+ filter = tempFilter.join(";");
+ } else {
+ filter = this.state.filter;
+ }
+ } else {
+ console.log(tempFilter);
- window.history.replaceState({}, "", "?region=" + filter)
+ if (tempFilter[0] !== "world") {
+ filter = this.state.filter + ";" + filter;
+ }
}
- this.setState({ filter: filter });
- }
-
- render() {
- try {
- const t = this.state.translation
-
- if (document.location.pathname.slice(-1) === "/") {
- return
- }
+ }
- const challenge = JSON.parse(JSON.stringify(this.state.challenge));
- const regions = this.regions
- const absoluteRegion = this.state.filter.split(";")
- let region = absoluteRegion[0];
- if (absoluteRegion[0] === "world") {
- region = window.region ?? "na"
- }
-
- function nameToURL(name) {
- if (typeof name !== "string") {
- return "error"
- }
- return name.replace(/#/g, "-");
- }
-
- function checkThresholds(thresholds) {
- let noThresholds = true;
- for (let index = 0; index < thresholds.length; index++) {
- if (thresholds[index] !== "-") {
- noThresholds = false;
- }
- }
- return noThresholds
- }
+ window.history.replaceState({}, "", "?region=" + filter);
+ }
+ this.setState({ filter: filter });
+ }
+
+ render() {
+ try {
+ const t = this.state.translation;
+
+ if (document.location.pathname.slice(-1) === "/") {
+ return
;
+ }
+
+ const challenge = JSON.parse(JSON.stringify(this.state.challenge));
+ const regions = this.regions;
+ const absoluteRegion = this.state.filter.split(";");
+ let region = absoluteRegion[0];
+ if (absoluteRegion[0] === "world") {
+ region = window.region ?? "na";
+ }
+
+ function nameToURL(name) {
+ if (typeof name !== "string") {
+ return "error";
+ }
+ return name.replace(/#/g, "-");
+ }
+
+ function checkThresholds(thresholds) {
+ let noThresholds = true;
+ for (let index = 0; index < thresholds.length; index++) {
+ if (thresholds[index] !== "-") {
+ noThresholds = false;
+ }
+ }
+ return noThresholds;
+ }
+
+ let filters = [
+
{
+ e.preventDefault();
+ return false;
+ }}
+ className={start.filterOption + " " + start["world"]}
+ id="world"
+ >
+ Global
+ ,
+ ];
+ for (let i = 0; i < regions.length; i++) {
+ filters.push(
+
{
+ e.preventDefault();
+ return false;
+ }}
+ className={start.filterOption + " " + start[regions[i]]}
+ id={regions[i]}
+ >
+ {regions[i]}
+
+ );
+ }
+
+ let summoner = [];
+ let warnings = [];
+ let thresholds = ["-", "-", "-", "-", "-", "-", "-", "-", "-", "-"];
+ let percentiles = {};
+ for (let i = 0; i < this.tiers.length; i++) {
+ percentiles[serverToMachineReadable(this.tiers[i])] =
+ Math.round(11 - (i + 1)) / 10;
+ }
+
+ let icon =
+ "https://lolcdn.darkintaqt.com/cdn/np-token/" + challenge["icon_2"];
+
+ if (
+ challenge.challenge.id < 10 ||
+ challenge.challenge.id === 2022000 ||
+ challenge.challenge.id === 2023000 ||
+ challenge.challenge.id === 2024100 ||
+ challenge.challenge.id === 2024200 ||
+ challenge.challenge.id === 2024300
+ ) {
+ if (challenge.challenge.id !== 0) {
+ if (challenge.challenge.id === 2024100) {
+ icon =
+ "https://cdn.darkintaqt.com/lol/static/challenges/2024-1seasonal.svg";
+ } else if (challenge.challenge.id === 2024200) {
+ icon =
+ "https://cdn.darkintaqt.com/lol/static/challenges/2024-2seasonal.svg";
+ } else if (challenge.challenge.id === 2024300) {
+ icon =
+ "https://cdn.darkintaqt.com/lol/static/challenges/2024-3seasonal.svg";
+ } else {
+ icon =
+ "https://cdn.darkintaqt.com/lol/static/challenges/" +
+ challenge.challenge.translation.name
+ .toLowerCase()
+ .replace(" ", "") +
+ ".svg";
+ }
+ }
+ }
+
+ let totalLength = this.state.totalLength;
+
+ let isLoading = "";
+ // Not loaded yet
+ if (challenge.icon === 1) {
+ isLoading = css.loading;
+ let i = 0;
+ while (i < 25) {
+ i++;
+ summoner.push(
+
+ {i}.
+
+
+
+ Loading
+
+
+ ...
+ -
+
+ );
+ }
- let filters = [
{ e.preventDefault(); return false; }} className={start.filterOption + " " + start["world"]} id="world">Global ];
- for (let i = 0; i < regions.length; i++) {
- filters.push(
{ e.preventDefault(); return false; }} className={start.filterOption + " " + start[regions[i]]} id={regions[i]}>{regions[i]} )
+ icon = "https://lolcdn.darkintaqt.com/cdn/profileicon/-1";
+ } else if (
+ challenge.challenge.leaderboard === true ||
+ checkExists(challenge.challenge.tags["leaderboardManuallyEnabled"])
+ ) {
+ thresholds = challenge.stats[serverToMachineReadable(region)];
+ percentiles =
+ challenge.stats["percentiles-" + serverToMachineReadable(region)];
+
+ if (checkThresholds(thresholds)) {
+ warnings.push(
+
+ This challenge is not enabled in #{absoluteRegion}
+
+ );
+ } else {
+ // create list with summoners
+ let summoners = [];
+
+ let counters = {};
+ for (let i = 0; i < regions.length; i++) {
+ if (
+ !absoluteRegion.includes(regions[i]) &&
+ absoluteRegion[0] !== "world"
+ ) {
+ continue;
}
-
- let summoner = []
- let warnings = [];
- let thresholds = ["-", "-", "-", "-", "-", "-", "-", "-", "-", "-"]
- let percentiles = {}
- for (let i = 0; i < this.tiers.length; i++) {
- percentiles[serverToMachineReadable(this.tiers[i])] = Math.round(11 - (i + 1)) / 10;
+ for (let ii = 0; ii < challenge.summoner[regions[i]].length; ii++) {
+ if (!checkExists(counters[regions[i]])) {
+ counters[regions[i]] = 1;
+ }
+ challenge.summoner[regions[i]][ii].push(regions[i]);
+ challenge.summoner[regions[i]][ii].push(counters[regions[i]]);
+ summoners.push(challenge.summoner[regions[i]][ii]);
+ counters[regions[i]]++;
}
-
- let icon = "https://lolcdn.darkintaqt.com/cdn/np-token/" + challenge["icon_2"]
-
- if (challenge.challenge.id < 10 || challenge.challenge.id === 2022000 || challenge.challenge.id === 2023000 || challenge.challenge.id === 2024100 || challenge.challenge.id === 2024200) {
- if (challenge.challenge.id !== 0) {
- if (challenge.challenge.id === 2024100) {
- icon = "https://cdn.darkintaqt.com/lol/static/challenges/2024-1seasonal.svg"
- } else if (challenge.challenge.id === 2024200) {
- icon = "https://cdn.darkintaqt.com/lol/static/challenges/2024-2seasonal.svg"
- } else {
- icon = "https://cdn.darkintaqt.com/lol/static/challenges/" + challenge.challenge.translation.name.toLowerCase().replace(" ", "") + ".svg"
- }
+ }
+ if (challenge.challenge.reversed === true) {
+ summoners.sort((a, b) => {
+ // Order by name if same value and position
+ if (a[1] === b[1]) {
+ if (b[6] === a[6]) {
+ return a[4] - b[4];
}
- }
-
- let totalLength = this.state.totalLength
-
- let isLoading = ""
- // Not loaded yet
- if (challenge.icon === 1) {
- isLoading = css.loading;
- let i = 0;
- while (i < 25) {
- i++;
- summoner.push(
- {i}.
-
-
-
- Loading
-
-
- ...
- -
- )
+ return a[6] - b[6];
+ }
+ return a[1] - b[1];
+ });
+ } else {
+ summoners.sort((a, b) => {
+ // Order by timestamp if same value and position
+ if (a[1] === b[1]) {
+ if (b[6] === a[6]) {
+ return a[4] - b[4];
}
-
- icon = "https://lolcdn.darkintaqt.com/cdn/profileicon/-1"
- } else if (challenge.challenge.leaderboard === true || checkExists(challenge.challenge.tags["leaderboardManuallyEnabled"])) {
-
- thresholds = challenge.stats[serverToMachineReadable(region)]
- percentiles = challenge.stats["percentiles-" + serverToMachineReadable(region)]
-
- if (checkThresholds(thresholds)) {
- warnings.push(
This challenge is not enabled in #{absoluteRegion}
)
- } else {
-
- // create list with summoners
- let summoners = []
-
-
- let counters = {};
- for (let i = 0; i < regions.length; i++) {
-
- if (!absoluteRegion.includes(regions[i]) && absoluteRegion[0] !== "world") { continue; }
-
- for (let ii = 0; ii < challenge.summoner[regions[i]].length; ii++) {
- if (!checkExists(counters[regions[i]])) {
- counters[regions[i]] = 1
- }
- challenge.summoner[regions[i]][ii].push(regions[i])
- challenge.summoner[regions[i]][ii].push(counters[regions[i]])
- summoners.push(challenge.summoner[regions[i]][ii])
- counters[regions[i]]++
- }
-
- }
- if (challenge.challenge.reversed === true) {
- summoners.sort((a, b) => {
- // Order by name if same value and position
- if (a[1] === b[1]) {
- if (b[6] === a[6]) {
- return a[4] - b[4]
- }
- return a[6] - b[6]
- }
- return a[1] - b[1]
- })
- } else {
- summoners.sort((a, b) => {
- // Order by timestamp if same value and position
- if (a[1] === b[1]) {
- if (b[6] === a[6]) {
- return a[4] - b[4]
- }
- return a[6] - b[6]
- }
- return b[1] - a[1]
- })
- }
-
- if (summoners.length === 0) {
- summoner = []
- } else {
- for (let i = 0; i < summoners.length; i++) {
- if (i >= totalLength) {
- break;
- }
- const player = summoners[i];
- // let pos = css.normal;
- // if (i === 0) {
- // pos = css.pos1
- // } else if (i < 10) {
- // pos = css.top10
- // } else if (i < 100) {
- // pos = css.top100
- // }
- let userlink = "/" + player[6] + "/" + nameToURL(player[0])
-
- if (player[0] === "%") {
- userlink = "/faq"
- }
-
- summoner.push(
- {i + 1}.
-
-
- {player[5] === 1 ? : null}
-
- {player[0]} {serverToHumanReadable(player[6])}
-
-
- {capitalize(t(strtolower(intToTier(player[2]))))}
- {beautifyNum(player[1], false)}
- )
+ return a[6] - b[6];
+ }
+ return b[1] - a[1];
+ });
+ }
+
+ if (summoners.length === 0) {
+ summoner = [];
+ } else {
+ for (let i = 0; i < summoners.length; i++) {
+ if (i >= totalLength) {
+ break;
+ }
+ const player = summoners[i];
+ // let pos = css.normal;
+ // if (i === 0) {
+ // pos = css.pos1
+ // } else if (i < 10) {
+ // pos = css.top10
+ // } else if (i < 100) {
+ // pos = css.top100
+ // }
+ let userlink = "/" + player[6] + "/" + nameToURL(player[0]);
+
+ if (player[0] === "%") {
+ userlink = "/faq";
+ }
+
+ summoner.push(
+
+ {i + 1}.
+
+
+ {player[5] === 1 ? (
+
+ ) : null}
+ {("This challenge isn't enabled in this {{region}}", { region: absoluteRegion })}
- } else {
- warnings.push(challenge.stats["percentiles-" + serverToMachineReadable(region)])
- warnings.push(Leaderboards aren't enabled for this challenge
Why? Because it is not possible to "scale" in this challenge, as it has a static highest achievable score. If you think this challenge should have a leaderboard, please create an issue on GitHub . )
- }
- }
-
- try {
- if (checkExists(challenge.challenge.tags["leaderboardManuallyEnabled"])) {
- warnings.push({t("Leaderboards might be incorrect due to a missing API-endpoint about this challenge. We still update rankings in this leaderboard, if you found a player who should be up here, just look them up.")}
)
- }
- } catch (error) {
- console.warn(error);
- }
- if (challenge.challenge.reversed) {
- warnings.push({t("This challenge is reversed. The less your points the better your placement")}
)
+ placeholderSrc={"https://lolcdn.darkintaqt.com/s/p-cb"}
+ alt={player[0] + "'s profile image"}
+ >
+
+ {player[0]}{" "}
+
+ {serverToHumanReadable(player[6])}
+
+
+
+
+ {capitalize(t(strtolower(intToTier(player[2]))))}
+ {beautifyNum(player[1], false)}
+
+ );
}
+ }
+ }
+ } else {
+ thresholds = challenge.challenge.thresholds;
+ if (checkThresholds(thresholds)) {
+ summoner = (
+
+ {
+ ("This challenge isn't enabled in this {{region}}",
+ { region: absoluteRegion })
+ }
+
+ );
+ } else {
+ warnings.push(
+ challenge.stats["percentiles-" + serverToMachineReadable(region)]
+ );
+ warnings.push(
+
+ Leaderboards aren't enabled for this challenge
+
+
+
+ Why? Because it is not possible to "scale" in this challenge, as
+ it has a static highest achievable score.
+ If you think this challenge should have a leaderboard, please
+ create an issue on{" "}
+
+ GitHub
+
+ .
+
+
+ );
+ }
+ }
+
+ try {
+ if (
+ checkExists(challenge.challenge.tags["leaderboardManuallyEnabled"])
+ ) {
+ warnings.push(
+
+ {t(
+ "Leaderboards might be incorrect due to a missing API-endpoint about this challenge. We still update rankings in this leaderboard, if you found a player who should be up here, just look them up."
+ )}
+
+ );
+ }
+ } catch (error) {
+ console.warn(error);
+ }
+ if (challenge.challenge.reversed) {
+ warnings.push(
+
+ {t(
+ "This challenge is reversed. The less your points the better your placement"
+ )}
+
+ );
+ }
+
+ if (challenge.icon_2 === 0) {
+ warnings.push(
+
+ This leaderboard is "technically" wrong, as the ranking still
+ includes points from the seasonal 2023 challenges for some players,
+ which should not be counted towards the total points.{" "}
+
+ );
+ }
+
+ // if (summoner.length === 0) {
+ // warnings.push(
No high-ranked summoners yetDue to API limitations we can only show players ranked MASTER+
)
+ // }
+
+ let thresholdTable = [];
+ for (let i = 1; i < thresholds.length; i++) {
+ let lineThrough = {
+ color: "#828282",
+ textDecoration: "none",
+ textAlign: "center",
+ };
+ if (thresholds[i] === "-" && percentiles[intToTier(i)] === 0) {
+ lineThrough.textDecoration = "line-through";
+ } else {
+ lineThrough.color = "var(--type,#fff)";
+ }
- if (challenge.icon_2 === 0) {
- warnings.push(
This leaderboard is "technically" wrong, as the ranking still includes points from the seasonal 2023 challenges for some players, which should not be counted towards the total points.
);
- }
-
- // if (summoner.length === 0) {
- // warnings.push(
No high-ranked summoners yetDue to API limitations we can only show players ranked MASTER+
)
- // }
-
- let thresholdTable = []
- for (let i = 1; i < thresholds.length; i++) {
-
- let lineThrough = { color: "#828282", textDecoration: "none", textAlign: "center" };
- if (thresholds[i] === "-" && percentiles[intToTier(i)] === 0) {
- lineThrough.textDecoration = "line-through";
- } else {
- lineThrough.color = "var(--type,#fff)"
- }
-
- thresholdTable.unshift(
-
{strtoupper(t(strtolower(intToTier(i))))}
-
{beautifyNum(thresholds[i])}
-
{Math.round(percentiles[intToTier(i)] * 1000) / 10}%
-
)
+ thresholdTable.unshift(
+
+
+ {strtoupper(t(strtolower(intToTier(i))))}
+
+
{beautifyNum(thresholds[i])}
+
+ {Math.round(percentiles[intToTier(i)] * 1000) / 10}%
+
+
+ );
+ }
+
+ let content = (
+
+
-
-
- {challenge.challenge.translation.name}
-
- {challenge.challenge.translation.description} {challenge.timestamp
- ? ({t("Updated")} )
- :
- }
-
- {challenge.title.length > 0
- ?
- {challenge.title[0][1]}
-
- : null}
-
-
-
-
-
- start[filter]).join(" ")}>
- {filters}
-
-
-
-
-
-
-
{t("Thresholds")}
- {t("How many players have reached a tier")}
-
-
-
-
-
{t("Tier")}
-
{t("Points")}
-
%
-
-
- {thresholdTable}
-
-
-
- {warnings}
-
- {challenge.text !== false ?
-
-
{t("Info")}
- {t("All you need to know about this challenge")}
-
-
" + challenge.text.replace(/---\n/ig, "
").replace(/\n/g, " ") + "
" }}>
-
: null
- }
-
- {challenge.challenge.translation.name !== "Loading" ?
- : null}
-
- {/* FIX: Disabled since buggy */}
-
-
-
{t("Average Progress")}
- {t("Points per game")}
-
-
-
-
-
-
-
-
-
{t("\"{{challenge}}\" Leaderboard", { challenge: challenge.challenge.translation.name })}
- {this.state.filter === "world" ? t("Global Ranking") : t("Regional Ranking")}
-
-
-
-
- {t("Position")}
- {t("Summoner")}
- {t("Tier")}
- {t("Points")}
-
- {summoner}
-
-
-
- ;
-
- if (this.state.message !== -1) {
- content = this.state.message;
+ >
+
+
{challenge.challenge.translation.name}
+
+ {challenge.challenge.translation.description}{" "}
+ {challenge.timestamp ? (
+
+ ({t("Updated")}{" "}
+ )
+
+ ) : (
+
+ )}
+ {challenge.title.length > 0 ? (
+
+
+
+
+ {challenge.title[0][1]}
+
+
+ ) : null}
+
+
+
+
start[filter])
+ .join(" ")
}
-
- return
- {content}
-
- } catch (e) {
- console.warn(e);
- return an error occurred
- }
+ >
+ {filters}
+
+
+
+
+
+
{t("Thresholds")}
+ {t("How many players have reached a tier")}
+
+
+
+
{t("Tier")}
+
{t("Points")}
+
%
+
+
+ {thresholdTable}
+
+
+
+ {warnings}
+
+ {challenge.text !== false ? (
+
+
+
{t("Info")}
+
+ {" "}
+ {t("All you need to know about this challenge")}{" "}
+
+
+
" +
+ challenge.text
+ .replace(
+ /---\n/gi,
+ "
"
+ )
+ .replace(/\n/g, " ") +
+ "
",
+ }}
+ >
+
+ ) : null}
+
+ {challenge.challenge.translation.name !== "Loading" ? (
+
+ ) : null}
+
+ {/* FIX: Disabled since buggy */}
+
+
+
{t("Average Progress")}
+ {t("Points per game")}
+
+
+
+
+
+
+
+
+
+ {t('"{{challenge}}" Leaderboard', {
+ challenge: challenge.challenge.translation.name,
+ })}
+
+
+ {" "}
+ {this.state.filter === "world"
+ ? t("Global Ranking")
+ : t("Regional Ranking")}{" "}
+
+
+
+
+
+ {t("Position")}
+ {t("Summoner")}
+ {t("Tier")}
+ {t("Points")}
+
+ {summoner}
+
+
+
+
+ );
+
+ if (this.state.message !== -1) {
+ content = this.state.message;
+ }
+
+ return
{content} ;
+ } catch (e) {
+ console.warn(e);
+ return
an error occurred
;
}
+ }
}
-export default withTranslation()(Challenge)
\ No newline at end of file
+export default withTranslation()(Challenge);
diff --git a/src/module/Challenges.js b/src/module/Challenges.js
index dc02d53..8fd5e21 100644
--- a/src/module/Challenges.js
+++ b/src/module/Challenges.js
@@ -372,7 +372,8 @@ class Challenges extends Component {
if (
parentId !== 2022000 &&
parentId !== 2023000 &&
- parentId !== 2024100
+ parentId !== 2024100 &&
+ parentId !== 2024200
) {
continue;
}
@@ -612,12 +613,12 @@ class Challenges extends Component {
Legacy
-
+
- 2024.2 Seasonal
+ 2024.3 Seasonal
-
-
+ constructor(props) {
+ super(props);
+ this.challenges = props.content;
+ this.updateCompontent = this.updateCompontent.bind(this);
+ this.state = {
+ content:
,
+ };
+ }
+
+ componentDidMount() {
+ get(
+ "https://challenges.darkintaqt.com/api/v5/c/?id=2024300",
+ this.updateCompontent
+ );
+ }
+
+ updateCompontent(leaderboards) {
+ // console.log(leaderboards);
+
+ // let challenges = this.challenges
+
+ let regions = config.regions;
+ let summoner = [];
+ let counters = {};
+
+ for (let i = 0; i < regions.length; i++) {
+ for (let ii = 0; ii < leaderboards.summoner[regions[i]].length; ii++) {
+ if (!checkExists(counters[regions[i]])) {
+ counters[regions[i]] = 1;
}
+ leaderboards.summoner[regions[i]][ii].push(regions[i]);
+ leaderboards.summoner[regions[i]][ii].push(counters[regions[i]]);
+ summoner.push(leaderboards.summoner[regions[i]][ii]);
+ counters[regions[i]]++;
+ }
}
-
- componentDidMount() {
-
- get("https://challenges.darkintaqt.com/api/v5/c/?id=2024200", this.updateCompontent)
-
- }
-
- updateCompontent(leaderboards) {
-
- // console.log(leaderboards);
-
- // let challenges = this.challenges
-
- let regions = config.regions
- let summoner = []
- let counters = {};
-
- for (let i = 0; i < regions.length; i++) {
- for (let ii = 0; ii < leaderboards.summoner[regions[i]].length; ii++) {
- if (!checkExists(counters[regions[i]])) {
- counters[regions[i]] = 1
- }
- leaderboards.summoner[regions[i]][ii].push(regions[i])
- leaderboards.summoner[regions[i]][ii].push(counters[regions[i]])
- summoner.push(leaderboards.summoner[regions[i]][ii])
- counters[regions[i]]++
- }
-
+ summoner.sort((a, b) => {
+ if (a[1] === b[1]) {
+ if (b[5] === a[5]) {
+ return a[0] < b[0] ? -1 : +(a[0] > b[0]);
}
- summoner.sort((a, b) => {
- if (a[1] === b[1]) {
- if (b[5] === a[5]) {
- return a[0] < b[0] ? -1 : +(a[0] > b[0])
- }
- return a[5] - b[5]
- }
- return b[1] - a[1]
- });
-
- let topPlayer = []
-
- for (let i = 0; i < 5; i++) {
- const player = summoner[i];
- topPlayer.push(
- })
-
+ return a[5] - b[5];
+ }
+ return b[1] - a[1];
+ });
+
+ let topPlayer = [];
+
+ for (let i = 0; i < 5; i++) {
+ const player = summoner[i];
+ topPlayer.push(
+
+ );
}
-
- render() {
- return this.state.content
- }
-}
\ No newline at end of file
+ this.setState({
+ content: (
+
+ ),
+ });
+ }
+
+ render() {
+ return this.state.content;
+ }
+}
diff --git a/src/module/user/UserChallenges.js b/src/module/user/UserChallenges.js
index a900a0d..9d48044 100644
--- a/src/module/user/UserChallenges.js
+++ b/src/module/user/UserChallenges.js
@@ -1,466 +1,579 @@
import { Component, Fragment } from "react";
import config from "../../config";
-import filterCSS from "../../css/filter.module.css"
+import filterCSS from "../../css/filter.module.css";
import { setCookie } from "../../func/cookiefunctions";
-import { toggleValue } from "../../func/arrayManipulationFunctions.js"
+import { toggleValue } from "../../func/arrayManipulationFunctions.js";
import ChallengeObject from "../ChallengeObject";
-import challengeCSS from "../../css/challengeObject.module.css"
+import challengeCSS from "../../css/challengeObject.module.css";
-import { beautifyNum } from "../../func/beautify.js"
-import { checkExists } from "../../func/arrayManipulationFunctions.js"
+import { beautifyNum } from "../../func/beautify.js";
+import { checkExists } from "../../func/arrayManipulationFunctions.js";
import { intToTier } from "../../func/tierFunctions";
-import Timestamp from "react-timestamps"
+import Timestamp from "react-timestamps";
-import css from "../../css/user.module.css"
+import css from "../../css/user.module.css";
import orderChallenges, { getNextLevel } from "./orderChallenges";
-import Loader from "../Loader"
+import Loader from "../Loader";
import { withTranslation } from "react-i18next";
import { capitalize } from "../../func/stringManipulation";
import getChallenge from "../../func/getChallenge";
-import { getStorage, setStorage, storageKeys } from "../../func/sessionStorageFunctions";
-
+import {
+ getStorage,
+ setStorage,
+ storageKeys,
+} from "../../func/sessionStorageFunctions";
class UserChallenges extends Component {
- constructor(props) {
- super(props)
-
-
- this.changeFilter = this.changeFilter.bind(this)
- this.changeExtraFilter = this.changeExtraFilter.bind(this)
- this.toggleMasterTierSorting = this.toggleMasterTierSorting.bind(this)
- this.togglePointsAvailableSorting = this.togglePointsAvailableSorting.bind(this)
- this.toggleCapstones = this.toggleCapstones.bind(this);
-
- this.changeDisplayMethod = this.changeDisplayMethod.bind(this)
- this.search = this.search.bind(this);
-
- this.props = props;
-
- const filter = getStorage(storageKeys.userFilter, "level");
- const alphabet = filter === "alphabetic-a-z" ? "z-a" : "a-z";
-
- this.state = {
- alphabet,
- orderByMaster: getStorage(storageKeys.masterOnly, false),
- orderByPoints: getStorage(storageKeys.pointsOnly, false),
- capstones: getStorage(storageKeys.capstones, false),
- placeholder: window.compactMode,
- filter,
- filters: getStorage(storageKeys.userFilters, {
- "category": [],
- "type": [],
- "gamemode": [],
- }),
- translation: props.t,
- search: ""
- }
-
+ constructor(props) {
+ super(props);
+
+ this.changeFilter = this.changeFilter.bind(this);
+ this.changeExtraFilter = this.changeExtraFilter.bind(this);
+ this.toggleMasterTierSorting = this.toggleMasterTierSorting.bind(this);
+ this.togglePointsAvailableSorting =
+ this.togglePointsAvailableSorting.bind(this);
+ this.toggleCapstones = this.toggleCapstones.bind(this);
+
+ this.changeDisplayMethod = this.changeDisplayMethod.bind(this);
+ this.search = this.search.bind(this);
+
+ this.props = props;
+
+ const filter = getStorage(storageKeys.userFilter, "level");
+ const alphabet = filter === "alphabetic-a-z" ? "z-a" : "a-z";
+
+ this.state = {
+ alphabet,
+ orderByMaster: getStorage(storageKeys.masterOnly, false),
+ orderByPoints: getStorage(storageKeys.pointsOnly, false),
+ capstones: getStorage(storageKeys.capstones, false),
+ placeholder: window.compactMode,
+ filter,
+ filters: getStorage(storageKeys.userFilters, {
+ category: [],
+ type: [],
+ gamemode: [],
+ }),
+ translation: props.t,
+ search: "",
+ };
+ }
+
+ toggleMasterTierSorting() {
+ setStorage(storageKeys.masterOnly, !this.state.orderByMaster);
+
+ this.setState({
+ orderByMaster: !this.state.orderByMaster,
+ });
+ }
+
+ toggleCapstones() {
+ setStorage(storageKeys.capstones, !this.state.capstones);
+
+ this.setState({
+ capstones: !this.state.capstones,
+ });
+ }
+
+ togglePointsAvailableSorting() {
+ setStorage(storageKeys.pointsOnly, !this.state.orderByPoints);
+
+ this.setState({
+ orderByPoints: !this.state.orderByPoints,
+ });
+ }
+
+ changeFilter(e) {
+ const user = this.props.summoner;
+
+ if (user.challenges.length !== 0) {
+ const button = e.currentTarget;
+ const filter = this.state.filter;
+
+ if (filter === button.id) {
+ return;
+ }
+
+ if (filter === "alphabetic-a-z") {
+ document
+ .getElementById("alphabetic-z-a")
+ .classList.remove(filterCSS["selected"]);
+ } else if (filter === "alphabetic-z-a") {
+ document
+ .getElementById("alphabetic-a-z")
+ .classList.remove(filterCSS["selected"]);
+ } else {
+ document.getElementById(filter).classList.remove(filterCSS["selected"]);
+ }
+
+ button.classList.add(filterCSS["selected"]);
+
+ let tempFilter = button.id;
+ let alphabetVar = this.state.alphabet;
+
+ if (tempFilter === "alphabetic-a-z" && alphabetVar === "a-z") {
+ alphabetVar = "z-a";
+ }
+
+ if (tempFilter === "alphabetic-z-a" && alphabetVar === "z-a") {
+ alphabetVar = "a-z";
+ }
+
+ this.setState({ filter: tempFilter, alphabet: alphabetVar });
+ setStorage(storageKeys.userFilter, tempFilter);
}
-
- toggleMasterTierSorting() {
-
- setStorage(storageKeys.masterOnly, !this.state.orderByMaster);
-
- this.setState({
- orderByMaster: !this.state.orderByMaster
- })
+ }
+
+ changeExtraFilter(e) {
+ const user = this.props.summoner;
+ if (user.challenges.length !== 0) {
+ let filters = this.state.filters;
+
+ const toggle = toggleValue(
+ filters[e.currentTarget.getAttribute("type")],
+ e.currentTarget.id
+ );
+
+ if (toggle.method === true) {
+ e.currentTarget.classList.add(filterCSS["selected"]);
+ } else {
+ e.currentTarget.classList.remove(filterCSS["selected"]);
+ }
+
+ this.setState({ filters: filters });
+ setStorage(storageKeys.userFilters, filters);
}
-
- toggleCapstones() {
-
- setStorage(storageKeys.capstones, !this.state.capstones);
-
- this.setState({
- capstones: !this.state.capstones
- })
-
+ }
+
+ changeDisplayMethod() {
+ setCookie("filter", JSON.stringify(!this.state.placeholder));
+ window.compactMode = !this.state.placeholder;
+ this.setState({ placeholder: !this.state.placeholder });
+ }
+
+ search(e) {
+ this.setState({ search: e.currentTarget.value });
+ }
+
+ componentDidUpdate() {
+ const filters = [
+ this.state.filter,
+ ...Object.values(this.state.filters).flat(),
+ ];
+
+ for (const id of filters) {
+ if (document.getElementById(id)) {
+ document.getElementById(id).classList.add(filterCSS["selected"]);
+ }
}
-
- togglePointsAvailableSorting() {
-
- setStorage(storageKeys.pointsOnly, !this.state.orderByPoints);
-
- this.setState({
- orderByPoints: !this.state.orderByPoints
- })
+ }
+
+ render() {
+ const t = this.state.translation;
+ const user = JSON.parse(JSON.stringify(this.props.summoner));
+
+ if (user.challenges.length === 0) {
+ return (
+
+ );
}
-
- changeFilter(e) {
- const user = this.props.summoner
-
- if (user.challenges.length !== 0) {
-
- const button = e.currentTarget
- const filter = this.state.filter
-
- if (filter === button.id) {
- return
- }
-
- if (filter === "alphabetic-a-z") {
- document.getElementById("alphabetic-z-a").classList.remove(filterCSS["selected"])
- } else if (filter === "alphabetic-z-a") {
- document.getElementById("alphabetic-a-z").classList.remove(filterCSS["selected"])
- } else {
- document.getElementById(filter).classList.remove(filterCSS["selected"])
- }
-
- button.classList.add(filterCSS["selected"])
-
- let tempFilter = button.id
- let alphabetVar = this.state.alphabet
-
- if (tempFilter === "alphabetic-a-z" && alphabetVar === "a-z") {
- alphabetVar = "z-a"
- }
-
- if (tempFilter === "alphabetic-z-a" && alphabetVar === "z-a") {
- alphabetVar = "a-z"
-
- }
-
- this.setState({ filter: tempFilter, alphabet: alphabetVar })
- setStorage(storageKeys.userFilter, tempFilter);
-
+ document.title = `${user.summonerName}'s Challenge Progress Overview`;
+
+ const server = this.props.server;
+
+ const filter = this.state.filter;
+
+ let challengesOrdered = orderChallenges(
+ user.challenges,
+ this.state.filter,
+ this.state.filters,
+ this.state.orderByMaster,
+ this.state.orderByPoints,
+ this.state.search,
+ this.state.capstones
+ );
+
+ let challenges = challengesOrdered
+ .map((challenge) => {
+ if (challenge[0] !== 0 && challenge[0] < 10) {
+ return null;
}
- }
-
-
- changeExtraFilter(e) {
-
-
-
- const user = this.props.summoner
- if (user.challenges.length !== 0) {
-
- let filters = this.state.filters
-
- const toggle = toggleValue(filters[e.currentTarget.getAttribute("type")], e.currentTarget.id)
-
- if (toggle.method === true) {
-
- e.currentTarget.classList.add(filterCSS["selected"])
-
- } else {
-
- e.currentTarget.classList.remove(filterCSS["selected"])
-
- }
-
- this.setState({ filters: filters })
- setStorage(storageKeys.userFilters, filters);
+ const tier = intToTier(challenge[1]);
+
+ let leaderboardposition = "";
+ let position,
+ next,
+ previousPositions = 1;
+ let nexttier = getNextLevel(tier);
+
+ const c = challenge[6];
+
+ if (c.leaderboard === true && challenge[5].length > 1) {
+ switch (tier) {
+ case "GRANDMASTER":
+ previousPositions = c["leaderboardThresholds"][3] ?? 1;
+ break;
+ case "MASTER":
+ previousPositions = c["leaderboardThresholds"][5] ?? 1;
+ break;
+ default:
+ previousPositions = 1;
+ break;
+ }
+ position =
+ "#" + beautifyNum(previousPositions - 1 + challenge[5][1], false);
+
+ if (challenge[5][1] <= 100 && challenge[5].length === 4) {
+ position = position + " (#" + challenge[5][3] + " World)";
+ }
+ position += " - ";
}
- }
-
- changeDisplayMethod() {
- setCookie("filter", JSON.stringify(!this.state.placeholder));
- window.compactMode = !this.state.placeholder
- this.setState({ placeholder: !this.state.placeholder });
- }
-
- search(e) {
- this.setState({ search: e.currentTarget.value })
- }
-
- componentDidUpdate() {
- const filters = [this.state.filter, ...Object.values(this.state.filters).flat()];
-
- for (const id of filters) {
- if (document.getElementById(id)) {
- document.getElementById(id).classList.add(filterCSS["selected"]);
- }
- }
- }
-
-
- render() {
-
- const t = this.state.translation
- const user = JSON.parse(JSON.stringify(this.props.summoner));
-
- if (user.challenges.length === 0) {
-
- return
+ if (this.state.orderByMaster === true) {
+ nexttier = "MASTER";
}
- document.title = `${user.summonerName}'s Challenge Progress Overview`
-
- const server = this.props.server
-
- const filter = this.state.filter
-
-
- let challengesOrdered = orderChallenges(user.challenges, this.state.filter, this.state.filters, this.state.orderByMaster, this.state.orderByPoints, this.state.search, this.state.capstones)
-
-
- let challenges = challengesOrdered.map((challenge) => {
-
- if (challenge[0] !== 0 && challenge[0] < 10) {
- return null
- }
-
- const tier = intToTier(challenge[1])
-
- let leaderboardposition = ""
- let position, next, previousPositions = 1;
- let nexttier = getNextLevel(tier)
-
- const c = challenge[6]
-
-
- if (c.leaderboard === true && challenge[5].length > 1) {
- switch (tier) {
- case "GRANDMASTER":
- previousPositions = c["leaderboardThresholds"][3] ?? 1
- break;
- case "MASTER":
- previousPositions = c["leaderboardThresholds"][5] ?? 1
- break;
- default:
- previousPositions = 1
- break;
- }
- position = "#" + beautifyNum((previousPositions - 1) + challenge[5][1], false);
- if (challenge[5][1] <= 100 && challenge[5].length === 4) {
+ next = 1;
+ if (checkExists(c["thresholds"][nexttier])) {
+ next = c["thresholds"][nexttier];
+ } else if (!checkExists(c["thresholds"][tier])) {
+ let stop = false;
+ let i = 0;
- position = position + " (#" + challenge[5][3] + " World)";
- }
- position += " - ";
-
- }
-
- if (this.state.orderByMaster === true) {
- nexttier = "MASTER"
- }
-
- next = 1
+ while (stop === false && i < 10) {
+ i++;
+ nexttier = getNextLevel(nexttier);
if (checkExists(c["thresholds"][nexttier])) {
- next = c["thresholds"][nexttier]
- } else if (!checkExists(c["thresholds"][tier])) {
-
- let stop = false;
- let i = 0;
-
- while (stop === false && i < 10) {
- i++;
- nexttier = getNextLevel(nexttier);
- if (checkExists(c["thresholds"][nexttier])) {
- next = c["thresholds"][nexttier]
- stop = true;
- }
-
- if (nexttier === "CHALLENGER") {
- stop = true;
- }
- }
- } else {
- next = c["thresholds"][tier]
- }
-
- if (tier === "CHALLENGER" && this.state.orderByMaster === false) {
- if (c.leaderboard === true) {
- // leaderboards, not #1
- next = c["leaderboardThresholds"][0] ?? 0
- nexttier = "CROWN";
- } else {
- // No leaderboards, so maxed
- nexttier = "MAXED"
- }
- if ((previousPositions - 1) + challenge[5][1] === 1) {
- // leaderboards, #1
- nexttier = "FIRST";
- }
- }
-
- let tags = []
-
- if (checkExists(challenge[8])) {
- tags.push(
)
- }
-
- if (checkExists(challenge[7]) && challenge[7] !== "none") {
- tags.push(
)
+ next = c["thresholds"][nexttier];
+ stop = true;
}
-
-
-
- if (filter === "timestamp") {
- leaderboardposition =
+ if (nexttier === "CHALLENGER") {
+ stop = true;
}
+ }
+ } else {
+ next = c["thresholds"][tier];
+ }
+ if (tier === "CHALLENGER" && this.state.orderByMaster === false) {
+ if (c.leaderboard === true) {
+ // leaderboards, not #1
+ next = c["leaderboardThresholds"][0] ?? 0;
+ nexttier = "CROWN";
+ } else {
+ // No leaderboards, so maxed
+ nexttier = "MAXED";
+ }
+ if (previousPositions - 1 + challenge[5][1] === 1) {
+ // leaderboards, #1
+ nexttier = "FIRST";
+ }
+ }
- return
- })?.filter(x => x !== null)
+ let tags = [];
+
+ if (checkExists(challenge[8])) {
+ tags.push(
+
+ );
+ }
+ if (checkExists(challenge[7]) && challenge[7] !== "none") {
+ tags.push(
);
+ }
- if (challenges.length === 0) {
- challenges =
+ if (filter === "timestamp") {
+ leaderboardposition = (
+
+ );
+ } else {
+ leaderboardposition = (
+