a
|
After Width: | Height: | Size: 46 KiB |
@@ -0,0 +1,716 @@
|
||||
/* ===== Audiobook Player - Minimalist Immersive Design ===== */
|
||||
|
||||
/* CSS Variables for theming */
|
||||
:root {
|
||||
--bg-primary: #F5F1E8;
|
||||
--bg-secondary: #FFFFFF;
|
||||
--bg-card: #FFFFFF;
|
||||
--text-primary: #2C2C2C;
|
||||
--text-secondary: #666666;
|
||||
--text-muted: #999999;
|
||||
--accent: #8B7355;
|
||||
--accent-light: #A68B6A;
|
||||
--border: #E5E0D5;
|
||||
--shadow: rgba(0, 0, 0, 0.08);
|
||||
--player-bg: rgba(255, 255, 255, 0.95);
|
||||
--progress-bg: #E5E0D5;
|
||||
--progress-fill: #8B7355;
|
||||
}
|
||||
|
||||
.dark-mode {
|
||||
--bg-primary: #1A1A1A;
|
||||
--bg-secondary: #252525;
|
||||
--bg-card: #2A2A2A;
|
||||
--text-primary: #E8E1D1;
|
||||
--text-secondary: #B8B0A0;
|
||||
--text-muted: #888888;
|
||||
--accent: #A68B6A;
|
||||
--accent-light: #C4A882;
|
||||
--border: #3A3A3A;
|
||||
--shadow: rgba(0, 0, 0, 0.3);
|
||||
--player-bg: rgba(40, 40, 40, 0.98);
|
||||
--progress-bg: #3A3A3A;
|
||||
--progress-fill: #A68B6A;
|
||||
}
|
||||
|
||||
/* Reset and Base */
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html {
|
||||
font-size: 16px;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Georgia, "Times New Roman", serif;
|
||||
background-color: var(--bg-primary);
|
||||
color: var(--text-primary);
|
||||
line-height: 1.6;
|
||||
transition: background-color 0.3s ease, color 0.3s ease;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
/* App Container */
|
||||
.app {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
/* ===== Header ===== */
|
||||
.header {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 56px;
|
||||
background: var(--bg-secondary);
|
||||
border-bottom: 1px solid var(--border);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 0 16px;
|
||||
z-index: 1000;
|
||||
box-shadow: 0 1px 3px var(--shadow);
|
||||
}
|
||||
|
||||
.header-title {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
flex: 1;
|
||||
text-align: center;
|
||||
margin: 0 10px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* Navigation Buttons */
|
||||
.nav-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--accent);
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.nav-btn:hover {
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
.nav-icon {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.back-btn .nav-text {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 400px) {
|
||||
.back-btn .nav-text {
|
||||
display: inline;
|
||||
}
|
||||
}
|
||||
|
||||
/* Theme Toggle */
|
||||
.theme-toggle {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.2rem;
|
||||
cursor: pointer;
|
||||
padding: 8px;
|
||||
border-radius: 50%;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.theme-toggle:hover {
|
||||
transform: scale(1.1);
|
||||
}
|
||||
|
||||
/* ===== Main Content ===== */
|
||||
.main-content {
|
||||
flex: 1;
|
||||
padding: 72px 16px 24px;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Welcome Section */
|
||||
.welcome {
|
||||
text-align: center;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
.welcome h2 {
|
||||
font-size: 1.5rem;
|
||||
margin-bottom: 8px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* ===== Source Cards (Home) ===== */
|
||||
.sources-grid {
|
||||
display: grid;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.source-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
background: var(--bg-card);
|
||||
border-radius: 16px;
|
||||
padding: 20px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
box-shadow: 0 2px 8px var(--shadow);
|
||||
transition: transform 0.2s, box-shadow 0.2s;
|
||||
min-height: 80px;
|
||||
}
|
||||
|
||||
.source-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 4px 16px var(--shadow);
|
||||
}
|
||||
|
||||
.source-icon {
|
||||
font-size: 2.5rem;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.source-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.source-name {
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.source-count {
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.source-arrow {
|
||||
font-size: 1.5rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ===== List Page ===== */
|
||||
.list-header {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.list-header h2 {
|
||||
font-size: 1.1rem;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.search-box input {
|
||||
width: 100%;
|
||||
padding: 12px 16px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 12px;
|
||||
background: var(--bg-card);
|
||||
color: var(--text-primary);
|
||||
font-size: 1rem;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.search-box input:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.search-box input::placeholder {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Stories List */
|
||||
.stories-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.story-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
background: var(--bg-card);
|
||||
border-radius: 12px;
|
||||
padding: 16px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.story-item:hover {
|
||||
background: var(--bg-secondary);
|
||||
}
|
||||
|
||||
.story-number {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--bg-primary);
|
||||
border-radius: 50%;
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-secondary);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.story-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.story-title {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
margin-bottom: 4px;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.story-meta {
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.story-meta .author {
|
||||
color: var(--accent);
|
||||
}
|
||||
|
||||
.story-arrow {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: var(--bg-primary);
|
||||
border-radius: 50%;
|
||||
font-size: 0.7rem;
|
||||
color: var(--accent);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* ===== Player Page ===== */
|
||||
.player-page {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
/* Fixed Player Bar (80px) */
|
||||
.player-bar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 80px;
|
||||
background: var(--player-bg);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border-bottom: 1px solid var(--border);
|
||||
z-index: 1000;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.player-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.player-info {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.player-title {
|
||||
font-size: 0.95rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.player-author {
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.play-btn, .close-btn {
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border-radius: 50%;
|
||||
border: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.play-btn {
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.play-btn:hover {
|
||||
transform: scale(1.05);
|
||||
background: var(--accent-light);
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: var(--bg-primary);
|
||||
color: var(--text-secondary);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.close-btn:hover {
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* Progress Bar */
|
||||
.progress-container {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.time-current, .time-total {
|
||||
font-size: 0.7rem;
|
||||
color: var(--text-muted);
|
||||
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
|
||||
min-width: 35px;
|
||||
}
|
||||
|
||||
.time-total {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
/* Speed Control Bar */
|
||||
.speed-control-bar {
|
||||
position: fixed;
|
||||
top: 80px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 44px;
|
||||
background: var(--player-bg);
|
||||
backdrop-filter: blur(20px);
|
||||
-webkit-backdrop-filter: blur(20px);
|
||||
border-bottom: 1px solid var(--border);
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 40px;
|
||||
padding: 0 20px;
|
||||
}
|
||||
|
||||
.speed-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.9rem;
|
||||
font-family: inherit;
|
||||
cursor: pointer;
|
||||
padding: 6px 16px;
|
||||
border-radius: 16px;
|
||||
transition: all 0.2s;
|
||||
min-width: 60px;
|
||||
}
|
||||
|
||||
.speed-btn:hover {
|
||||
color: var(--text-primary);
|
||||
background: var(--bg-primary);
|
||||
}
|
||||
|
||||
.speed-btn.active {
|
||||
color: white;
|
||||
background: var(--accent);
|
||||
}
|
||||
|
||||
/* Content Area with Speed Control */
|
||||
.content-area.player-with-speed {
|
||||
margin-top: 124px; /* 80px player + 44px speed control */
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
flex: 1;
|
||||
height: 4px;
|
||||
background: var(--progress-bg);
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.progress-fill {
|
||||
height: 100%;
|
||||
background: var(--progress-fill);
|
||||
border-radius: 2px;
|
||||
width: 0%;
|
||||
transition: width 0.1s linear;
|
||||
}
|
||||
|
||||
/* Content Area */
|
||||
.content-area {
|
||||
margin-top: 80px;
|
||||
padding: 20px 16px 40px;
|
||||
height: calc(100vh - 80px);
|
||||
overflow-y: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.content-area.player-with-speed {
|
||||
margin-top: 124px; /* 80px player + 44px speed control */
|
||||
height: calc(100vh - 124px);
|
||||
}
|
||||
|
||||
.story-content {
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.content-header {
|
||||
margin-bottom: 32px;
|
||||
padding-bottom: 24px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.content-header h1 {
|
||||
font-size: 1.6rem;
|
||||
line-height: 1.3;
|
||||
margin-bottom: 12px;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.content-meta {
|
||||
font-size: 0.9rem;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.content-meta .author {
|
||||
color: var(--accent);
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.content-meta .year {
|
||||
margin-left: 8px;
|
||||
padding-left: 8px;
|
||||
border-left: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* Content Body */
|
||||
.content-body {
|
||||
font-size: 1.1rem;
|
||||
line-height: 1.8;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.content-chunk {
|
||||
margin-bottom: 24px;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
|
||||
.content-chunk p {
|
||||
margin-bottom: 1.2em;
|
||||
text-align: justify;
|
||||
hyphens: auto;
|
||||
}
|
||||
|
||||
.content-chunk p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* Loading State */
|
||||
.loading {
|
||||
text-align: center;
|
||||
padding: 40px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Content End */
|
||||
.content-end {
|
||||
text-align: center;
|
||||
padding: 48px 0;
|
||||
color: var(--text-muted);
|
||||
border-top: 1px solid var(--border);
|
||||
margin-top: 48px;
|
||||
}
|
||||
|
||||
.content-end p {
|
||||
font-style: italic;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
||||
.back-to-list {
|
||||
padding: 12px 32px;
|
||||
background: var(--accent);
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 24px;
|
||||
font-size: 0.95rem;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.back-to-list:hover {
|
||||
background: var(--accent-light);
|
||||
}
|
||||
|
||||
/* ===== Empty State ===== */
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.empty-subtitle {
|
||||
font-size: 0.85rem !important;
|
||||
}
|
||||
|
||||
/* ===== Footer ===== */
|
||||
.footer {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8rem;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
|
||||
/* ===== Responsive Adjustments ===== */
|
||||
@media (min-width: 768px) {
|
||||
.main-content {
|
||||
padding-top: 80px;
|
||||
}
|
||||
|
||||
.content-area {
|
||||
padding: 32px 40px;
|
||||
}
|
||||
|
||||
.content-body {
|
||||
font-size: 1.2rem;
|
||||
line-height: 1.9;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1024px) {
|
||||
.player-bar {
|
||||
left: auto;
|
||||
width: 380px;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
height: auto;
|
||||
border-left: 1px solid var(--border);
|
||||
border-bottom: none;
|
||||
flex-direction: column-reverse;
|
||||
justify-content: flex-end;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.player-controls {
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.player-info {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.progress-container {
|
||||
padding-top: 0;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.content-area {
|
||||
margin-top: 0;
|
||||
margin-right: 380px;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.content-area.player-with-speed {
|
||||
margin-top: 0;
|
||||
margin-right: 380px;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.speed-control-bar {
|
||||
left: auto;
|
||||
right: 0;
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
width: 380px;
|
||||
height: 60px;
|
||||
border-top: 1px solid var(--border);
|
||||
border-bottom: none;
|
||||
border-left: 1px solid var(--border);
|
||||
}
|
||||
}
|
||||
|
||||
/* ===== Scrollbar Styling ===== */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-track {
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--border);
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--text-muted);
|
||||
}
|
||||
|
||||
/* ===== Selection ===== */
|
||||
::selection {
|
||||
background: var(--accent-light);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.dark-mode ::selection {
|
||||
background: var(--accent);
|
||||
}
|
||||
|
After Width: | Height: | Size: 638 KiB |
|
After Width: | Height: | Size: 779 KiB |
@@ -0,0 +1,252 @@
|
||||
/**
|
||||
* Audiobook Player - App JavaScript
|
||||
* Minimalist immersive reading experience
|
||||
*/
|
||||
|
||||
// Theme Management
|
||||
function initTheme() {
|
||||
const savedTheme = localStorage.getItem('theme') || 'light';
|
||||
if (savedTheme === 'dark') {
|
||||
document.body.classList.remove('light-mode');
|
||||
document.body.classList.add('dark-mode');
|
||||
updateThemeIcon(true);
|
||||
}
|
||||
}
|
||||
|
||||
function toggleTheme() {
|
||||
const isDark = document.body.classList.contains('dark-mode');
|
||||
|
||||
if (isDark) {
|
||||
document.body.classList.remove('dark-mode');
|
||||
document.body.classList.add('light-mode');
|
||||
localStorage.setItem('theme', 'light');
|
||||
} else {
|
||||
document.body.classList.remove('light-mode');
|
||||
document.body.classList.add('dark-mode');
|
||||
localStorage.setItem('theme', 'dark');
|
||||
}
|
||||
|
||||
updateThemeIcon(!isDark);
|
||||
}
|
||||
|
||||
function updateThemeIcon(isDark) {
|
||||
const toggle = document.querySelector('.theme-toggle');
|
||||
if (toggle) {
|
||||
toggle.textContent = isDark ? '☀️' : '🌙';
|
||||
}
|
||||
}
|
||||
|
||||
// Navigation
|
||||
function goBack() {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
function closePlayer() {
|
||||
// Override in player page
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
// Save and Restore Reading Position
|
||||
function saveReadingPosition(storyId, scrollPosition) {
|
||||
const positions = JSON.parse(localStorage.getItem('readingPositions') || '{}');
|
||||
positions[storyId] = {
|
||||
position: scrollPosition,
|
||||
timestamp: Date.now()
|
||||
};
|
||||
localStorage.setItem('readingPositions', JSON.stringify(positions));
|
||||
}
|
||||
|
||||
function getReadingPosition(storyId) {
|
||||
const positions = JSON.parse(localStorage.getItem('readingPositions') || '{}');
|
||||
return positions[storyId]?.position || 0;
|
||||
}
|
||||
|
||||
// Smooth Scroll
|
||||
function scrollToPosition(position) {
|
||||
window.scrollTo({
|
||||
top: position,
|
||||
behavior: 'smooth'
|
||||
});
|
||||
}
|
||||
|
||||
// Touch Gestures (for mobile)
|
||||
let touchStartX = 0;
|
||||
let touchEndX = 0;
|
||||
|
||||
function initTouchGestures() {
|
||||
document.addEventListener('touchstart', (e) => {
|
||||
touchStartX = e.changedTouches[0].screenX;
|
||||
}, { passive: true });
|
||||
|
||||
document.addEventListener('touchend', (e) => {
|
||||
touchEndX = e.changedTouches[0].screenX;
|
||||
handleSwipe();
|
||||
}, { passive: true });
|
||||
}
|
||||
|
||||
function handleSwipe() {
|
||||
const swipeThreshold = 100;
|
||||
const diff = touchStartX - touchEndX;
|
||||
|
||||
// Swipe right (go back)
|
||||
if (diff < -swipeThreshold) {
|
||||
// Only if we're not on the home page
|
||||
if (window.location.pathname !== '/') {
|
||||
goBack();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Keyboard Shortcuts
|
||||
function initKeyboardShortcuts() {
|
||||
document.addEventListener('keydown', (e) => {
|
||||
// Space: Play/Pause (on player page)
|
||||
if (e.code === 'Space' && document.getElementById('playBtn')) {
|
||||
e.preventDefault();
|
||||
togglePlay();
|
||||
}
|
||||
|
||||
// Escape: Go back
|
||||
if (e.code === 'Escape') {
|
||||
if (window.location.pathname !== '/') {
|
||||
goBack();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Audio Player Enhancements
|
||||
function initAudioPlayer() {
|
||||
const audio = document.getElementById('audioPlayer');
|
||||
if (!audio) return;
|
||||
|
||||
// Handle errors
|
||||
audio.addEventListener('error', (e) => {
|
||||
console.error('Audio error:', e);
|
||||
showNotification('播放出错,请重试');
|
||||
});
|
||||
|
||||
// Handle ended
|
||||
audio.addEventListener('ended', () => {
|
||||
isPlaying = false;
|
||||
updatePlayButton();
|
||||
});
|
||||
|
||||
// Handle loading
|
||||
audio.addEventListener('loadstart', () => {
|
||||
showNotification('加载中...', 1000);
|
||||
});
|
||||
}
|
||||
|
||||
// Notification System
|
||||
function showNotification(message, duration = 3000) {
|
||||
// Remove existing notification
|
||||
const existing = document.querySelector('.notification');
|
||||
if (existing) {
|
||||
existing.remove();
|
||||
}
|
||||
|
||||
const notification = document.createElement('div');
|
||||
notification.className = 'notification';
|
||||
notification.textContent = message;
|
||||
notification.style.cssText = `
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
background: var(--bg-card);
|
||||
color: var(--text-primary);
|
||||
padding: 12px 24px;
|
||||
border-radius: 24px;
|
||||
box-shadow: 0 4px 16px var(--shadow);
|
||||
z-index: 9999;
|
||||
font-size: 0.9rem;
|
||||
animation: slideUp 0.3s ease;
|
||||
`;
|
||||
|
||||
document.body.appendChild(notification);
|
||||
|
||||
if (duration > 0) {
|
||||
setTimeout(() => {
|
||||
notification.style.animation = 'slideDown 0.3s ease';
|
||||
setTimeout(() => notification.remove(), 300);
|
||||
}, duration);
|
||||
}
|
||||
|
||||
return notification;
|
||||
}
|
||||
|
||||
// Add animation styles
|
||||
const style = document.createElement('style');
|
||||
style.textContent = `
|
||||
@keyframes slideUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(20px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateX(-50%) translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes slideDown {
|
||||
from {
|
||||
opacity: 1;
|
||||
transform: translateX(-50%) translateY(0);
|
||||
}
|
||||
to {
|
||||
opacity: 0;
|
||||
transform: translateX(-50%) translateY(20px);
|
||||
}
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
|
||||
// Prefetch next chunk (optimization)
|
||||
function prefetchNextChunk(currentIndex) {
|
||||
// Implementation for preloading next audio chunk
|
||||
// This would be implemented in player.html
|
||||
}
|
||||
|
||||
// Performance: Debounce scroll events
|
||||
function debounce(func, wait) {
|
||||
let timeout;
|
||||
return function executedFunction(...args) {
|
||||
const later = () => {
|
||||
clearTimeout(timeout);
|
||||
func(...args);
|
||||
};
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
};
|
||||
}
|
||||
|
||||
// Initialize on DOM ready
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initTheme();
|
||||
initTouchGestures();
|
||||
initKeyboardShortcuts();
|
||||
initAudioPlayer();
|
||||
});
|
||||
|
||||
// Handle page visibility change (pause when switching tabs)
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
const audio = document.getElementById('audioPlayer');
|
||||
if (document.hidden && audio && !audio.paused) {
|
||||
// Optional: pause when switching tabs
|
||||
// audio.pause();
|
||||
// isPlaying = false;
|
||||
// updatePlayButton();
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent zoom on double tap (mobile)
|
||||
let lastTouchEnd = 0;
|
||||
document.addEventListener('touchend', (event) => {
|
||||
const now = Date.now();
|
||||
if (now - lastTouchEnd <= 300) {
|
||||
event.preventDefault();
|
||||
}
|
||||
lastTouchEnd = now;
|
||||
}, { passive: false });
|
||||
|
After Width: | Height: | Size: 778 KiB |
|
After Width: | Height: | Size: 593 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 590 KiB |
|
After Width: | Height: | Size: 586 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 46 KiB |
|
After Width: | Height: | Size: 100 KiB |
|
After Width: | Height: | Size: 108 KiB |
|
After Width: | Height: | Size: 109 KiB |
|
After Width: | Height: | Size: 116 KiB |
|
After Width: | Height: | Size: 45 KiB |
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 104 KiB |
|
After Width: | Height: | Size: 99 KiB |
|
After Width: | Height: | Size: 634 KiB |
|
After Width: | Height: | Size: 583 KiB |
|
After Width: | Height: | Size: 1.3 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 1.6 MiB |
|
After Width: | Height: | Size: 239 KiB |