small
This commit is contained in:
7
public/assets/js/config.js
Normal file
7
public/assets/js/config.js
Normal file
@@ -0,0 +1,7 @@
|
||||
// Configuration for the frontend
|
||||
const config = {
|
||||
// Use services.btcforplebs.com in production, localhost in development
|
||||
apiBaseUrl: window.location.hostname === 'localhost'
|
||||
? 'http://localhost:5252'
|
||||
: 'https://services.btcforplebs.com'
|
||||
};
|
||||
@@ -4,7 +4,7 @@ let linkStatuses = {};
|
||||
// Fetch statuses on page load
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Fetch statuses immediately but keep folders closed
|
||||
fetch("https://services.btcforplebs.com/api/link-status")
|
||||
fetch(`${config.apiBaseUrl}/api/link-status`)
|
||||
.then(res => res.json())
|
||||
.then(statuses => {
|
||||
linkStatuses = statuses; // Store for later use
|
||||
@@ -43,7 +43,7 @@ function toggleFolder(folderId, buttonId) {
|
||||
if (Object.keys(linkStatuses).length > 0) {
|
||||
updateFolderStatuses(folder, linkStatuses);
|
||||
} else {
|
||||
fetch("https://services.btcforplebs.com/api/link-status")
|
||||
fetch(`${config.apiBaseUrl}/api/link-status`)
|
||||
.then(res => res.json())
|
||||
.then(statuses => {
|
||||
linkStatuses = statuses;
|
||||
@@ -60,7 +60,7 @@ async function init() {
|
||||
try {
|
||||
// Fetch the status first
|
||||
console.log("Fetching statuses...");
|
||||
const response = await fetch("https://services.btcforplebs.com/api/link-status");
|
||||
const response = await fetch(`${config.apiBaseUrl}/api/link-status`);
|
||||
const statuses = await response.json();
|
||||
console.log("Got statuses:", statuses);
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta c <!-- scripts -->
|
||||
<script src="/assets/js/config.js"></script>
|
||||
<script src="/assets/js/scripts.js"></script>
|
||||
<script src="/assets/js/home.js"></script>
|
||||
<link rel="stylesheet" href="/assets/css/main.css">et="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>BTCforPlebs</title>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user