View Single Post
Old 10-05-2012, 05:23 PM   PM User | #8
erebus
New Coder

 
Join Date: Sep 2012
Location: Houston, TX
Posts: 22
Thanks: 2
Thanked 0 Times in 0 Posts
erebus is an unknown quantity at this point
if it could help... sure

Code:
<div class="image-articles articles">
            <div class="cl">&nbsp;</div>
            <div class="article">
              <div class="cl">&nbsp;</div>
              <div class="image"> <a href="http://dayzlive.com/"><img src="images/erebus.gif" id="streamlogo1" alt="" /></a> </div>
              <div class="cnt">
                <h4 id="streamname1"><a href="http://dayzlive.com/">#1 Stream</a></h4>
                <p id="streaminfo1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed elementum molestie </p>
              </div>
              <div class="cl">&nbsp;</div>
            </div>
            <div class="article">
              <div class="cl">&nbsp;</div>
              <div class="image"> <a href="http://dayzlive.com/"><img src="images/freckelzicon.jpg" id="streamlogo2" alt="" /></a> </div>
              <div class="cnt">
                <h4 id="streamname2"><a href="http://dayzlive.com/">#2 Stream</a></h4>
                <p id="streaminfo2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed elementum molestie </p>
              </div>
              <div class="cl">&nbsp;</div>
            </div>
            <div class="article">
              <div class="cl">&nbsp;</div>
              <div class="image"> <a href="http://dayzlive.com/"><img src="images/sacriel.jpeg" id="streamlogo3" alt="" /></a> </div>
              <div class="cnt">
                <h4 id="streamname3"><a href="http://dayzlive.com/">#3 Stream</a></h4>
                <p id="streaminfo3">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed elementum molestie </p>
              </div>
              <div class="cl">&nbsp;</div>
            </div>
This is the existing code... the things marked with ID's streamlogo1,2, and 3 are to be replaced with the logo variable...

the streamname1,2 and 3 to be replaced with the channel.name variable

and i also like to insert the viewers into the begining of the ipsum text..

i tried just replaceing the elements but there is a delay where you see the old info for a moment and then it gets replaced... which is not acceptable.. here is that code by the way...

Code:
<script type="text/javascript">
function showGame(o){
var thediv=document.getElementById("results")
var base=o.query.results.json.streams;
for (var i = 0; i < base.length; i++) {
document.getElementById("streamlogo1").src=base[0].channel.logo;
document.getElementById("streamlogo2").src=base[1].channel.logo;
document.getElementById("streamlogo3").src=base[2].channel.logo;

document.getElementById("streamname1").innerHTML=base[0].channel.name;
document.getElementById("streamname2").innerHTML=base[1].channel.name;
document.getElementById("streamname3").innerHTML=base[2].channel.name;

document.getElementById("streaminfo1").innerHTML="<b>Viewers: "+base[0].viewers+"</b><br><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed elementum molestie urna...</p>";
document.getElementById("streaminfo2").innerHTML="<b>Viewers: "+base[1].viewers+"</b><br><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed elementum molestie urna</p>";
document.getElementById("streaminfo3").innerHTML="<b>Viewers: "+base[2].viewers+"</b><br><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed elementum molestie urna</p>";
	}
}	

var myurl=encodeURIComponent("https://api.twitch.tv/kraken/streams?game=DayZ&limit=3")

scr=document.createElement("script");
scr.type="text/javascript"
scr.src='http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20json%20where%20url%3D%22'+myurl+'%2F%22&format=json&callback=showGame';
document.body.appendChild(scr);
</script>
erebus is offline   Reply With Quote