Jeg baksede et hurtigt javascript sammen som hentede det nuværende nummer som spiller fra min favorit radiostation. Det er hverken kønt eller specielt brugbart men det slog da en times tid ihjel.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | function HttpRequest(url){ var pageRequest = false //variable to hold ajax object if (!pageRequest && typeof XMLHttpRequest != 'undefined') pageRequest = new XMLHttpRequest() if (pageRequest){ //if pageRequest is not false pageRequest.open('GET', url, false) //get page synchronously pageRequest.send(null) embedpage(pageRequest) } } function embedpage(request){ //if viewing page offline or the document was successfully retrieved online (status code=2000) if (window.location.href.indexOf("http")==-1 || request.status==200) var ebmContent = request.responseText; var re = /<p\s*[^>]*>([\S\s]*?)<\/p>/g; var match = re.exec( ebmContent.substring(2200, 3000) ); var CurrentTrack = match[1]; CurrentTrack = CurrentTrack.replace(/&(lt|gt);/g, function (strMatch, p1){ return (p1 == "lt")? "<" : ">";}); //remove tags CurrentTrack = CurrentTrack.replace(/<\/?[^>]+(>|$)/g, ""); CurrentTrack = CurrentTrack.replace(/^\s*|\s*$/g,''); //remove additional whitespaces CurrentTrack = CurrentTrack.replace(/\s/g,'+'); //turn whitespaces into + window.location = "http://www.twitter.com/home?status=EBM-radio+is+playing+:::+"+ CurrentTrack; } HttpRequest("http://www.ebm-radio.de/scripts/latest_tracks/scxml_onlydata.php") //include "external.htm" onto current page |