diff options
author | Frank Wuerthwein <fkw@ucsd.edu> | 2009-02-07 03:26:29 +0000 |
---|---|---|
committer | Frank Wuerthwein <fkw@ucsd.edu> | 2009-02-07 03:26:29 +0000 |
commit | 75149c139ae5a03704642e03c563c25ad998d161 (patch) | |
tree | 095e34975744c4f39a53f1c8a877fa2e539e727a | |
parent | 7fa0912c72485b96bf4180e8f149aef633014abf (diff) |
Example HTML/javascript file that display the header of a RRD archive filesv0.1
-rw-r--r-- | src/examples/rrdHeaderInfo.html | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/src/examples/rrdHeaderInfo.html b/src/examples/rrdHeaderInfo.html new file mode 100644 index 0000000..42824c3 --- /dev/null +++ b/src/examples/rrdHeaderInfo.html @@ -0,0 +1,103 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<!-- + Example HTML/javascript file that display the + header of a RRD archive files + Part of the javascriptRRD package + Copyright (c) 2009 Frank Wuerthwein, fkw@ucsd.edu + + Original repository: http://javascriptrrd.sourceforge.net/ + + MIT License [http://www.opensource.org/licenses/mit-license.php] + +--> + +<html> + + <script type="text/javascript" src="../lib/binaryXHR.js"></script> + <script type="text/javascript" src="../lib/rrdFile.js"></script> + <head> + <title>RRD Header Info</title> + </head> + + <body> + <h1 id="title">Javascript needed for this page to work</h1> + + <script type="text/javascript"> + document.getElementById("title").firstChild.data="RRD Header Info"; + </script> + + <label for="form_label_fname">RRD URL:</label> + <input type="text" id="input_fname" value="Test.rrd" + onchange="input_update()"> + <button onclick="input_update()">Update</button> + <hr> + + <table id="infotable" border=1> + <tr><th>RRD file</th><td id="fname" colspan="3">None</td></tr> + <tr><th>Step</th><td id="step">N/A</td><th>Last update</th><td id="last_update">N/A</td></tr> + </table> + + <script type="text/javascript"> + function write_failure() { + var pel=document.getElementById("hello"); + pel.style.color='red'; + pel.firstChild.data="Invalid RRD file."; + } + + function update_info(fname,rrd_data) { + document.getElementById("fname").firstChild.data=fname; + document.getElementById("step").firstChild.data=rrd_data.getStep(); + document.getElementById("last_update").firstChild.data=rrd_data.getLastUpdate(); + var oTable=document.getElementById("infotable"); + while (oTable.rows.length>=3) { + oTable.deleteRow(2); + } + + + var nrDSs=rrd_data.getNrDSs() + var oRow=oTable.insertRow(-1); + var oCell=oRow.insertCell(0); + oCell.innerHTML="<b>DS list</b>"; + oCell.colSpan=4; + for (var i=0; i<nrDSs; i++) { + var oDS=rrd_data.getDS(i); + oRow=oTable.insertRow(-1); + oCell=oRow.insertCell(0) + oCell.innerHTML="<b>"+oDS.getName()+"</B>"; + oCell=oRow.insertCell(1) + oCell.innerHTML=oDS.getType(); + oCell.colSpan=3; + } + } + function update_info_handler(bf) { + var rrd_data=undefined; + try { + var rrd_data=new RRDFile(bf); + } catch(err) { + alert("File "+fname+" is not a valid RRD archive!"); + } + if (rrd_data!=undefined) { + update_info(fname,rrd_data) + } + } + + fname=document.getElementById("input_fname").value; + + function input_update() { + fname=document.getElementById("input_fname").value; + try { + FetchBinaryURLAsync(fname,update_info_handler); + } catch (err) { + alert("Failed loading "+fname+"\n"+err); + } + } + + //try { + // FetchBinaryURLAsync(fname,update_info_handler); + //} catch (err) { + // alert("Failed loading "+fname+"\n"+err); + //} + + </script> + </body> +</html> |