Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function(){
- var channels = ['ESL_SC2', 'OgamingSC2', 'cretetion', 'freecodecamp', 'storbeck', 'habathcx', 'RobotCaleb', 'noobs2ninjas'];
- getChannelsNames();
- function getChannelsNames(){
- var myHtml = '', status = 'Offline';
- channels.forEach(function(channel, callback){
- $.getJSON('https://wind-bow.glitch.me/twitch-api/streams/' + channel, function(json){
- status = onlineStatus(json);
- myHtml += infoChannels(channel, status);
- }).fail(function(){
- console.log('Error');
- myHtml += infoChannels(channel, status);
- });
- });
- $('.channels').html(myHtml);
- }
- function onlineStatus(json){
- if(json.stream){
- return json.stream.game;
- } else {
- return 'Offline';
- }
- }
- function infoChannels(channel, status){
- return "<div class='row'><div class='col-12 col-md-4 bg-info'>" + channel + "</div><div class='col-12 col-md-8 bg-primary text-center'>" + status + "</div></div>";
- }
- });
Add Comment
Please, Sign In to add comment