sigh. javascript. switching to back-ticks for fetch on index.html

This commit is contained in:
Greg Gauthier 2024-07-01 17:01:25 +01:00
parent c2b8364b6d
commit c4411006fe

View File

@ -4,6 +4,7 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="styles.css"> <link rel="stylesheet" type="text/css" href="styles.css">
<title>Gamma World Gaming Tools</title> <title>Gamma World Gaming Tools</title>
<script src="config.js"></script>
</head> </head>
<body> <body>
<div style="text-align: center"> <div style="text-align: center">
@ -31,14 +32,6 @@
<div id="toolPanel"></div> <div id="toolPanel"></div>
<script> <script>
if (window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1') {
window.BASE_URL = 'http://127.0.0.1:5000';
} else {
window.BASE_URL = 'https://gammaworld.gmgauthier.com';
}
console.log(window.location.hostname)
console.log(window.BASE_URL)
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
loadContent("intro.html"); loadContent("intro.html");
@ -86,7 +79,7 @@
document.getElementById('toolPanel').innerHTML = ''; document.getElementById('toolPanel').innerHTML = '';
document.getElementById('toolPanel').appendChild(imgElement); document.getElementById('toolPanel').appendChild(imgElement);
fetch('${window.BASE_URL}/coinflip') fetch(`${window.BASE_URL}/coinflip`)
.then(response => response.text()) .then(response => response.text())
.then(data => { .then(data => {
let imgSrc = 'img/' + data.replace(/\"/g, '') + '.jpg'; let imgSrc = 'img/' + data.replace(/\"/g, '') + '.jpg';
@ -114,7 +107,7 @@
imgElement.style.marginRight = 'auto'; imgElement.style.marginRight = 'auto';
resultSection.appendChild(imgElement); resultSection.appendChild(imgElement);
fetch('${window.BASE_URL}/dice/probability') fetch(`${window.BASE_URL}/dice/probability`)
.then((response) => { .then((response) => {
if (!response.ok) { if (!response.ok) {
throw response; throw response;