Skip to content

Commit

Permalink
Merge pull request #427 from ShivaniG14/community-favorites
Browse files Browse the repository at this point in the history
Added Lofi button to favorites panel
  • Loading branch information
shakeelmohamed committed Dec 26, 2023
2 parents d6c013c + c95e583 commit e1a3fa6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
14 changes: 11 additions & 3 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,20 @@ a {
#demo {
display: block;
margin: 0 auto;
margin-bottom: 15px;
}

.fav-panel {
display: flex;
justify-content: center;
}

#focus-btn {
display: block;
margin: 0 auto;
width: fit-content;
margin-right: 8px;
}

#lofi-btn {
margin-left: 8px;
}

#zen-video-description {
Expand Down
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ <h3>
Click for Demo
</button>

<div>
<div class="fav-panel">
<br>
<button class="btn" id="focus-btn">
<i class="fa fa-headphones"></i>
Focus
</button>
<button class="btn" id="lofi-btn">
<i class="fa fa-headphones"></i>
Lofi
</button>
</div>
</div>
<!-- footer -->
Expand Down
24 changes: 24 additions & 0 deletions js/everything.js
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,8 @@ function wrapParseYouTubeVideoID(url) {

// The focus video ID
var focusId = "pJ5FD9_Orbg";
// The lofi video ID
var lofiId = "i43tkaTXtwI";

// Some demo video's audio, feel free to add more
var demos = [
Expand Down Expand Up @@ -627,6 +629,7 @@ $(function() {
else {
// Show the Focus button If there is no search
$("#focus-btn").show();
$("#focus-btn").css("display", "inline");
errorMessage.show("Try entering a YouTube video ID or URL!");
}
});
Expand Down Expand Up @@ -680,13 +683,34 @@ $(function() {
// Show Focus Button
if (window.location.href.indexOf(focusId) === -1) {
$("#focus-btn").show();
$("#focus-btn").css("display", "inline");
}
else {
// Hide Focus Button
$("#focus-btn").hide();
}
});

// Handle lofi link click
$("#lofi-btn").click(function(event) {
event.preventDefault();
gtag("send", "event", "lofi", "clicked");
// Redirect to the favorite "lofi" URL
window.location.href = makeListenURL(lofiId);
});

// Check if the current ID is the lofi ID
$(window).on("load", function() {
// Show Lofi Button
if (window.location.href.indexOf(lofiId) === -1) {
$("#lofi-btn").show();
$("#lofi-btn").css("display", "inline");
}
else {
// Hide Lofi Button
$("#lofi-btn").hide();
}
});

// Load the player
ZenPlayer.init(currentVideoID);
Expand Down

0 comments on commit e1a3fa6

Please sign in to comment.