Skip to content

Commit

Permalink
tweak conjugator for searchbox support
Browse files Browse the repository at this point in the history
  • Loading branch information
sandervonk committed Sep 2, 2022
1 parent 877190b commit 55206d8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
18 changes: 17 additions & 1 deletion app/conjugator.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<link rel="shortcut icon" href="//sander.vonk.one/VITE/img/icon/app/icon-512x512.png" type="image/png" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="google" content="notranslate" />
<meta name="waitforload" content="true" />
<meta name="runsetup" content="true" />
<meta name="noauthenforce" content="true" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
Expand Down Expand Up @@ -58,6 +57,23 @@
<meta name="og:url" content="/VITE/app/conjugator.html" />
<meta name="og:site_name" content="VITE! French Conjugation" />
<meta name="og:type" content="website" />
<!-- search results searchbox support -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebSite",
"name": "VITE! French Practice - Conjugator",
"url": "https://sander.vonk.one/VITE/",
"potentialAction": {
"@type": "SearchAction",
"target": {
"@type": "EntryPoint",
"urlTemplate": "https://sander.vonk.one/VITE/app/conjugator.html?verb={search_term_string}&tense=present"
},
"query-input": "required name=search_term_string"
}
}
</script>
<!-- Analytics!! -->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="//www.googletagmanager.com/gtag/js?id=G-5GF8MRX85G"></script>
Expand Down
22 changes: 13 additions & 9 deletions js/conjugator.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,16 @@ function fillConjugations() {
}
}
$("#search-options").on("change", fillConjugations);

function setupApp() {
return new Promise((resolved, rejected) => {
$.getJSON("/VITE/verbs.json")
.done(function (response) {
verbs = response;
setupVerbDropdown(verbs)
.then(() => {
if (params && params.get("verb") && $("#conjugator-verb").has(`option[value="${params.get("verb")}"]`)) {
$("#conjugator-verb").val(params.get("verb"));
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
if (params && params.get("verb") && $("#conjugator-verb").has(`option[value="${capitalizeFirstLetter(params.get("verb"))}"]`)) {
$("#conjugator-verb").val(capitalizeFirstLetter(params.get("verb")));
}
if (params && params.get("tense") && $("#conjugator-tense").has(`option[value="${params.get("tense")}"]`)) {
$("#conjugator-tense").val(params.get("tense"));
Expand All @@ -54,14 +57,15 @@ function setupApp() {

$("#prev-button").click(changeVerb(-1));
$("#next-button").click(changeVerb(1));

resolved();
})
.catch((err) => {
rejected(err);
console.error(err);
});
})
.fail(function (err) {
console.error("Could not load verbs.json :(", err);
});
}

$("#explanation-button").click(() => {
let newStorage;
try {
Expand Down

0 comments on commit 55206d8

Please sign in to comment.