PageSourceSearch

https://spacewaves2.net/template/default/js/homepage.js

js spacewaves2.net collected 2026-09-26 03:39:23 UTC 3,644 bytes, 94 lines download raw bytes

1/**
2 * spacewaves2.net — Homepage JavaScript
3 * 主页交互功能脚本
4 */
5
6'use strict';
7
8document.addEventListener('DOMContentLoaded', function() {
9    // 浮动目录 / 展开 / 全屏:由首页 index.html 内联脚本处理(Space Waves)
10
11    // 视频播放功能
12    const videoPlaceholder = document.getElementById('video-placeholder');
13    const gameplayVideo = document.getElementById('gameplay-video');
14    
15    if (videoPlaceholder && gameplayVideo) {
16        videoPlaceholder.addEventListener('click', function() {
17            gameplayVideo.src = 'https://www.youtube.com/embed/uEHt29gzgtI?autoplay=1&rel=0';
18            gameplayVideo.classList.remove('hidden');
19            videoPlaceholder.style.display = 'none';
20        });
21    }
22    
23    // 书签功能
24    const bookmarkBtn = document.getElementById('bookmark-btn');
25    if (bookmarkBtn) {
26        bookmarkBtn.addEventListener('click', function(e) {
27            e.preventDefault();
28            if (window.sidebar && window.sidebar.addPanel) {
29                window.sidebar.addPanel(document.title, window.location.href, '');
30            } else if (window.external && ('AddFavorite' in window.external)) {
31                window.external.AddFavorite(window.location.href, document.title);
32            } else {
33                alert('Press Ctrl+D (Cmd+D on Mac) to bookmark this page!');
34            }
35        });
36    }
37    
38    // 星级评分功能
39    const stars = document.querySelectorAll('.star');
40    const starsContainer = document.querySelector('.rating-row') || document.querySelector('[aria-label="Rate this game"]') || document.querySelector('[aria-label="rate this game"]');
41    
42    if (stars.length > 0 && starsContainer) {
43        function getCurrentRating() {
44            const avgRatingEl = document.getElementById('avg-rating');
45            return avgRatingEl ? parseFloat(avgRatingEl.textContent.split('/')[0] || 0) : 0;
46        }
47        
48        function resetStarsToInitialState() {
49            const avgRating = getCurrentRating();
50            stars.forEach(star => {
51                const path = star.querySelector('path');
52                if (path) {
53                    const starValue = parseInt(star.getAttribute('data-star'));
54                    if (starValue <= Math.round(avgRating)) {
55                        path.setAttribute('fill', '#ef4444');
56                        path.setAttribute('stroke', '#ef4444');
57                    } else {
58                        path.setAttribute('fill', 'none');
59                        path.setAttribute('stroke', 'currentColor');
60                    }
61                }
62            });
63        }
64        
65        function highlightStars(count) {
66            stars.forEach((star, index) => {
67                const path = star.querySelector('path');
68                if (path) {
69                    if (index < count) {
70                        path.setAttribute('fill', '#ef4444');
71                        path.setAttribute('stroke', '#ef4444');
72                    } else {
73                        path.setAttribute('fill', 'none');
74                        path.setAttribute('stroke', 'currentColor');
75                    }
76                }
77            });
78        }
79        
80        // 鼠标悬停效果
81        stars.forEach((star, index) => {
82            star.addEventListener('mouseenter', function() {
83                highlightStars(index + 1);
84            });
85        });
86        
87        starsContainer.addEventListener('mouseleave', function() {
88            resetStarsToInitialState();
89        });
90        
91        // 初始化星级显示
92        resetStarsToInitialState();
93    }
94});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.