--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<script>
+ var canvas;
+ var context;
+ function drawplot(times, color) {
+ var tmin = times[0][0];
+ var tfact = 640/(times[times.length-1][0] - tmin);
+ var i;
+ var height = [];
+ var hmax = 0;
+ var hfact;
+
+ for (i = 1; i < times.length; i++) {
+ height[i] = 1 / (times[i][0] - times[i-1][0]);
+ if (hmax < height[i]) hmax = height[i];
+ }
+ height[i+1] = height[i];
+ hfact = 480 / hmax;
+ context.beginPath();
+ context.moveTo(0, 480 - height[1]*hfact);
+ for (i = 1; i < times.length; i++) {
+ context.lineTo((times[i][0] - tmin)*tfact,480 - height[i]*hfact);
+ context.lineTo((times[i][0] - tmin)*tfact,480 - height[i+1]*hfact);
+ }
+ context.strokeStyle = color;
+ context.stroke();
+ }
+ function gotdata(data) {
+ canvas = document.getElementById("plot");
+ context = canvas.getContext("2d");
+ drawplot(data.cold, "blue");
+ drawplot(data.hot, "red");
+ }
+</script>
+</head><body>
+<canvas id="plot" width="640" height = "480"
+ style="border:solid 1px #000000;"></canvas>
+<hr/>
+<div id=debug>
+</div>
+<script>
+ var xmlhttp = new XMLHttpRequest();
+ var url = "query.cgi";
+
+ xmlhttp.onreadystatechange = function() {
+ if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
+ document.getElementById("debug").innerHTML = xmlhttp.responseText;
+ var myData = JSON.parse(xmlhttp.responseText);
+ gotdata(myData);
+ }
+ }
+ xmlhttp.open("GET", url, true);
+ xmlhttp.send();
+</script>
+</body>
++ ", \"hi\": " ++ show (ohi :: Int)
++ "}, \"current\": {\"cold\": " ++ show (floor (ccold :: Double))
++ ", \"hot\": " ++ show (floor (chot :: Double))
- ++ "}}, \"cold\": [" ++ showjson cold
+ ++ "}, \"cold\": [" ++ showjson cold
++ "], \"hot\": [" ++ showjson hot ++ "]}\n"
showjson :: [(Int, Double)] -> String