Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Changes button title to follow standard
- Some minor improvements
- Changes container width to fit new button
  • Loading branch information
lcpunch committed Apr 16, 2020
1 parent 9e2ca07 commit 1542423
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
2 changes: 1 addition & 1 deletion css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ a {
@media all and (min-width: 480px) {

#container {
max-width: 450px;
max-width: 480px;
}

}
Expand Down
39 changes: 15 additions & 24 deletions js/everything.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global URI getSearchResults, getAutocompleteSuggestions, parseYoutubeVideoID, getYouTubeVideoDescription */
/* global URI getSearchResults, getAutocompleteSuggestions, parseYoutubeVideoID, getYouTubeVideoDescription, getYouTubeVideoPlaylist */

var keyCodes = {
SPACEBAR: 32
Expand Down Expand Up @@ -300,17 +300,14 @@ var ZenPlayer = {
// toggle auto next song playing
$("#toggleAutoplay").click(function(event) {
var toggleTextElement = $("#" + event.currentTarget.id);

if (!autoplayState) {
autoplayState = true;
toggleTextElement.text("Stop autoplay");
}
else if (autoplayState === true) {
toggleTextElement.text("Start autoplay");
autoplayState = false;
toggleTextElement.text("Stop Autoplay");
}
else {
toggleTextElement.text("Stop autoplay");
autoplayState = true;
toggleTextElement.text("Autoplay");
autoplayState = false;
}
});
},
Expand Down Expand Up @@ -582,10 +579,10 @@ function pickDemo() {

function updateAutoplayToggle(state) {
if (state) {
$("#toggleAutoplay").text("Stop autoplay");
$("#toggleAutoplay").text("Stop Autoplay");
}
else {
$("#toggleAutoplay").text("Start autoplay");
$("#toggleAutoplay").text("Autoplay");
}
}

Expand Down Expand Up @@ -637,25 +634,19 @@ $(function() {
$("#v").attr("value", currentVideoID);
// get similar videos, populate playList
if (!isFileProtocol()) {
$.ajax({
url: "https://www.googleapis.com/youtube/v3/search",
dataType: "json",
async: false,
data: {
key: youTubeDataApiKey,
part: "snippet",
type: "video",
relatedToVideoId: currentVideoID
},
success: function(data) {
getYouTubeVideoPlaylist(
currentVideoID,
youTubeDataApiKey,
function(data) {
// push items into playlist
for (var i = data.items.length - 1; i > -1; i--) {
playList.push(data.items[i].id.videoId);
}
},
function(jqXHR, textStatus, errorThrown) {
logError(jqXHR, textStatus, errorThrown, "Related video lookup error");
}
}).fail(function(jqXHR, textStatus, errorThrown) {
logError(jqXHR, textStatus, errorThrown, "Related video lookup error");
});
);
}
}
else {
Expand Down
15 changes: 15 additions & 0 deletions js/zap-common.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ function getYouTubeVideoDescription(videoID, youTubeDataApiKey, onSuccess, onFai
}).fail(onFail);
}

function getYouTubeVideoPlaylist(videoID, youTubeDataApiKey, onSuccess, onFail) {
$.ajax({
url: "https://www.googleapis.com/youtube/v3/search",
dataType: "json",
async: false,
data: {
key: youTubeDataApiKey,
part: "snippet",
type: "video",
relatedToVideoId: videoID
},
success: onSuccess
}).fail(onFail);
}

/**
* Given a YouTube video ID, YouTube.com video URL, or YouTu.Be video URL, return an object
* containing the method used to derive the ID, and the ID itself. The following were used to test;
Expand Down

0 comments on commit 1542423

Please sign in to comment.