Change challenge location has to include and work off of challenge ID (#1522)

* Adds challenge ID into location hashes so that the right challenge is always loaded regardless of duplicate names
* Closes #1120
This commit is contained in:
Kevin Chung
2020-06-30 03:27:47 -04:00
committed by GitHub
parent c9442037a8
commit 3716904e77
7 changed files with 19 additions and 8 deletions

View File

@@ -34,8 +34,11 @@ const loadChal = id => {
};
const loadChalByName = name => {
const chal = $.grep(challenges, chal => chal.name == name)[0];
let idx = name.lastIndexOf("-");
let pieces = [name.slice(0, idx), name.slice(idx + 1)];
let id = pieces[1];
const chal = $.grep(challenges, chal => chal.id == id)[0];
displayChal(chal);
};
@@ -118,7 +121,7 @@ const displayChal = chal => {
challenge.postRender();
window.location.replace(
window.location.href.split("#")[0] + "#" + chal.name
window.location.href.split("#")[0] + `#${chal.name}-${chal.id}`
);
$("#challenge-window").modal();
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -257,7 +257,9 @@
{% for solve in solves %}
<tr>
<td>
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}">{{ solve.challenge.name }}</a>
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}-{{ solve.challenge.id }}">
{{ solve.challenge.name }}
</a>
</td>
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
<td>{{ solve.challenge.value }}</td>

View File

@@ -154,7 +154,9 @@
{% for solve in solves %}
<tr>
<td>
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}">{{ solve.challenge.name }}</a>
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}-{{ solve.challenge.id }}">
{{ solve.challenge.name }}
</a>
</td>
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
<td>{{ solve.challenge.value }}</td>

View File

@@ -121,7 +121,9 @@
{% for solve in user.solves %}
<tr>
<td>
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}">{{ solve.challenge.name }}</a>
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}-{{ solve.challenge.id }}">
{{ solve.challenge.name }}
</a>
</td>
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
<td>{{ solve.challenge.value }}</td>

View File

@@ -121,7 +121,9 @@
{% for solve in user.solves %}
<tr>
<td>
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}">{{ solve.challenge.name }}</a>
<a href="{{ url_for('challenges.listing') }}#{{ solve.challenge.name }}-{{ solve.challenge.id }}">
{{ solve.challenge.name }}
</a>
</td>
<td class="d-none d-md-block d-lg-block">{{ solve.challenge.category }}</td>
<td>{{ solve.challenge.value }}</td>