Spaces:
Running
Running
Update docs.html
Browse files
docs.html
CHANGED
|
@@ -2063,6 +2063,50 @@
|
|
| 2063 |
</div>
|
| 2064 |
|
| 2065 |
<script src="utils/xp-calculations.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2066 |
<script>
|
| 2067 |
// Sidebar toggle functionality
|
| 2068 |
const sidebarToggle = document.getElementById('sidebarToggle');
|
|
@@ -2161,38 +2205,7 @@
|
|
| 2161 |
}
|
| 2162 |
}
|
| 2163 |
|
| 2164 |
-
|
| 2165 |
-
const themeLoadingIndicator = document.getElementById('theme-loading');
|
| 2166 |
-
if (themeLoadingIndicator) {
|
| 2167 |
-
themeLoadingIndicator.style.display = 'block';
|
| 2168 |
-
}
|
| 2169 |
-
|
| 2170 |
-
try {
|
| 2171 |
-
// β
Use dynamic userId from Telegram
|
| 2172 |
-
const response = await fetch(`https://reaperxxxx-testldb.hf.space/user/${userId}/theme`);
|
| 2173 |
-
const data = await response.json();
|
| 2174 |
-
|
| 2175 |
-
if (data.status && data.theme) {
|
| 2176 |
-
console.log('[v0] Theme loaded from API:', data.theme);
|
| 2177 |
-
changeTheme(data.theme); // β
apply theme
|
| 2178 |
-
return;
|
| 2179 |
-
}
|
| 2180 |
-
} catch (error) {
|
| 2181 |
-
console.log('[v0] API theme fetch failed, using default:', error);
|
| 2182 |
-
changeTheme('default'); // β
fallback theme
|
| 2183 |
-
} finally {
|
| 2184 |
-
// β
Always hide/remove loader
|
| 2185 |
-
if (themeLoadingIndicator) {
|
| 2186 |
-
themeLoadingIndicator.remove();
|
| 2187 |
-
}
|
| 2188 |
-
}
|
| 2189 |
-
}
|
| 2190 |
-
window.addEventListener('DOMContentLoaded', () => {
|
| 2191 |
-
if (userId) {
|
| 2192 |
-
loadUserTheme(userId);
|
| 2193 |
-
}
|
| 2194 |
-
});
|
| 2195 |
-
|
| 2196 |
window.addEventListener('DOMContentLoaded', async () => {
|
| 2197 |
const savedTheme = localStorage.getItem('xselectedTheme') || 'default';
|
| 2198 |
changeTheme(savedTheme);
|
|
|
|
| 2063 |
</div>
|
| 2064 |
|
| 2065 |
<script src="utils/xp-calculations.js"></script>
|
| 2066 |
+
<script>
|
| 2067 |
+
async function loadUserTheme() {
|
| 2068 |
+
const themeLoadingIndicator = document.getElementById('theme-loading');
|
| 2069 |
+
if (themeLoadingIndicator) {
|
| 2070 |
+
themeLoadingIndicator.style.display = 'block';
|
| 2071 |
+
}
|
| 2072 |
+
|
| 2073 |
+
try {
|
| 2074 |
+
// β
Figure out userId dynamically
|
| 2075 |
+
let userId;
|
| 2076 |
+
const initData = Telegram.WebApp.initDataUnsafe;
|
| 2077 |
+
const startParam = initData.start_param;
|
| 2078 |
+
|
| 2079 |
+
if (startParam) {
|
| 2080 |
+
userId = startParam; // viewing someone else
|
| 2081 |
+
} else if (initData.user && initData.user.id) {
|
| 2082 |
+
userId = initData.user.id; // current user
|
| 2083 |
+
} else {
|
| 2084 |
+
console.error("β Unable to fetch userId");
|
| 2085 |
+
return;
|
| 2086 |
+
}
|
| 2087 |
+
|
| 2088 |
+
// β
Use the dynamic userId in API call
|
| 2089 |
+
const response = await fetch(`https://reaperxxxx-testldb.hf.space/user/${userId}/theme`);
|
| 2090 |
+
const data = await response.json();
|
| 2091 |
+
|
| 2092 |
+
if (data.status && data.theme) {
|
| 2093 |
+
console.log('[v0] Theme loaded from API:', data.theme);
|
| 2094 |
+
changeTheme(data.theme);
|
| 2095 |
+
return;
|
| 2096 |
+
}
|
| 2097 |
+
} catch (error) {
|
| 2098 |
+
console.log('[v0] API theme fetch failed, using default:', error);
|
| 2099 |
+
changeTheme('default');
|
| 2100 |
+
} finally {
|
| 2101 |
+
if (themeLoadingIndicator) {
|
| 2102 |
+
themeLoadingIndicator.remove();
|
| 2103 |
+
}
|
| 2104 |
+
}
|
| 2105 |
+
}
|
| 2106 |
+
|
| 2107 |
+
// β
Run after DOM is ready
|
| 2108 |
+
window.addEventListener('DOMContentLoaded', loadUserTheme);
|
| 2109 |
+
</script>
|
| 2110 |
<script>
|
| 2111 |
// Sidebar toggle functionality
|
| 2112 |
const sidebarToggle = document.getElementById('sidebarToggle');
|
|
|
|
| 2205 |
}
|
| 2206 |
}
|
| 2207 |
|
| 2208 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2209 |
window.addEventListener('DOMContentLoaded', async () => {
|
| 2210 |
const savedTheme = localStorage.getItem('xselectedTheme') || 'default';
|
| 2211 |
changeTheme(savedTheme);
|