Итак, модифицируй мой дизайн так, чтобы он был похож на soundcloud: index.ejs: <!DOCTYPE…
- User
Итак, модифицируй мой дизайн так, чтобы он был похож на soundcloud:
index.ejs:
<title>Home</title><div class="form-group">Search by genre: All
<script>let currentAudio = null;
function togglePlay(index) { const audio = index !== undefined ? document.getElementById(
audio-${index}) : currentAudio; const button = document.querySelector('.audio-player-button');if (!currentAudio) { currentAudio = audio; } if (index !== undefined && currentAudio !== audio) { currentAudio.pause(); currentAudio = audio; } if (audio.paused) { audio.play(); button.innerHTML = '<i class="audio-player-icon fa fa-pause"></i>'; audio.ontimeupdate = () => updateProgress(audio); document.querySelector('.audio-player-controls').style.display = 'flex'; } else { audio.pause(); button.innerHTML = '<i class="audio-player-icon fa fa-play"></i>'; audio.ontimeupdate = null; }}
function setProgressFullwidth(value) { if (!currentAudio) return; currentAudio.currentTime = (value / 100) * currentAudio.duration; updateProgress(currentAudio); }
function updateProgress(audio) { const progressBar = document.querySelector('.progress-bar'); const progressTime = document.getElementById('progress-time-fullwidth'); const value = (audio.currentTime / audio.duration) * 100; progressBar.value = value; const minutes = Math.floor(audio.currentTime / 60); const seconds = Math.floor(audio.currentTime % 60).toString().padStart(2, '0'); progressTime.innerHTML =
${minutes}:${seconds}; }css: .musician-info { display: inline-block; margin-left: 10px; vertical-align: top;
}
.name { font-weight: bold; font-size: 1.2em; }
.genre { display: block; font-size: 0.9em; color: #666; }
ul li a img { max-width: 200px; height: 200px; object-fit: cover; }
/* Normalize CSS */ body { margin: 0; font-family: 'Roboto', sans-serif; font-size: 16px; line-height: 1.5; }
/* Header */ .header { background-color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); }
.navbar-brand img { height: 50px; }
/* Hero */ .hero { background-image: url('/img/hero.jpg'); background-size: cover; background-position: center; color: #fff; padding: 100px 0; }
.hero-title { font-size: 48px; margin-bottom: 20px; }
.nowplaying { font-size: 15px; margin-bottom: 50px; text-align: center; margin-top: 50px; }
.hero-subtitle { font-size: 24px; margin-bottom: 40px; }
.hero .btn-primary { background-color: #ffc107; border-color: #ffc107; }
.hero .btn-primary:hover { background-color: #ffca2c; border-color: #ffca2c; }
/* Search */ .section-search { background-color: #f8f9fa; padding: 80px 0; }
.section-title { font-size: 36px; margin-bottom: 40px; text-align: center; }
.form-search { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; max-width: 800px; margin: 0 auto; position: relative; /* add this */ }
.form-search .btn-primary { position: relative; /* add this / right: 0; / add this / top: 100%; / add this / margin-top: 20px; / add this */ margin-left: 10px; }
.form-group { margin: 10px; }
.form-group select { margin-top: 10px; }
.form-group label { margin-bottom: 5px; display: block; }
.form-control { border-radius: 0; }
.btn-primary { background-color: #ffc107; border-color: #ffc107; }
.btn-primary:hover { background-color: #ffca2c; border-color: #ffca2c; }
/* Results */ .section-results { padding: 80px 0; text-align: center; }
/* Footer */ .footer { background-color: #212529; color: #fff; padding: 20px 0; }
.footer p { margin-bottom: 0; font-size: 14px; }
.footer a { color: #fff; }
.footer a:hover { color: #ffc107; }
/* последние зарегистрированные пользователи */ .musician-card { background-color: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); margin-bottom: 30px; overflow: hidden; }
.musician-info { padding: 20px; }
.musician-info h3 { margin-top: 0; }
.musician-info p { margin-bottom: 10px; }
.musician-link { background-color: #f2f2f2; padding: 15px; text-align: center; }
.musician-link a { color: #333; display: inline-block; font-size: 16px; text-decoration: none; }
/* audio player */ .audio-tracklist { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(auto, 1fr); grid-gap: 20px; list-style: none; max-width: 1200px; margin: 0 auto; padding: 0; }
.audio-track { text-align: center; }
.audio-track-image { width: 100%; height: 0; padding-bottom: 100%; position: relative; overflow: hidden; cursor: pointer; }
.audio-track-image img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.audio-track h4 { margin: 10px 0 0; font-size: 1.2rem; }
.audio-player-controls { position: fixed; bottom: 0; left: 0; width: 100%; background-color: #fff; z-index: 1; }
.audio-player-button { border: none; background-color: transparent; cursor: pointer; font-size: 2rem; color: #666; margin-right: 10px; }
.audio-player-progress-fullwidth { display: flex; flex-direction: row; justify-content: center; align-items: center; flex-grow: 1; }
.audio-player-progress-fullwidth input[type="range"] { flex-grow: 1; margin: 0 10px; -webkit-appearance: none; background-color: #eee; height: 4px; border-radius: 2px; }
.audio-player-progress-fullwidth input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background-color: #666; margin-top: -6px; cursor: pointer; }
.audio-player-progress-fullwidth .progress-time { font-size: 0.8rem; color: #666; }
- Assistant
index.ejs:
<title>Home</title><div class="form-group"> <label for="genre">Search by genre:</label> <select class="form-control" id="genre" name="genre"> <option value="">All</option> </select> </div> <div class="form-group"> <label for="city"><i class="fa fa-map-marker" aria-hidden="true"></i> Location:</label> <input id="city" name="city" type="text" class="form-control" autocomplete="on" value="<%= city %>" data-value=""> </div> <button class="btn btn-primary" type="submit"><i class="fa fa-search" aria-hidden="true"></i> Search</button> </form> </div> </section> <!-- AUDIO PLAYER --> <div class="audio-player"> <h1 class="nowplaying">Now playing</h1> <div class="audio-tracklist"> <% tracks.forEach((track, index) => { %> <div class="audio-track"> <audio id="audio-<%= index %>" src="/tracks/<%= track.filename %>"></audio> <div class="audio-track-image" onclick="togglePlay(<%= index %>)"> <img src="/img/<%= track.image_filename || 'default-track-image.png' %>" alt="<%= track.title %>"> </div> <h4><%= track.title %></h4> </div> <% }); %> </div> <div class="audio-player-controls" style="display: none;"> <button class="audio-player-button" onclick="togglePlay()"> <i class="audio-player-icon fa fa-play"></i> </button> <div class="audio-player-progress-fullwidth"> <input type="range" class="progress-bar" value="0" onchange="setProgressFullwidth(this.value)"> <span class="progress-time" id="progress-time-fullwidth">0:00</span> </div> </div> </div> <!-- END --> </main> <footer class="footer"> <div class="container"> <p class="text-center mb-0">My Musician Site © 2023</p> </div> </footer> <script> let currentAudio = null; function togglePlay(index) { const audio = index !== undefined ? document.getElementById(`audio-${index}`) : currentAudio; const button = document.querySelector('.audio-player-button'); if (!currentAudio) { currentAudio = audio; } if (index !== undefined && currentAudio !== audio) { currentAudio.pause(); currentAudio = audio; } if (audio.paused) { audio.play(); button.innerHTML = '<i class="audio-player-icon fa fa-pause"></i>'; audio.ontimeupdate = () => updateProgress(audio); document.querySelector('.audio-player-controls').style.display = 'flex'; } else { audio.pause(); button.innerHTML = '<i class="audio-player-icon fa fa-play"></i>'; audio.ontimeupdate = null; } } function setProgressFullwidth(value) { if (!currentAudio) return; currentAudio.currentTime = (value / 100) * currentAudio.duration; updateProgress(currentAudio); } function updateProgress(audio) { const progressBar = document.querySelector('.progress-bar'); const progressTime = document.getElementById('progress-time-fullwidth'); const value = (audio.currentTime / audio.duration) * 100; progressBar.value = value; const minutes = Math.floor(audio.currentTime / 60); const seconds = Math.floor(audio.currentTime % 60).toString().padStart(2, '0'); progressTime.innerHTML = `${minutes}:${seconds}`; } </script>css: /* Normalize CSS */ body { margin: 0; font-family: 'Roboto', sans-serif; font-size: 16px; line-height: 1.5; }
/* Header */ .header { background-color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); }
.navbar-brand img { height: 50px; }
/* Hero */ .hero { background-image: url('/img/hero.jpg'); background-size: cover; background-position: center; color: #fff; padding: 100px 0; }
.hero-title { font-size: 48px; margin-bottom: 20px; }
.nowplaying { font-size: 15px; margin-bottom: 50px; text-align: center; margin-top: 50px; }
.hero-subtitle { font-size: 24px; margin-bottom: 40px; }
.hero .btn-primary { background-color: #ffc107; border-color: #ffc107; }
.hero .btn-primary:hover { background-color: #ffca2c; border-color: #ffca2c; }
/* Search */ .section-search { background-color: #f8f9fa; padding: 80px 0; }
.section-title { font-size: 36px; margin-bottom: 40px; text-align: center; }
.form-search { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; max-width: 800px; margin: 0 auto; position: relative; /* add this */ }
.form-
- User
продолжай, ты остановился
- Assistant
олов-group { margin: 10px; }
.form-group select { margin-top: 10px; }
.form-group label { margin-bottom: 5px; display: block; }
.form-control { border-radius: 0; }
.btn-primary { background-color: #ffc107; border-color: #ffc107; }
.btn-primary:hover { background-color: #ffca2c; border-color: #ffca2c; }
/* Results */ .section-results { padding: 80px 0; text-align: center; }
/* Footer */ .footer { background-color: #212529; color: #fff; padding: 20px 0; }
.footer p { margin-bottom: 0; font-size: 14px; }
.footer a { color: #fff; }
.footer a:hover { color: #ffc107; }
/* последние зарегистрированные пользователи */ .musician-card { background-color: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); margin-bottom: 30px; overflow: hidden; }
.musician-info { padding: 20px; }
.musician-info h3 { margin-top: 0; }
.musician-info p { margin-bottom: 10px; }
.musician-link { background-color: #f2f2f2; padding: 15px; text-align: center; }
.musician-link a { color: #333; display: inline-block; font-size: 16px; text-decoration: none; }
/* audio player */ .audio-tracklist { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(auto, 1fr); grid-gap: 20px; list-style: none; max-width: 1200px; margin: 0 auto; padding: 0; }
.audio-track { text-align: center; }
.audio-track-image { width: 100%; height: 0; padding-bottom: 100%; position: relative; overflow: hidden; cursor: pointer; }
.audio-track-image img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.audio-track h4 { margin: 10px 0 0; font-size: 1.2rem; }
.audio-player-controls { position: fixed; bottom: 0; left: 0; width: 100%; background-color: #fff; z-index: 1; }
.audio-player-button { border: none; background-color: transparent; cursor: pointer; font-size: 2rem; color: #666; margin-right: 10px; }
.audio-player-progress-fullwidth { display: flex; flex-direction: row; justify-content: center; align-items: center; flex-grow: 1; }
.audio-player-progress-fullwidth input[type="range"] { flex-grow: 1; margin: 0 10px; -webkit-appearance: none; background-color: #eee; height: 4px; border-radius: 2px; }
.audio-player-progress-fullwidth input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background-color: #666; margin-top: -6px; cursor: pointer; }
.audio-player-progress-fullwidth .progress-time { font-size: 0.8rem; color: #666; }
- User
Окей, теперь модифицируй этот код таким образом, чтобы сайт был похож на soundcloud
- Assistant
index.ejs:
<title>Home</title><div class="audio-player-controls" style="display: none;"> <button class="audio-player-button" onclick="togglePlay()"> <i class="fa fa-play"></i> </button> <div class="audio-player-progress-fullwidth"> <input type="range" class="progress-bar" value="0" onchange="setProgressFullwidth(this.value)"> <span class="progress-time" id="progress-time-fullwidth">0:00</span> </div> </div> </main> <footer class="footer"> <div class="container"> <p class="text-center mb-0">My Musician Site © 2023</p> </div> </footer> <script> let currentAudio = null; function togglePlay(index) { const audio = index !== undefined ? document.getElementById(`audio-${index}`) : currentAudio; const button = document.querySelector('.audio-player-button'); if (!currentAudio) { currentAudio = audio;}
if (index !== undefined && currentAudio !== audio) { currentAudio.pause(); currentAudio = audio; } if (audio.paused) { audio.play(); button.innerHTML = '<i class="fa fa-pause"></i>'; audio.ontimeupdate = () => updateProgress(audio); document.querySelector('.audio-player-controls').style.display = 'flex'; } else { audio.pause(); button.innerHTML = '<i class="fa fa-play"></i>'; audio.ontimeupdate = null; } } function setProgressFullwidth(value) { if (!currentAudio) return; currentAudio.currentTime = (value / 100) * currentAudio.duration; updateProgress(currentAudio); } function updateProgress(audio) { const progressBar = document.querySelector('.progress-bar'); const progressTime = document.getElementById('progress-time-fullwidth'); const value = (audio.currentTime / audio.duration) * 100; progressBar.value = value; const minutes = Math.floor(audio.currentTime / 60); const seconds = Math.floor(audio.currentTime % 60).toString().padStart(2, '0'); progressTime.innerHTML = `${minutes}:${seconds}`; } </script>css:
/* Normalize CSS */ body { margin: 0; font-family: 'Roboto', sans-serif; font-size: 16px; line-height: 1.5; }
/* Header */ .header { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); }
.navbar-brand img { height: 50px; }
/* Search */ .section-search { background-color: #fff; padding-top: 80px; padding-bottom: 80px; }
.card-columns { column-count: 3; }
.card { margin-bottom: 20px; }
.img-fluid { width: 100%; height: auto; }
.card-title { font-size: 1.2rem; }
/* Footer */ .footer { background-color: #212529; color: #fff; padding: 20px 0; }
.footer p { margin-bottom: 0; font-size: 14px; }
.footer a { color: #fff; }
.footer a:hover { color: #ffc107; }
/* Audio Player Controls */ .audio-player-controls { position: fixed; bottom: 0; left: 0; width: 100%; background-color: #fff; display: flex; align-items: center; justify-content: center; padding: 10px 0; box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1); }
.audio-player-button { border: none; background-color: transparent; cursor: pointer; font-size: 2rem; color: #666; margin-right: 10px; }
.audio-player-progress-fullwidth { display: flex; flex-direction: row; justify-content: center; align-items: center; flex-grow: 1; }
.audio-player-progress-fullwidth input[type="range"] { flex-grow: 1; margin: 0 10px; -webkit-appearance: none; background-color: #eee; height: 4px; border-radius: 2px; }
.audio-player-progress-fullwidth input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%; background-color: #666; margin-top: -6px; cursor: pointer; }
.audio-player-progress-fullwidth .progress-time { font-size: 0.8rem; color: #666; }
.search-input { color: #fff; background-color: rgba(255,255,255,.1); border: none; outline: none; ::placeholder { color: #fff; } }
.search-button { border: none; background-color: transparent; cursor: pointer; font-size: 1.2rem; color: #fff; margin-left: 5px; }
@media (max-width: 767px) { .card-columns { column-count: 1; } }