A new Riff-radio.org site with a static approach.

refresh.js 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. var seconds = 1;
  2. var divid = "shoutcastdiv";
  3. var url = "test.txt";
  4. ////////////////////////////////
  5. //
  6. // Refreshing the DIV
  7. //
  8. ////////////////////////////////
  9. function refreshdiv(){
  10. // The XMLHttpRequest object
  11. var xmlHttp;
  12. try{
  13. xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
  14. }
  15. catch (e){
  16. try{
  17. xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // Internet Explorer
  18. }
  19. catch (e){
  20. try{
  21. xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  22. }
  23. catch (e){
  24. alert("Your browser does not support AJAX.");
  25. return false;
  26. }
  27. }
  28. }
  29. // Timestamp for preventing IE caching the GET request
  30. fetch_unix_timestamp = function()
  31. {
  32. return parseInt(new Date().getTime().toString().substring(0, 10))
  33. }
  34. var timestamp = fetch_unix_timestamp();
  35. var nocacheurl = url+"?t="+timestamp;
  36. // The code...
  37. xmlHttp.onreadystatechange=function(){
  38. if(xmlHttp.readyState==4){
  39. document.getElementById(divid).innerHTML=xmlHttp.responseText;
  40. setTimeout('refreshdiv()',seconds*1000);
  41. }
  42. }
  43. xmlHttp.open("GET",url,true);
  44. xmlHttp.send(null);
  45. }
  46. // Start the refreshing process
  47. window.onload = function startrefresh(){
  48. setTimeout('refreshdiv()',seconds*1000);
  49. }