@@ -287,12 +287,12 @@ <h3>Forecast Visualization</h3>
287287 </ div >
288288
289289 <!-- Footer -->
290+ < div style ="margin:8px 0; font-size:14px; color:#ccc; ">
291+ Total page views: < strong id ="visit-counter "> 0</ strong >
292+ </ div >
290293 < div class ="footer ">
291294 < small style ="color:#aaa; "> App Version: 1.0.0 (Beta)</ small >
292- < br > < div style ="margin:8px 0; font-size:14px; color:#ccc; ">
293- Total page views : < strong id ="visit-counter "> …</ strong >
294- </ div >
295- © 2025 Hariprashad Ravikumar · All rights reserved< br >
295+ < br > © 2025 Hariprashad Ravikumar · All rights reserved< br >
296296 < a href ="https://hariprashad-ravikumar.github.io " target ="_blank "> Website</ a > ·
297297 < a href ="https://github.com/Hariprashad-Ravikumar " target ="_blank "> GitHub</ a >
298298 </ div >
@@ -403,20 +403,25 @@ <h3>Forecast Visualization</h3>
403403 } ) ;
404404 </ script >
405405
406- < script >
407- async function updateCounter ( ) {
408- try {
409- const res = await fetch (
410- 'https://api.countapi.xyz/hit/AI-DataScience-Lab/page_visits'
411- ) ;
412- const { value } = await res . json ( ) ;
413- document . getElementById ( 'visit-counter' ) . textContent = value ;
414- } catch ( err ) {
415- console . error ( 'Counter error' , err ) ;
416- }
417- }
418- updateCounter ( ) ;
406+ <!-- right before </body> -->
407+ < script >
408+ document . addEventListener ( 'DOMContentLoaded' , ( ) => {
409+ const el = document . getElementById ( 'visit-counter' ) ;
410+ fetch ( URL )
411+ . then ( res => {
412+ if ( ! res . ok ) throw new Error ( `HTTP ${ res . status } ` ) ;
413+ return res . json ( ) ;
414+ } )
415+ . then ( data => {
416+ el . textContent = data . value ;
417+ } )
418+ . catch ( err => {
419+ console . error ( 'Counter error:' , err ) ;
420+ // optionally: el.textContent = '—';
421+ } ) ;
422+ } ) ;
419423</ script >
424+
420425
421426</ body >
422427</ html >
0 commit comments