Remove inline styles and scripts

This commit is contained in:
Florine W. Dekker 2021-04-28 13:11:29 +02:00
parent c908afeb42
commit 0e3d3b0adc
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
6 changed files with 36 additions and 18 deletions

View File

@ -7,6 +7,9 @@ module.exports = grunt => {
default: ["dist/"],
},
copy: {
css: {
files: [{expand: true, cwd: "src/main/", src: "**/*.css", dest: "dist/", flatten: true}]
},
db: {
files: [{expand: true, cwd: "src/main/", src: "**/.*.db", dest: "dist/", flatten: true}]
},
@ -19,12 +22,12 @@ module.exports = grunt => {
},
focus: {
dev: {
include: ["html", "js", "php"],
include: ["css", "html", "js", "php"],
},
},
replace: {
dev: {
src: ["./dist/*.html", "./dist/*.js"],
src: ["./dist/**/*.html", "./dist/**/*.js"],
replacements: [
{
from: "%%VERSION_NUMBER%%",
@ -45,6 +48,10 @@ module.exports = grunt => {
},
},
watch: {
css: {
files: ["src/main/**/*.css"],
tasks: ["copy:css"],
},
html: {
files: ["src/main/**/*.html"],
tasks: ["copy:html"],
@ -98,6 +105,7 @@ module.exports = grunt => {
// Pre
"clean",
// Copy files
"copy:css",
"copy:db",
"copy:html",
"copy:php",
@ -110,6 +118,7 @@ module.exports = grunt => {
// Pre
"clean",
// Copy files
"copy:css",
"copy:db",
"copy:html",
"copy:php",

BIN
package-lock.json generated

Binary file not shown.

View File

@ -1,6 +1,6 @@
{
"name": "random-fo76",
"version": "1.0.15",
"version": "1.0.16",
"description": "Random Fallout 76 record.",
"author": "Felix W. Dekker",
"browser": "dist/bundle.js",
@ -16,7 +16,7 @@
"deploy": "grunt deploy"
},
"devDependencies": {
"grunt": "^1.3.0",
"grunt": "^1.4.0",
"grunt-cli": "^1.4.2",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-copy": "^1.0.0",
@ -24,7 +24,7 @@
"grunt-focus": "^1.0.0",
"grunt-text-replace": "^0.4.0",
"grunt-webpack": "^4.0.3",
"webpack": "^5.33.2",
"webpack": "^5.36.0",
"webpack-cli": "^4.6.0"
}
}

7
src/main/css/main.css Normal file
View File

@ -0,0 +1,7 @@
table#metadata {
max-width: 300px;
}
.error {
color: red;
}

View File

@ -12,27 +12,29 @@
<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" />
<!--suppress HtmlUnknownTarget -->
<link rel="stylesheet" href="main.css?v=%%VERSION_NUMBER%%" />
<script async src="https://stats.fwdekker.com/count.js"
data-goatcounter="https://stats.fwdekker.com/count"></script>
</head>
<body>
<noscript>
<p style="color: red; font-weight: bold;">
<img src="https://stats.fwdekker.com/count?p=/tools/random-fo76/" alt="Counting pixel" />
<img src="https://stats.fwdekker.com/count?p=/tools/random-fo76/" alt="Counting pixel" />
<p>
This website does not function if JavaScript is disabled.
Please check the <a href="https://www.enable-javascript.com/">
instructions on how to enable JavaScript in your web browser</a>.
</p>
</noscript>
<main style="display: none;">
<main class="hidden">
<div id="nav"></div>
<div id="contents">
<div id="header"></div>
<!-- Metadata -->
<section class="container">
<table style="max-width: 300px;">
<table class="metadata">
<tr>
<th>Game version</th>
<td id="gameVersion">loading...</td>

View File

@ -1,5 +1,5 @@
// noinspection JSUnresolvedVariable
const {$, doAfterLoad, footer, header, nav, showPage} = window.fwdekker;
const {$, doAfterLoad, footer, header, nav} = window.fwdekker;
const storageKey = "/tools/random-fo76//selected-signatures";
@ -98,10 +98,10 @@ const updateSignatureToggle = () => {
if (getSelectedSignatures().length === document.querySelectorAll("#signatures input").length) {
signatureToggle.innerHTML = "Deselect all signatures";
signatureToggle.onclick = () => setAllSignatures(false);
signatureToggle.addEventListener("click", () => setAllSignatures(false));
} else {
signatureToggle.innerHTML = "Select all signatures";
signatureToggle.onclick = () => setAllSignatures(true);
signatureToggle.addEventListener("click", () => setAllSignatures(true));
}
};
@ -140,10 +140,10 @@ const createSignatureButtons = signatures => {
checkbox.id = `signature-${signature}`;
checkbox.name = `signature-${signature}`;
checkbox.value = signature;
checkbox.onclick = () => {
checkbox.addEventListener("click", () => {
updateSignatureToggle();
saveSelectedSignaturesToStorage();
};
});
col.appendChild(checkbox);
row.appendChild(col);
@ -176,7 +176,7 @@ doAfterLoad(() => {
vcsURL: "https://git.fwdekker.com/FWDekker/random-fo76/",
version: "v%%VERSION_NUMBER%%"
}));
showPage();
$("main").classList.remove("hidden");
});
// Load page from API
@ -199,7 +199,7 @@ doAfterLoad(() => {
},
() => {
const form = $("#signatureForm");
form.style.color = "red";
form.classList.add("error");
form.innerHTML = "Error: Failed to download signatures. Try reloading the page.";
}
);
@ -207,12 +207,12 @@ doAfterLoad(() => {
// Install handlers
doAfterLoad(() => {
$("#submit").onclick = () => {
$("#submit").addEventListener("click", () => {
$("#output").innerHTML = "Fetching record... please wait";
const selectedSignatures = getSelectedSignatures();
fetchFromApi(`action=get-random&signatures=${selectedSignatures.join(",")}`,
record => showRecord(record)
);
};
});
});