FreeCodeCamp : Use the Twitchtv JSON API
How do I make an freecodecamp : use the twitchtv json api?
What is a freecodecamp : use the twitchtv json api? How do you make a freecodecamp : use the twitchtv json api? This script and codes were developed by Markku Lehmonen on 30 November 2022, Wednesday.
FreeCodeCamp : Use the Twitchtv JSON API - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>FreeCodeCamp : Use the Twitchtv JSON API</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>Twitch Stream Magic</h1>
<div id="streamContainerOnline">
</div>
<div id="streamContainer"> <div id="streamItemPrefab" class="streamItem"> <a href="" class="streamLink"><img class="streamAvatar" src="https://tinyurl.com/jf9uu7d" alt="Image Placeholder" width="100" height="100"/></a> <div class="streamInfo"> <a href="" class="streamLink"><h2><span class="streamName"></span></a> <small class="streamStatus"></small></h2> <h3 class="streamTopic"></h3> <h3 class="streamActivity"><small class="label"></small> <span class="streamCategory"></span></h3> </div> </div>
</div>
<div id="streamContainerDeleted">
</div>
<!--<div id="testOutput">testOutput</div>--> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
FreeCodeCamp : Use the Twitchtv JSON API - Script Codes CSS Codes
body {font-family:Calibri; text-align:center;}
h1 {text-transform:uppercase;}
h2, h3 {margin:0px;}
/* unvisited link */
img {border:4px solid white; border-radius:4px;}
img:hover {border:4px solid orange;}
.streamContainer:hover, .streamContainerOnline:hover {opacity:1.0;}
a:link {color:black; text-decoration:none;}
a:visited {color:black; text-decoration:none;}
a:hover {color:orange; text-decoration:none;}
a:active {color:black; text-decoration:none;}
#streamContainer, #streamContainerOnline, #streamContainerDeleted {text-align:left; padding:15px; padding-bottom:0px; width:700px; margin:0 auto;}
.streamItem { padding:15px; margin-bottom:15px; overflow:auto;}
.streamItem img {float:left;}
.streamItem .streamInfo { padding-top:8px; margin-left:15px; float:left;}
.streamItem .streamInfo .streamName { /*text-transform:uppercase;*/ }
.streamItem .streamInfo .streamStatus {color:#999999;}
.streamItem .streamInfo .streamTopic {color:#666666;}
.streamItem .streamInfo .streamActivity {font-weight:normal;}
.streamItem .streamInfo .streamCategory {color:#888888;}
#streamItemPrefab { display:none; }
/*#testID_0 {color:red;}
#testID_1 {color:green;}
#testID_2 {color:blue;}*/
FreeCodeCamp : Use the Twitchtv JSON API - Script Codes JS Codes
var channels = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas", "brunofin", "comster404"];
$(document).ready(function() { for(var i = 0; i < channels.length; i++) { $.getJSON("https://wind-bow.hyperdev.space/twitch-api/channels/" + channels[i] + "?callback=?", function(data) { if(data.error !== "Not Found") { var streamItem = $("#streamItemPrefab").clone().appendTo("#streamContainer").css("display","block"); streamItem.find(".streamLink").prop("href", "https://www.twitch.tv/"+data.name); streamItem.find(".streamName").html(data.name); streamItem.prop("id", data.name); streamItem.find(".streamStatus").html("offline"); streamItem.find(".streamAvatar").prop("src", data.logo); streamItem.css("opacity", "0.3"); $.getJSON("https://wind-bow.hyperdev.space/twitch-api/streams/" + data.name + "?callback=?", function(data) { var streamItem = $(document).find("#"+data.stream.channel.name); streamItem.find(".streamStatus").html("<span style='color:green'>online</span>"); streamItem.find(".streamTopic").html(stringCutter(data.stream.channel.status, 70)); streamItem.find(".label").html("Streaming"); streamItem.find(".streamCategory").html(data.stream.game); streamItem.css("opacity", "1.0"); // Switch to Online Container streamItem.clone().appendTo("#streamContainerOnline"); streamItem.remove(); }); } else { //alert("error"); var streamItem = $("#streamItemPrefab").clone().appendTo("#streamContainerDeleted").css("display","block"); streamItem.css("opacity", "0.5"); streamItem.find(".streamTopic").html(stringCutter(data.message, 70)); // Quick Fix to disable hyperlink streamItem.find(".streamAvatar").hover(function() { $(this).css("border-color","white"); $(this).css("cursor","default"); }); streamItem.find('.streamLink').click(function(e) { e.preventDefault(); }); } }); }
});
function stringCutter(str, length) { if(str.length >= length) str = str.slice(0,length-3) + "..."; return str;
}
Developer | Markku Lehmonen |
Username | SharpDal |
Uploaded | November 30, 2022 |
Rating | 3 |
Size | 3,038 Kb |
Views | 12,144 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
A Pen by Markku Lehmonen | 7,804 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Simple Login Form | JoshBlackwood | 4,418 Kb |
Weather App | OmranAbazid | 2,596 Kb |
Twitch Live Channels | Inkblotty | 4,956 Kb |
Voting App - register | MatheusLima92 | 1,948 Kb |
A Pen by Mohomed Anees | Mohomedanees | 12,597 Kb |
Wavy Road with Dashes | Jonobr1 | 2,679 Kb |
DFF Website | Hawcubite | 10,123 Kb |
Slider for stackoverflow | KKOKU | 3,222 Kb |
Marching Squares Visualized | Sakri | 7,074 Kb |
Example SVGZ Data URI | Joeyhoer | 2,981 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!