Created
October 17, 2016 00:52
-
-
Save anonymous/195c190bb01d2eb85627881529be3636 to your computer and use it in GitHub Desktop.
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
<div id="widget-song">...</div> | |
<script type="text/javascript"> | |
var datoActual = ""; | |
(function consultarTrack(){ | |
var request = new XMLHttpRequest(); | |
request.open('GET', 'http://softcloudradio.com/trackdata.php', true); | |
request.onload = function() { | |
if (request.status >= 200 && request.status < 400) { | |
// Success! | |
var data = request.responseText; | |
if (datoActual.localeCompare(data) != 0) { | |
datoActual = data; | |
var artista = datoActual.match('<body>(.*?)</body>')[1].split(",").pop().split(" - ")[0]; | |
var cancion = datoActual.match('<body>(.*?)</body>')[1].split(",").pop().split(" - ").pop(); | |
$("#widget-song").html(artista + " - " + cancion); | |
} | |
} else { | |
console.debug("error"); | |
} | |
}; | |
request.onerror = function() { | |
console.debug("error"); | |
}; | |
request.send(); | |
setTimeout(consultarTrack,10000); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment