var qintv_ms = 5000; var uripart = "/updates?"; //var lastfrom = ""; //var lastfrom = "from="+(new Date(Date.now() - 10*60*1000)).toISOString(); var lastfrom="?limit=120"; //console.log(lastfrom); //var possible_display_functions = {"Off":"none", "Value":showvalue, "Gauge":showgauge, "Graph":showasgraph}; var possible_display_functions = {"Off":"none", "Value":showvalue, "Graph":showasgraph}; var stuff_to_display = {"clients":"none","*":showvalue,"client-count":showasgraph, "bytes-sent":showasgraph}; var sidseen = []; $(document).ready(function() { updateS5Stats(); setInterval("updateS5Stats()", qintv_ms); }); function getstreamdiv(sid) { var elem = $("#"+sid); if (elem.length<1) { $("#content").append('

Stream: '+sid+'

'); $("#menu").append(''+sid+' '); elem = $("#"+sid); } return elem; } function killvalue(name, nosetselect) { stuff_to_display[name]="none"; $.each(sidseen,function(index,sid){ $("#li-"+sid+"_"+name).remove() }); if (nosetselect != 1) { document.getElementById("opts-"+name).selectedIndex=0; } } function showvalue(sid, name) { var divid = sid+"_"+name; var elem = $("#"+divid); if (elem.length<1) { getstreamdiv(sid).append('
  • '+ name +'
  • '); elem = $("#"+divid); } var jsdvalue = graphdata[divid][graphdata[divid].length-1]; var jsdate = jsdvalue[0]; var value = jsdvalue[1]; elem.html(""+value+"
    @"+jsdate.toLocaleDateString()+" "+jsdate.toLocaleTimeString()+""); } var gauges = {}; function showgauge(sid, name) { var divid = sid+"_"+name; var elem = document.getElementById(divid); if (!elem) { getstreamdiv(sid).append('
  • '+ name +'
  • '); elem = document.getElementById(divid); gauges[divid] = new google.visualization.Gauge(elem); } var value = graphdata[divid][graphdata[divid].length-1][1]; var data = google.visualization.arrayToDataTable([["Label", "Value"],[name,value]]); gauges[divid].draw(data, {}); } var graphs = {} function showasgraph(sid, name) { var divid = sid+"_"+name; var elem = document.getElementById(divid); if (!elem) { getstreamdiv(sid).append('
  • '+ name +'
  • '); elem = document.getElementById(divid); graphs[divid] = new Dygraph(elem,graphdata[divid],{legend:'none',title:sid+"-"+name,labels:["Date/Time",name]}); } else { graphs[divid].updateOptions({'file':graphdata[divid]}); } } var graphdata = {} function savedata(sid, name, value, jsdate) { var divid = sid+"_"+name; if (!graphdata[divid]) { graphdata[divid]=[]; } graphdata[divid].push([jsdate,value]); } function showasetting(name) { var setid = "opts-"+name; if (! document.getElementById(setid)) { var sts = $('