Upgrade template to v3

This commit is contained in:
Florine W. Dekker 2022-11-21 23:05:16 +01:00
parent 458b88159c
commit 66048b94d2
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
4 changed files with 49 additions and 53 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{ {
"name": "debreviator", "name": "debreviator",
"version": "0.0.4", "version": "0.0.5",
"description": "Creates meaning by undoing your abbreviation.", "description": "Creates meaning by undoing your abbreviation.",
"author": "Florine W. Dekker", "author": "Florine W. Dekker",
"browser": "dist/bundle.js", "browser": "dist/bundle.js",
@ -16,15 +16,15 @@
"deploy": "grunt deploy" "deploy": "grunt deploy"
}, },
"devDependencies": { "devDependencies": {
"grunt": "^1.4.1", "grunt": "^1.5.3",
"grunt-cli": "^1.4.3", "grunt-cli": "^1.4.3",
"grunt-contrib-clean": "^2.0.0", "grunt-contrib-clean": "^2.0.1",
"grunt-contrib-copy": "^1.0.0", "grunt-contrib-copy": "^1.0.0",
"grunt-contrib-watch": "^1.1.0", "grunt-contrib-watch": "^1.1.0",
"grunt-focus": "^1.0.0", "grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0", "grunt-text-replace": "^0.4.0",
"grunt-webpack": "^5.0.0", "grunt-webpack": "^5.0.0",
"webpack": "^5.69.1", "webpack": "^5.75.0",
"webpack-cli": "^4.9.2" "webpack-cli": "^5.0.0"
} }
} }

View File

@ -8,17 +8,24 @@
<meta name="description" content="Creates meaning by undoing your abbreviation." /> <meta name="description" content="Creates meaning by undoing your abbreviation." />
<meta name="theme-color" content="#0033cc" /> <meta name="theme-color" content="#0033cc" />
<meta name="fwd:nav:target" content="#nav" />
<!-- TODO: Remove from [Experimental] once the tool is mature -->
<meta name="fwd:nav:highlight-path" content="/Tools/[Experimental]/Debreviator/" />
<meta name="fwd:footer:target" content="#footer" />
<meta name="fwd:footer:vcs-url" content="https://git.fwdekker.com/tools/debreviator/" />
<meta name="fwd:footer:version" content="v%%VERSION_NUMBER%%" />
<meta name="fwd:validation:load-forms" />
<title>Debreviator | FWDekker</title> <title>Debreviator | FWDekker</title>
<link rel="stylesheet" href="https://static.fwdekker.com/fonts/roboto/roboto.css" /> <link rel="stylesheet" href="https://static.fwdekker.com/lib/template/3.x.x/template.css?v=%%VERSION_NUMBER%%" />
<link rel="stylesheet" href="https://static.fwdekker.com/lib/template/2.x.x/template.css" />
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<link rel="stylesheet" href="main.css?v=%%VERSION_NUMBER%%" /> <link rel="stylesheet" href="main.css?v=%%VERSION_NUMBER%%" />
<script async src="https://stats.fwdekker.com/count.js" <script async src="https://stats.fwdekker.com/count.js"
data-goatcounter="https://stats.fwdekker.com/count"></script> data-goatcounter="https://stats.fwdekker.com/count"></script>
</head> </head>
<body> <body>
<noscript> <noscript class="fwd-js-notice">
<img src="https://stats.fwdekker.com/count?p=/tools/debreviator/" alt="Counting pixel" /> <img src="https://stats.fwdekker.com/count?p=/tools/debreviator/" alt="Counting pixel" />
<p> <p>
@ -27,35 +34,33 @@
instructions on how to enable JavaScript in your web browser</a>. instructions on how to enable JavaScript in your web browser</a>.
</p> </p>
</noscript> </noscript>
<main class="hidden"> <nav id="nav"></nav>
<div id="nav"></div> <main class="container hidden">
<div id="contents"> <div role="document">
<div id="header"></div> <section>
<header class="fwd-header">
<hgroup>
<h1><a href=".">Debreviator</a></h1>
<h2>Creates meaning by undoing your abbreviation.</h2>
</hgroup>
</header>
<section class="container"> <form id="debreviate-form">
<div class="row"> <label for="abbreviation">Abbreviation</label>
<div class="column"> <input id="abbreviation" type="text" autofocus />
<label for="abbreviation">Abbreviation</label> <small id="abbreviation-hint" data-hint-for="abbreviation"></small>
<input id="abbreviation" type="text" autofocus />
<button id="debreviate" type="button">Debreviate</button> <button id="debreviate" type="button">Debreviate</button>
</div> </form>
</div>
<br />
<div class="row"> <label for="debreviations">Debreviations</label>
<div class="column"> <textarea id="debreviations" readonly></textarea>
<label for="debreviations">Debreviations</label>
<span id="abbreviation-error"></span>
<textarea id="debreviations" readonly></textarea>
</div>
</div>
</section> </section>
<footer id="footer"></footer>
</div> </div>
<div id="footer"></div>
</main> </main>
<script src="https://static.fwdekker.com/lib/template/2.x.x/template.js"></script> <script src="https://static.fwdekker.com/lib/template/3.x.x/template.js?v=%%VERSION_NUMBER%%"></script>
<!--suppress HtmlUnknownTarget --> <!--suppress HtmlUnknownTarget -->
<script src="bundle.js?v=%%VERSION_NUMBER%%"></script> <script src="bundle.js?v=%%VERSION_NUMBER%%"></script>
</body> </body>

View File

@ -1,5 +1,7 @@
// noinspection JSUnresolvedVariable // noinspection JSUnresolvedVariable
const {$, doAfterLoad, footer, header, nav} = window.fwdekker; const {$, doAfterLoad} = window.fwdekker;
// noinspection JSUnresolvedVariable
const {clearFormValidity, showInputInvalid} = window.fwdekker.validation;
function toUppercaseAt(string, index) { function toUppercaseAt(string, index) {
@ -8,23 +10,9 @@ function toUppercaseAt(string, index) {
doAfterLoad(() => { doAfterLoad(() => {
$("#nav").appendChild(nav("/Tools/Debreviator/")); const debreviateForm = $("#debreviate-form");
$("#header").appendChild(header({
title: "Debreviator",
description: "Creates meaning by undoing your abbreviation"
}));
$("#footer").appendChild(footer({
vcsURL: "https://git.fwdekker.com/tools/debreviator/",
version: "v%%VERSION_NUMBER%%"
}));
$("main").classList.remove("hidden");
$("[autofocus]").focus();
});
doAfterLoad(() => {
const abbreviationInput = $("#abbreviation"); const abbreviationInput = $("#abbreviation");
const abbreviationError = $("#abbreviation-error"); const abbreviationError = $("#abbreviation-error");
const debreviateButton = $("#debreviate");
const debreviationOutput = $("#debreviations"); const debreviationOutput = $("#debreviations");
@ -39,9 +27,10 @@ doAfterLoad(() => {
}; };
const debreviate = () => { const debreviate = () => {
clearFormValidity(debreviateForm);
const abbreviation = abbreviationInput.value.trim(); const abbreviation = abbreviationInput.value.trim();
if (abbreviation === "") { if (abbreviation === "") {
showError("Abbreviation should be non-empty."); showInputInvalid(abbreviationInput, "Abbreviation should be non-empty.");
return; return;
} }
@ -75,11 +64,13 @@ doAfterLoad(() => {
}); });
}; };
debreviateButton.addEventListener("click", debreviate); debreviateForm.addEventListener("submit", event => {
abbreviationInput.addEventListener("keypress", event => { event.preventDefault();
if (event.key === "Enter") { debreviate();
debreviate();
event.preventDefault();
}
}); });
// Show page to user
$("main").classList.remove("hidden");
$("[autofocus]").focus();
}); });