Upgrade template to v3

This commit is contained in:
Florine W. Dekker 2022-11-21 22:27:58 +01:00
parent 1f65d60675
commit 5470eb3c7a
Signed by: FWDekker
GPG Key ID: D3DCFAA8A4560BE0
4 changed files with 34 additions and 45 deletions

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "converter",
"version": "1.4.12",
"version": "1.4.13",
"description": "Convert numbers to and from various bases.",
"author": "Florine W. Dekker",
"browser": "dist/bundle.js",
@ -19,15 +19,15 @@
"big-integer": "^1.6.51"
},
"devDependencies": {
"grunt": "^1.4.1",
"grunt": "^1.5.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-watch": "^1.1.0",
"grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0",
"grunt-webpack": "^5.0.0",
"webpack": "^5.69.1",
"webpack-cli": "^4.9.2"
"webpack": "^5.75.0",
"webpack-cli": "^5.0.0"
}
}

View File

@ -8,15 +8,20 @@
<meta name="description" content="Convert numbers to and from various bases." />
<meta name="theme-color" content="#0033cc" />
<meta name="fwd:nav:target" content="#nav" />
<meta name="fwd:nav:highlight-path" content="/Tools/Converter/" />
<meta name="fwd:footer:target" content="#footer" />
<meta name="fwd:footer:vcs-url" content="https://git.fwdekker.com/tools/converter/" />
<meta name="fwd:footer:version" content="v%%VERSION_NUMBER%%" />
<title>Converter | FWDekker</title>
<link rel="stylesheet" href="https://static.fwdekker.com/fonts/roboto/roboto.css" />
<link rel="stylesheet" href="https://static.fwdekker.com/lib/template/2.x.x/template.css" />
<link rel="stylesheet" href="https://static.fwdekker.com/lib/template/3.x.x/template.css?v=%%VERSION_NUMBER%%" />
<script async src="https://stats.fwdekker.com/count.js"
data-goatcounter="https://stats.fwdekker.com/count"></script>
</head>
<body>
<noscript>
<noscript class="fwd-js-notice">
<img src="https://stats.fwdekker.com/count?p=/tools/converter/" alt="Counting pixel" />
<p>
@ -25,27 +30,26 @@
instructions on how to enable JavaScript in your web browser</a>.
</p>
</noscript>
<main class="hidden">
<div id="nav"></div>
<div id="contents">
<div id="header"></div>
<nav id="nav"></nav>
<main class="container hidden">
<div role="document">
<section>
<header class="fwd-header">
<hgroup>
<h1><a href=".">Converter</a></h1>
<h2>Convert numbers to and from various bases.</h2>
</hgroup>
</header>
<!-- Input -->
<section class="container">
<div class="row">
<div class="column">
<form>
<fieldset id="inputs">
</fieldset>
</form>
</div>
</div>
<form>
<fieldset id="inputs"></fieldset>
</form>
</section>
<footer id="footer"></footer>
</div>
<div id="footer"></div>
</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 -->
<script src="bundle.js?v=%%VERSION_NUMBER%%"></script>
</body>

View File

@ -1,5 +1,5 @@
// noinspection JSUnresolvedVariable
const {$, doAfterLoad, footer, header, nav} = window.fwdekker;
const {$, doAfterLoad} = window.fwdekker;
import bigInt from "big-integer"
@ -12,7 +12,7 @@ import bigInt from "big-integer"
* @returns {string} the input string with one character replaced
*/
const stringReplaceAt = (str, index, replacement) =>
str.substr(0, index) + replacement + str.substr(index + replacement.length);
str.substring(0, index) + replacement + str.substring(index + replacement.length);
/**
* Replaces all instances of the target with the replacement.
@ -149,15 +149,12 @@ class Base64NumeralSystemInput extends NumeralSystemInput {
super(name, new Base64NumeralSystem(Base64NumeralSystem.defaultAlphabet()));
this.dropdown = document.createElement("select");
this.dropdown.id = `${this.name}Dropdown`;
this.dropdown.id = `${this.name}-dropdown`;
this.dropdown.onchange = () => {
const selectedOption = Base64NumeralSystemInput.dropdownOptions()[this.dropdown.value];
this.setLastDigits(selectedOption[0], selectedOption[1]);
};
this.dropdownDiv = document.createElement("div");
this.dropdownDiv.classList.add("float-right");
this.options =
Object.keys(Base64NumeralSystemInput.dropdownOptions()).map(key => {
const option = document.createElement("option");
@ -180,10 +177,9 @@ class Base64NumeralSystemInput extends NumeralSystemInput {
addToParent(parent) {
this.options.forEach(option => this.dropdown.appendChild(option));
this.dropdownDiv.appendChild(this.dropdown);
parent.appendChild(this.dropdownDiv);
parent.appendChild(this.label);
parent.appendChild(this.dropdown);
parent.appendChild(this.textarea);
}
}
@ -213,19 +209,6 @@ const updateAllInputs = (source, newValue) => {
};
doAfterLoad(() => {
$("#nav").appendChild(nav("/Tools/Converter/"));
$("#header").appendChild(header({
title: "Converter",
description: "Convert numbers to and from various bases"
}));
$("#footer").appendChild(footer({
vcsURL: "https://git.fwdekker.com/tools/converter/",
version: "v%%VERSION_NUMBER%%"
}));
$("main").classList.remove("hidden");
});
doAfterLoad(() => {
const inputParent = $("#inputs");
@ -234,4 +217,6 @@ doAfterLoad(() => {
updateAllInputs(undefined, bigInt(42));
inputs[0].textarea.focus();
$("main").classList.remove("hidden");
});