-
-
Save LukeXF/34d03c3a4bd86ffdf475 to your computer and use it in GitHub Desktop.
Get dat JSON doe
This file contains hidden or 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
// 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