Skip to content

Instantly share code, notes, and snippets.

@LukeXF
Created November 18, 2014 11:10
Show Gist options
  • Save LukeXF/34d03c3a4bd86ffdf475 to your computer and use it in GitHub Desktop.
Save LukeXF/34d03c3a4bd86ffdf475 to your computer and use it in GitHub Desktop.
Get dat JSON doe
// Load the reduced steam API
var loadsteam = function(){
$.getJSON('api.php', function(data){
/*
var items = [];
$.each( data, function( key, val ) {
items.push( "<li id='" + key + "'>" + val + "</li>" );
});
$( "<ul/>", {
"class": "my-new-list",
html: items.join( "" )
}).appendTo( "body" );
*/
// Set the online state of my steam account
$('#steam_1').html(data.state);
// Coloår the status accordingly
if (data.state == "online") {
$('#steam_1').css({'color': 'green' });
} else {
$('#steam_1').css({'color': 'red' });
};
// Detect if I am playing a game
if (data.gameon != false) {
$('#steam_2').html("I am currently in game playing " + data.playing + ".");
} else {
$('#steam_2').html("And I am not in game.")
};
});
};
loadsteam();
setInterval(function(){
loadsteam();
console.log('updated');
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment