Created
June 23, 2015 17:07
-
-
Save CBenni/f5d859c95b8490809e86 to your computer and use it in GitHub Desktop.
bdYgwY
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
Select a channel: <input type="text" id="channelSel" value="cbenni"/> | |
<div id="stream"><iframe src="http://www.twitch.tv/smites/embed" frameborder="0" scrolling="no" height="378" width="620"></iframe></div> |
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
$(function(){ | |
setInterval(checkStreamOnline,30000); | |
checkStreamOnline(); | |
$("#channelSel").change(checkStreamOnline); | |
}); | |
function checkStreamOnline() | |
{ | |
$.ajax({url:"https://api.twitch.tv/kraken/streams/",data:{"channel":$("#channelSel").val(),"callback":"streamsCallback"},crossDomain: true,dataType: 'jsonp'}); | |
} | |
function streamsCallback(data) | |
{ | |
if(data.streams.length>0) | |
{ | |
$("#stream").show("slow"); | |
} | |
else | |
{ | |
$("#stream").hide("slow"); | |
} | |
} |
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="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment