Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide community favorites shortcut #385

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,24 @@ a {
margin: 0 auto;
}

#focus-btn {
#com-fav-btn {
display: flex;
justify-content: center;
}

#fav-btn {
display: block;
margin: 0 auto;
width: fit-content;
}

#focus-btn, #lofi-btn {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a CSS class instead of two IDs

margin-right: 5px;
width: fit-content;
text-align: center;
display: none;
}

#zen-video-description {
white-space: pre-line;
}
Expand Down
25 changes: 18 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
<!-- Global site tag (gtag.js) - Google Analytics -->
<script src="https://www.googletagmanager.com/gtag/js?id=UA-62983413-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag("js", new Date());
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag("js", new Date());

gtag("config", "UA-62983413-1");
gtag("send", "pageview");
gtag("config", "UA-62983413-1");
gtag("send", "pageview");
</script>

<script src="js/zap-common.js"></script>
Expand Down Expand Up @@ -110,10 +110,21 @@ <h3>

<div>
<br>
<button class="btn" id="focus-btn">
<button class="btn" id="fav-btn">
<i class="fa fa-headphones"></i>
Focus
Community favorites
</button>
<br>
<div id="com-fav-btn">
<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>
</div>
<!-- footer -->
Expand Down
30 changes: 25 additions & 5 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 = "5qap5aO4i9A";

// Some demo video's audio, feel free to add more
var demos = [
Expand Down Expand Up @@ -667,6 +669,13 @@ $(function() {
}
});

// Handle community favorites click
$("#fav-btn").click(function(event) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can refactor away this button

event.preventDefault();
$( "#focus-btn" ).toggle();
$( "#lofi-btn" ).toggle();
});

// Handle focus link click
$("#focus-btn").click(function(event) {
event.preventDefault();
Expand All @@ -675,19 +684,30 @@ $(function() {
window.location.href = makeListenURL(focusId);
});

// Check if the current ID is the focus ID
// 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 community focus ID
$(window).on("load", function() {
// Show Focus Button
if (window.location.href.indexOf(focusId) === -1) {
$("#focus-btn").show();
$("#fav-btn").show();
}
// Show Lofi Button
else if (window.location.href.indexOf(lofiId) === -1) {
$("#fav-btn").show();
}
else {
// Hide Focus Button
$("#focus-btn").hide();
// Hide community favorites Button
$("#fav-btn").hide();
}
});


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

Expand Down