465 lines
14 KiB
HTML
465 lines
14 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>熱門排行</title>
|
|
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap" rel="stylesheet">
|
|
<style>
|
|
body {
|
|
font-family: 'Roboto', sans-serif;
|
|
margin: 0;
|
|
padding: 0;
|
|
background-color: #f4f4f4;
|
|
}
|
|
.container {
|
|
text-align: center;
|
|
margin: 20px;
|
|
}
|
|
.header {
|
|
background: #D32F2F;
|
|
padding: 10px 0;
|
|
color: white;
|
|
font-size: 24px;
|
|
font-weight: 500;
|
|
text-align: center;
|
|
}
|
|
.banner {
|
|
width: 100%;
|
|
max-width: 600px;
|
|
margin: 0 auto 20px;
|
|
}
|
|
.banner img {
|
|
width: 100%;
|
|
height: auto;
|
|
}
|
|
.menu-toggle {
|
|
position: absolute;
|
|
top: 10px;
|
|
left: 10px;
|
|
cursor: pointer;
|
|
}
|
|
.menu {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
height: 100%;
|
|
width: 250px;
|
|
background: white;
|
|
transform: translateX(-250px);
|
|
transition: transform 0.3s ease;
|
|
box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
|
|
overflow-y: auto;
|
|
}
|
|
.menu.active {
|
|
transform: translateX(0);
|
|
}
|
|
.menu ul {
|
|
list-style: none;
|
|
padding: 0;
|
|
margin: 0;
|
|
}
|
|
.menu ul li {
|
|
padding: 15px 20px;
|
|
border-bottom: 1px solid #ccc;
|
|
}
|
|
.menu ul li a {
|
|
text-decoration: none;
|
|
color: #333;
|
|
display: block;
|
|
}
|
|
.menu ul li a:hover {
|
|
background: #eee;
|
|
}
|
|
.content {
|
|
margin: 20px;
|
|
}
|
|
.table-container {
|
|
margin-top: 20px;
|
|
overflow-x: auto;
|
|
}
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
}
|
|
th, td {
|
|
border: 1px solid #ddd;
|
|
padding: 8px;
|
|
}
|
|
th {
|
|
background-color: #333;
|
|
color: white;
|
|
}
|
|
tr:nth-child(odd) {
|
|
background-color: white;
|
|
}
|
|
tr:nth-child(even) {
|
|
background-color: #f2f2f2;
|
|
}
|
|
tr:hover {
|
|
background-color: #666;
|
|
}
|
|
td {
|
|
color: black;
|
|
}
|
|
.song-details {
|
|
position: fixed;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
background-color: white;
|
|
border-radius: 10px;
|
|
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
|
|
padding: 20px;
|
|
z-index: 1000;
|
|
width: 80%;
|
|
max-width: 400px;
|
|
text-align: left;
|
|
display: none;
|
|
}
|
|
|
|
.overlay {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
background-color: rgba(0, 0, 0, 0.5);
|
|
backdrop-filter: blur(5px);
|
|
z-index: 999;
|
|
display: none;
|
|
}
|
|
.song-details button {
|
|
width: 100%;
|
|
padding: 10px;
|
|
margin: 10px 0;
|
|
background-color: #D32F2F;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 5px;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.song-details button:hover {
|
|
background-color: #b52b2b;
|
|
}
|
|
|
|
.close-btn {
|
|
position: absolute;
|
|
top: 10px;
|
|
right: 10px;
|
|
font-size: 24px;
|
|
color: #333;
|
|
cursor: pointer;
|
|
font-weight: bold;
|
|
}
|
|
|
|
.close-btn:hover {
|
|
color: #D32F2F;
|
|
}
|
|
|
|
a {
|
|
text-decoration: none;
|
|
color: inherit;
|
|
}
|
|
|
|
input,
|
|
button {
|
|
pointer-events: auto;
|
|
cursor: text;
|
|
}
|
|
|
|
button {
|
|
cursor: pointer;
|
|
}
|
|
|
|
input[type="text"],
|
|
input[type="search"],
|
|
input[type="email"],
|
|
input[type="password"] {
|
|
-webkit-appearance: none;
|
|
-moz-appearance: none;
|
|
appearance: none;
|
|
}
|
|
|
|
.form-group button,
|
|
.song-details button {
|
|
border: none;
|
|
background-color: #D32F2F;
|
|
color: white;
|
|
padding: 10px 20px;
|
|
border-radius: 5px;
|
|
font-size: 16px;
|
|
transition: background-color 0.3s;
|
|
}
|
|
|
|
.form-group button:hover,
|
|
.song-details button:hover {
|
|
background-color: #b52b2b;
|
|
}
|
|
|
|
/* 添加表格行的樣式 */
|
|
#results-table tbody tr {
|
|
cursor: pointer;
|
|
}
|
|
|
|
#results-table tbody tr:hover {
|
|
background-color: rgba(211, 47, 47, 0.1);
|
|
}
|
|
|
|
/* 防止表格內容被選中 */
|
|
#results-table {
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
-moz-user-select: none;
|
|
-ms-user-select: none;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div class="header">熱門排行</div>
|
|
|
|
<!-- Add Banner -->
|
|
<div class="banner">
|
|
<img src="手機點歌/BANNER-02.png" alt="超級巨星 Banner">
|
|
</div>
|
|
|
|
<div class="menu-toggle">
|
|
<svg height="32px" id="Layer_1" style="enable-background:new 0 0 32 32;" version="1.1" viewBox="0 0 32 32" width="32px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="M4,10h24c0.553,0,1-0.447,1-1s-0.447-1-1-1H4c-0.553,0-1,0.447-1,1S3.447,10,4,10z"/><path d="M28,15H4c-0.553,0-1,0.447-1,1s0.447,1,1,1h24c0.553,0,1-0.447,1-1S28.553,15,28,15z"/><path d="M28,22H4c-0.553,0-1,0.447-1,1s0.447,1,1,1h24c0.553,0,1-0.447,1-1S28.553,22,28,22z"/></svg>
|
|
</div>
|
|
|
|
<div class="menu">
|
|
<ul>
|
|
<li><a href="windows.html" class="menu-link">首頁</a></li>
|
|
<li><a href="new-songs.html" class="menu-link">新歌快報</a></li>
|
|
<li><a href="top-ranking.html" class="menu-link">熱門排行</a></li>
|
|
<li><a href="search-singer.html" class="menu-link">歌星查詢</a></li>
|
|
<li><a href="search-song.html" class="menu-link">歌名查詢</a></li>
|
|
<li><a href="clicked-song.html" class="menu-link">已點歌曲</a></li>
|
|
<!-- <!-- //<li><a href="my-favorite.html" class="menu-link">我的最愛</a></li> --> -->
|
|
<li><a href="sound-control.html" class="menu-link">聲音控制</a></li>
|
|
<li><a href="social-media.html" class="menu-link">社群媒體</a></li>
|
|
<li><a href="love-message.html" class="menu-link">真情告白</a></li>
|
|
<li><a href="mood-stickers.html" class="menu-link">心情貼圖</a></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="container">
|
|
<!-- 遮罩层 -->
|
|
<div class="overlay" id="overlay"></div>
|
|
|
|
<div class="content">
|
|
<h2>熱門排行</h2>
|
|
<div class="table-container">
|
|
<table id="results-table">
|
|
<thead>
|
|
<tr>
|
|
<th>歌名</th>
|
|
<th>歌手</th>
|
|
<th>語別</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<!-- 搜索結果將顯示在這裡 -->
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 歌曲詳細信息區域 -->
|
|
<div class="song-details" id="song-details" style="display:none;">
|
|
<span class="close-btn" id="close-btn">×</span>
|
|
<p>歌名:<span id="detail-song-name"></span></p>
|
|
<p>編號:<span id="detail-song-number"></span></p>
|
|
<p>歌手:<span id="detail-singer"></span></p>
|
|
<p>語別:<span id="detail-language"></span></p>
|
|
<button id="order-song-button">包廂點歌</button>
|
|
<button id="insert-song-button">插播歌曲</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// 首先處理導航 - 確保最高優先級
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// 導航處理
|
|
const menuLinks = document.querySelectorAll('.menu-link');
|
|
menuLinks.forEach(link => {
|
|
// 移除所有現有的事件監聽器
|
|
const oldLink = link.cloneNode(true);
|
|
link.parentNode.replaceChild(oldLink, link);
|
|
|
|
// 添加新的點擊處理
|
|
oldLink.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
e.stopImmediatePropagation();
|
|
const href = this.getAttribute('href');
|
|
if (href) {
|
|
window.location.href = href;
|
|
}
|
|
}, true); // 使用捕獲階段
|
|
});
|
|
|
|
// 菜單切換
|
|
const menuToggle = document.querySelector('.menu-toggle');
|
|
const menu = document.querySelector('.menu');
|
|
|
|
if (menuToggle && menu) {
|
|
menuToggle.addEventListener('click', (e) => {
|
|
e.stopPropagation();
|
|
e.stopImmediatePropagation();
|
|
menu.classList.toggle('active');
|
|
}, true);
|
|
|
|
document.addEventListener('click', (e) => {
|
|
if (!menu.contains(e.target) && !menuToggle.contains(e.target)) {
|
|
menu.classList.remove('active');
|
|
}
|
|
}, true);
|
|
}
|
|
});
|
|
|
|
function showDetails() {
|
|
document.getElementById('song-details').style.display = 'block';
|
|
document.getElementById('overlay').style.display = 'block';
|
|
}
|
|
|
|
|
|
function hideDetails(e) {
|
|
if (e) {
|
|
e.preventDefault(); // 阻止默認行為
|
|
e.stopPropagation(); // 阻止事件冒泡
|
|
}
|
|
document.getElementById('song-details').style.display = 'none';
|
|
document.getElementById('overlay').style.display = 'none';
|
|
}
|
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
fetch('/search', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
},
|
|
body: JSON.stringify({ type: 'top-ranking' })
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
const tableBody = document.querySelector('#results-table tbody');
|
|
tableBody.innerHTML = '';
|
|
|
|
data.forEach(song => {
|
|
const row = document.createElement('tr');
|
|
const songNameCell = document.createElement('td');
|
|
const singerCell = document.createElement('td');
|
|
const languageCell = document.createElement('td');
|
|
|
|
songNameCell.textContent = song.Song;
|
|
singerCell.textContent = song.ArtistA;
|
|
languageCell.textContent = song.Category;
|
|
|
|
row.appendChild(songNameCell);
|
|
row.appendChild(singerCell);
|
|
row.appendChild(languageCell);
|
|
|
|
row.addEventListener('click', (e) => {
|
|
e.preventDefault(); // 阻止默認行為
|
|
e.stopPropagation(); // 阻止事件冒泡
|
|
|
|
window.selectedSong = song;
|
|
console.log('Selected song:', window.selectedSong);
|
|
|
|
// 更新詳情視窗內容
|
|
document.getElementById('detail-song-name').textContent = song.Song;
|
|
document.getElementById('detail-song-number').textContent = song.SongNumber;
|
|
document.getElementById('detail-singer').textContent = song.ArtistA;
|
|
document.getElementById('detail-language').textContent = song.Category;
|
|
|
|
// 顯示詳情視窗和遮罩
|
|
document.getElementById('song-details').style.display = 'block';
|
|
document.getElementById('overlay').style.display = 'block';
|
|
});
|
|
|
|
tableBody.appendChild(row);
|
|
});
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
|
|
|
|
document.getElementById('overlay').addEventListener('click', hideDetails);
|
|
|
|
|
|
document.getElementById('close-btn').addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
hideDetails(e);
|
|
});
|
|
});
|
|
|
|
document.getElementById('order-song-button').addEventListener('click', () => {
|
|
const song = window.selectedSong;
|
|
console.log(window.selectedSong);
|
|
|
|
fetch('/order-song', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
},
|
|
body: JSON.stringify(song)
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
alert('點歌成功!');
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
});
|
|
|
|
document.getElementById('insert-song-button').addEventListener('click', () => {
|
|
const song = window.selectedSong;
|
|
|
|
fetch('/insert-song', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json;charset=UTF-8'
|
|
},
|
|
body: JSON.stringify(song)
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
alert('插播成功!');
|
|
})
|
|
.catch(error => {
|
|
console.error('Error:', error);
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('form').forEach(form => {
|
|
form.addEventListener('submit', (e) => {
|
|
e.preventDefault();
|
|
});
|
|
});
|
|
|
|
document.querySelectorAll('button').forEach(button => {
|
|
button.addEventListener('click', (e) => {
|
|
e.preventDefault();
|
|
if(button.onclick) {
|
|
button.onclick.call(this);
|
|
}
|
|
});
|
|
});
|
|
|
|
// 確保詳情視窗內的點擊不會冒泡到外層
|
|
document.getElementById('song-details').addEventListener('click', function(e) {
|
|
e.stopPropagation();
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html> |