A Pen by Zoran Stanic on CodePen.
Created
November 11, 2016 00:12
-
-
Save pilgrim011/c1408e782b2d720b764ade59a0adc4cb to your computer and use it in GitHub Desktop.
Twitch.tvx
This file contains 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
<head> | |
<link rel="stylesheet" type="text/css" | |
href="https://fonts.google.com/specimen/Ubuntu?selection.family=Ubuntu"> | |
</head> | |
<body> | |
<div class="text-center container" > | |
<h1> | |
Twitch streamers | |
</h1> | |
<div id= "channels"> | |
<span id = "online"></span> | |
<span id= "offline"></span> | |
<span id = "closed"></span> | |
</div> | |
</div> | |
</body> |
This file contains 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(){ | |
var users = ["comster404", "ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas","brunofin"]; | |
for(i=0;i<users.length;i++){ | |
var getUsers = "https://api.twitch.tv/kraken/streams/" + users[i] + "?callback="; | |
$.getJSON(getUsers, function(data) { | |
if (data.stream===null){ | |
$.getJSON(data._links.channel, function(data2){ | |
$("#offline").append("<h3><a href = https://www.twitch.tv/" + data2.name + " target=_blank>" + data2.display_name + "</a> Offline</h3>"); | |
$("#offline").css("color","grey"); | |
}); | |
} | |
else if (data.stream.game){ | |
$("#online").prepend("<h3><a href = https://www.twitch.tv/" + data.stream.channel.name + " target=_blank>" + data.stream.channel.display_name + "</a>" + " " + data.stream.channel.status + "</h3>"); | |
$("#online").css("color","white"); | |
} | |
}).fail(function(jqXHR) { | |
var tmp = jqXHR.responseJSON.message; | |
var tmparr = tmp.split(" "); | |
var nonuser = tmparr[1].replace(/['"]+/g, ''); | |
console.log(nonuser); | |
$("#closed").append("<h3><a href = https://www.twitch.tv/ target=_blank>" + nonuser + "</a> Account closed </h3>"); | |
$("#closed").css("color","grey"); | |
$("#closed").css("color","grey"); | |
}); | |
} | |
}); |
This file contains 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://code.jquery.com/jquery-2.2.4.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> |
This file contains 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{ | |
font-family:Ubuntu; | |
} | |
h3 { | |
width: 1000px; | |
margin: 10px; | |
border: 3px solid black; | |
background-color:#247A96; | |
} | |
a{ | |
color:#9AA3A6; | |
} |
This file contains 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://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment