Widget:Pamela
From Whitespace (Hackerspace Gent)
(Difference between revisions)
| Line 1: | Line 1: | ||
| − | <includeonly><div id="pamelaWidget">Loading <a href='http://0x20.be/Pamela'>Pamela</a>...</div><script type="text/javascript">var xmlHttp = null; | + | <includeonly> |
| + | <div id="pamelaWidget">Loading <a href='http://0x20.be/Pamela'>Pamela</a>...</div> | ||
| + | <script type="text/javascript"> | ||
| + | var xmlHttp = null; | ||
| − | function | + | function LoadPamelaCountWidget() |
{ | { | ||
var Url = "http://0x20.be/pam/macs"; | var Url = "http://0x20.be/pam/macs"; | ||
| − | xmlHttp = new XMLHttpRequest(); | + | xmlHttp = new XMLHttpRequest(); |
xmlHttp.onreadystatechange = ProcessRequest; | xmlHttp.onreadystatechange = ProcessRequest; | ||
xmlHttp.open( "GET", Url, true ); | xmlHttp.open( "GET", Url, true ); | ||
xmlHttp.send( null ); | xmlHttp.send( null ); | ||
| − | setTimeout( function() { | + | setTimeout( function() { LoadPamelaCountWidget(); }, 60000 ); |
} | } | ||
| − | function ProcessRequest() | + | function ProcessRequest() |
{ | { | ||
| − | if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) | + | if ( xmlHttp.readyState == 4 && xmlHttp.status == 200 ) |
{ | { | ||
| − | if ( xmlHttp.responseText != "Not found" ) | + | if ( xmlHttp.responseText != "Not found" ) |
{ | { | ||
var macs = eval ( "(" + xmlHttp.responseText + ")" ); | var macs = eval ( "(" + xmlHttp.responseText + ")" ); | ||
| − | |||
document.getElementById( "pamelaWidget" ).innerHTML = "According to <a href='http://0x20.be/Pamela'>Pamela</a> there are " + macs.length + " devices active in the space: " + macs.join( ", " ); | document.getElementById( "pamelaWidget" ).innerHTML = "According to <a href='http://0x20.be/Pamela'>Pamela</a> there are " + macs.length + " devices active in the space: " + macs.join( ", " ); | ||
| − | } | + | } |
} | } | ||
} | } | ||
| − | + | LoadPamelaCountWidget(); | |
| + | </script> | ||
| + | </includeonly> | ||