Skip to content

Commit 9f1305a

Browse files
committed
feat: add config.js to control data source (dev and prod)
1 parent 4d06723 commit 9f1305a

5 files changed

Lines changed: 41 additions & 3 deletions

File tree

about.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>About - BalatroBench</title>
88
<script src="https://cdn.tailwindcss.com"></script>
99
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10+
<script src="config.js"></script>
1011
<script src="script.js"></script>
1112
<!-- Theme-aware favicon -->
1213
<link rel="icon" href="favicon.svg" type="image/svg+xml">

community.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>BalatroBench Community</title>
88
<script src="https://cdn.tailwindcss.com"></script>
99
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10+
<script src="config.js"></script>
1011
<script src="script.js"></script>
1112
<!-- Theme-aware favicon -->
1213
<link rel="icon" href="favicon.svg" type="image/svg+xml">

config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Configuration file for BalatroBench
3+
* Controls data source locations
4+
*/
5+
6+
const CONFIG = {
7+
// Current active environment - change this to switch environments
8+
// environment: 'development',
9+
environment: 'production',
10+
11+
// Environment configurations
12+
environments: {
13+
development: {
14+
name: 'Development',
15+
data: '' // Local data - use relative paths
16+
},
17+
production: {
18+
name: 'Production',
19+
data: 'https://balatrobench.b-cdn.net' // CDN data
20+
}
21+
},
22+
23+
// Get current environment
24+
getCurrent() {
25+
return this.environments[this.environment] || this.environments.development;
26+
},
27+
28+
// Get data URL for current environment
29+
getData() {
30+
return this.getCurrent().data;
31+
}
32+
};
33+
34+
// Make CONFIG available globally
35+
window.CONFIG = CONFIG;

index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<title>BalatroBench</title>
88
<script src="https://cdn.tailwindcss.com"></script>
99
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
10+
<script src="config.js"></script>
1011
<script src="script.js"></script>
1112
<!-- Theme-aware favicon -->
1213
<link rel="icon" href="favicon.svg" type="image/svg+xml">

script.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ let performanceChart = null;
4141
let DEFAULT_BENCHMARK_VERSION = null; // Must be set from manifest
4242
let PAGE_TYPE = null; // 'main' or 'community'
4343

44-
// Data source configuration
45-
const IS_DEV = new URLSearchParams(window.location.search).has('dev');
46-
const DATA_BASE_URL = IS_DEV ? '' : 'http://balatrobench.b-cdn.net';
44+
// Data source configuration - using CONFIG from config.js
45+
const DATA_BASE_URL = window.CONFIG ? window.CONFIG.getData() : '';
46+
const IS_DEV = window.CONFIG ? window.CONFIG.environment === 'development' : false;
4747

4848
// Detect which page we're on
4949
function detectPageType() {

0 commit comments

Comments
 (0)