A Pen by VenomSnake on CodePen.
Created
December 2, 2017 11:40
-
-
Save HuangStanley050/20f23184709d593196f460e5c823161c to your computer and use it in GitHub Desktop.
Twitch TV API exercise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<body> | |
<div class="container-fluid"> | |
<h1 class="text-center" style="background-color:lavender;">Twitch Streamers</h1> | |
<div class="row"> | |
<div class="col-md-4" style="background-color:Aqua;"> | |
<img src="https://pbs.twimg.com/media/C6PR9SfWUAA1DoF.jpg" class="horizontal" style="width: 90px";> | |
<a id="test1" href="https://go.twitch.tv/zwan_oj" target="_blank"><P class="horizontal">Zwan</P></a> | |
</div> | |
<div class="col-md-4" style="background-color:Tomato;"> | |
<img src="https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-profile_image-d9514f2df0962329-300x300.png" class="horizontal" style="width: 50px";> | |
<a id="test2" href="https://go.twitch.tv/freecodecamp" target="_blank"><p class="horizontal">FreeCodeCamp</p></a> | |
</div> | |
<div class="col-md-4" style="background-color:DeepSkyBlue;"> | |
<img src="https://static-cdn.jtvnw.net/jtv_user_pictures/esl_sc2-profile_image-d6db9488cec97125-300x300.jpeg" class="horizontal" style="width: 50px";> | |
<a id="test3" href="https://go.twitch.tv/esl_sc2" target="_blank"><p class="horizontal">ESL_SC2</p></a> | |
</div> | |
</div> | |
</div> | |
</div> | |
</body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
//test user zwan status | |
$.getJSON( "https://wind-bow.glitch.me/twitch-api/streams/zwan_oj", function( data ) { | |
console.log(data["stream"]); //show the online or offline status of the channel ["stream"]// | |
//console.log(data["stream"]["channel"]["status"]); //show the what's being played | |
if ( data["stream"] != null) { | |
console.log(data["stream"]["channel"]["status"]); | |
var description = data["stream"]["channel"]["status"]; | |
var new_sliced = description.slice(0,30); | |
$("#test1").append("<p class=\"horizontal\">"+"--->"+new_sliced+"</p>") | |
} | |
else { | |
//console.log("Offline"); | |
$("#test1").append("<p class=\"horizontal\">--->Offline</p>") | |
} | |
}); | |
//end checking zwan status | |
//checking freecodecamp status | |
$.getJSON( "https://wind-bow.glitch.me/twitch-api/streams/freecodecamp", function( data ) { | |
console.log(data["stream"]); //show the online or offline status of the channel ["stream"]// | |
//console.log(data["stream"]["channel"]["status"]); //show the what's being played | |
if ( data["stream"] != null) { | |
console.log(data["stream"]["channel"]["status"]); | |
var description = data["stream"]["channel"]["status"]; | |
var new_sliced = description.slice(0,30); | |
$("#test2").append("<p class=\"horizontal\">"+"--->"+new_sliced+"</p>") | |
} | |
else { | |
//console.log("Offline"); | |
$("#test2").append("<p class=\"horizontal\">--->Offline</p>") | |
} | |
}); | |
//end checking freecodecamp status | |
//check stats on user ESL_SC2 | |
$.getJSON( "https://wind-bow.glitch.me/twitch-api/streams/esl_sc2", function( data ) { | |
//console.log(data["stream"]); //show the online or offline status of the channel ["stream"]// | |
//console.log(data["stream"]["channel"]["status"]); //show the what's being played | |
if ( data["stream"] != null) { | |
console.log(data["stream"]["channel"]["status"]); | |
var description = data["stream"]["channel"]["status"]; | |
var new_sliced = description.slice(0,30); | |
$("#test3").append("<p class=\"horizontal\">"+"--->"+new_sliced+"</p>") | |
} | |
else { | |
//console.log("Offline"); | |
$("#test3").append("<p class=\"horizontal\">--->Offline</p>") | |
} | |
}); | |
//end of checking ESL_SC2 status | |
/*$.getJSON( "https://wind-bow.glitch.me/twitch-api/streams/zwan_oj", function( data ) { | |
console.log(data); | |
});*/ | |
}); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
background-color: lightblue; | |
} | |
.horizontal { | |
display: inline-block; | |
} | |
img { | |
border-radius: 50%; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment