Skip to content

Commit

Permalink
Every exercise type has its own URL anchor-hash now
Browse files Browse the repository at this point in the history
  • Loading branch information
kyletimmermans committed Oct 2, 2024
1 parent 1e7ad50 commit aa272ac
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 19 deletions.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@
</script>
</body>

</html>
</html>
69 changes: 66 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,59 @@ var jsonCompare, jsonShortFormAdj;
var correctAnswer, fetchList = [];


// Start with verbs on site load
// Anchor-Hash tag handling
// Go to specified exercise on load (verb() default if none chosen)
document.addEventListener("DOMContentLoaded", (event) => {
verb();
let anchorHash = window.location.hash.toLowerCase();

switch (anchorHash) {
case "#verbs":
verb();
break;
case "#singular-nouns":
singNoun();
break;
case "#plural-nouns":
plurNoun();
break;
case "#singular-adjectives":
singAdj();
break;
case "#plural-adjectives":
plurAdj();
break;
case "#pronouns":
pronoun();
break;
case "#possessive-pronouns":
possessive();
break;
case "#demonstratives":
demonstrative();
break;
case "#question-words":
questionWord();
break;
case "#comparatives":
comparative();
break;
case "#short-form-adjectives":
shortFormAdj();
break;
case "#about":
var modal = new bootstrap.Modal(document.getElementById("aboutModal"));
var dropdown = new bootstrap.Dropdown(document.getElementById("dropdownMenu2"));
dropdown.hide();
modal.show();
break
case "#exercises":
var modal = new bootstrap.Modal(document.getElementById("aboutModal"));
var dropdown = new bootstrap.Dropdown(document.getElementById("dropdownMenu2"));
modal.hide();
dropdown.show();
default:
verb();
}
});


Expand Down Expand Up @@ -376,11 +426,14 @@ const randomShortFormAdj = (data) => {
};


// Split point from random generators to fetchers \\
// ######################################################
// ### Split point from random generators to fetchers ###
// ######################################################


const verb = () => {
document.querySelector("#centered-title").textContent = "Verb Conjugations";
window.location.hash = "#verbs"
var isError = false;

if (fetchList.includes("verb") == false) {
Expand Down Expand Up @@ -421,6 +474,7 @@ const verb = () => {

const singNoun = () => {
document.querySelector("#centered-title").textContent = "Singular Noun Cases";
window.location.hash = "#singular-nouns"
var isError = false;

if (fetchList.includes("noun") == false) {
Expand Down Expand Up @@ -475,6 +529,7 @@ const singNoun = () => {

const plurNoun = () => {
document.querySelector("#centered-title").textContent = "Plural Noun Cases";
window.location.hash = "#plural-nouns"
var isError = false;

if (fetchList.includes("noun") == false) {
Expand Down Expand Up @@ -527,6 +582,7 @@ const plurNoun = () => {

const singAdj = () => {
document.querySelector("#centered-title").textContent = "Singular Adjective Cases";
window.location.hash = "#singular-adjectives"
var isError = false;

if (fetchList.includes("adj") == false) {
Expand Down Expand Up @@ -568,6 +624,7 @@ const singAdj = () => {

const plurAdj = () => {
document.querySelector("#centered-title").textContent = "Plural Adjective Cases";
window.location.hash = "#plural-adjectives"
var isError = false;

if (fetchList.includes("adj") == false) {
Expand Down Expand Up @@ -608,6 +665,7 @@ const plurAdj = () => {

const pronoun = () => {
document.querySelector("#centered-title").textContent = "Pronoun Cases";
window.location.hash = "#pronouns"
var isError = false;

if (fetchList.includes("pro") == false) {
Expand Down Expand Up @@ -667,6 +725,7 @@ const pronoun = () => {

const possessive = () => {
document.querySelector("#centered-title").textContent = "Possessive Pronoun + Сам Cases";
window.location.hash = "#possessive-pronouns"
var isError = false;

if (fetchList.includes("poss") == false) {
Expand Down Expand Up @@ -705,6 +764,7 @@ const possessive = () => {

const demonstrative = () => {
document.querySelector("#centered-title").textContent = "Demonstrative + Весь Cases";
window.location.hash = "#demonstratives"
var isError = false;

if (fetchList.includes("demo") == false) {
Expand Down Expand Up @@ -743,6 +803,7 @@ const demonstrative = () => {

const questionWord = () => {
document.querySelector("#centered-title").textContent = "Question Word Cases";
window.location.hash = "#question-words"
var isError = false;

if (fetchList.includes("ques") == false) {
Expand Down Expand Up @@ -791,6 +852,7 @@ const questionWord = () => {

const comparative = () => {
document.querySelector("#centered-title").textContent = "Comparative Creation";
window.location.hash = "#comparatives"
var isError = false;

if (fetchList.includes("comp") == false) {
Expand Down Expand Up @@ -831,6 +893,7 @@ const comparative = () => {

const shortFormAdj = () => {
document.querySelector("#centered-title").textContent = "Short Form Adjectives";
window.location.hash = "#short-form-adjectives"
var isError = false;

if (fetchList.includes("shortFormAdj") == false) {
Expand Down
11 changes: 0 additions & 11 deletions assets/js/anchor-hash.js

This file was deleted.

2 changes: 0 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ <h1 class="col" id="centered-title"><b>Verb Conjugations</b></h1>
});
</script>

<script type="text/javascript" src="/assets/js/anchor-hash.js"></script>

<script>console.log("%cNo Cheating :)", "background: rgba(13, 202, 240, 0.5);");</script>
</body>

Expand Down
2 changes: 0 additions & 2 deletions mobile/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,6 @@ <h1 class="col" id="centered-title"><b>Verb Conjugations</b></h1>
</div>
</div>

<script type="text/javascript" src="/assets/js/anchor-hash.js"></script>

<script>console.log("%cNo Cheating :)", "background: rgba(13, 202, 240, 0.5);");</script>
</body>

Expand Down

0 comments on commit aa272ac

Please sign in to comment.