@@ -1233,8 +1233,89 @@ document.addEventListener('DOMContentLoaded', () => {
12331233
12341234 // Initialize version selector for both pages
12351235 initBenchmarkVersionSelector ( ) ;
1236+
1237+ // Initialize quotes rotation (if on a page with quotes)
1238+ initQuotesRotation ( ) ;
12361239} ) ;
12371240
1241+ // ============================================================================
1242+ // Quotes Rotation
1243+ // ============================================================================
1244+
1245+ const QUOTE_ROTATION_INTERVAL_MS = 10000 ; // 10 seconds between quotes
1246+
1247+ async function initQuotesRotation ( ) {
1248+ const container = document . getElementById ( 'quote-container' ) ;
1249+ const textEl = document . getElementById ( 'quote-text' ) ;
1250+ const authorEl = document . getElementById ( 'quote-author' ) ;
1251+
1252+ if ( ! container || ! textEl || ! authorEl ) return ; // Not on a page with quotes
1253+
1254+ try {
1255+ const response = await fetch ( 'assets/quotes.json' ) ;
1256+ if ( ! response . ok ) return ;
1257+ const data = await response . json ( ) ;
1258+ const quotes = data . quotes ;
1259+
1260+ if ( ! quotes || quotes . length === 0 ) return ;
1261+
1262+ let currentIndex = Math . floor ( Math . random ( ) * quotes . length ) ;
1263+ let isTransitioning = false ;
1264+ let autoRotateTimer = null ;
1265+
1266+ function displayQuote ( index ) {
1267+ const quote = quotes [ index ] ;
1268+ textEl . textContent = `"${ quote . text } "` ;
1269+ authorEl . textContent = ` — ${ quote . vendor } / ${ quote . model } ` ;
1270+ }
1271+
1272+ function getRandomIndex ( ) {
1273+ // Pick a random index different from current
1274+ if ( quotes . length <= 1 ) return 0 ;
1275+ let newIndex ;
1276+ do {
1277+ newIndex = Math . floor ( Math . random ( ) * quotes . length ) ;
1278+ } while ( newIndex === currentIndex ) ;
1279+ return newIndex ;
1280+ }
1281+
1282+ function transitionToNext ( ) {
1283+ if ( isTransitioning ) return ;
1284+ isTransitioning = true ;
1285+
1286+ currentIndex = getRandomIndex ( ) ;
1287+ // Fade out container
1288+ container . style . opacity = '0' ;
1289+ // After fade out (1s), update and fade in
1290+ setTimeout ( ( ) => {
1291+ displayQuote ( currentIndex ) ;
1292+ container . style . opacity = '1' ;
1293+ isTransitioning = false ;
1294+ } , 1000 ) ;
1295+ }
1296+
1297+ function resetAutoRotate ( ) {
1298+ if ( autoRotateTimer ) clearInterval ( autoRotateTimer ) ;
1299+ autoRotateTimer = setInterval ( transitionToNext , QUOTE_ROTATION_INTERVAL_MS ) ;
1300+ }
1301+
1302+ // Display first quote immediately
1303+ displayQuote ( currentIndex ) ;
1304+
1305+ // Click on quote text to cycle to next quote
1306+ textEl . addEventListener ( 'click' , ( ) => {
1307+ transitionToNext ( ) ;
1308+ resetAutoRotate ( ) ; // Reset timer on manual click
1309+ } ) ;
1310+
1311+ // Start auto-rotation
1312+ resetAutoRotate ( ) ;
1313+
1314+ } catch ( e ) {
1315+ console . error ( 'Failed to load quotes:' , e ) ;
1316+ }
1317+ }
1318+
12381319// ===== Run Viewer (modal) =====
12391320function formatRequestId ( n ) {
12401321 return String ( n ) . padStart ( 5 , '0' ) ;
0 commit comments