new cleanup and updates
[home-automation.git] / weather-php-test.php
1 <?php ob_start('ob_gzhandler') ?>
2 <?
3 function get_data($item) {
4   $doc = new DOMDocument();
5   $doc->load('http://weather/weather/all-output.xml');
6   $arrFeeds = array();
7   foreach ($doc->getElementsByTagName('weather') as $node) {
8     $itemRSS = array ( 
9       $item => $node->getElementsByTagName($item)->item(0)->nodeValue,
10       );
11     array_push($arrFeeds, $itemRSS);
12   }
13   echo $itemRSS[$item];
14 }
15 ?>
16 <!DOCTYPE html>
17 <html>
18 <head>
19     <script src="libraries/RGraph.common.core.js" ></script>
20     <script src="libraries/RGraph.common.context.js" ></script>
21     <script src="libraries/RGraph.common.annotate.js" ></script>
22     <script src="libraries/RGraph.common.tooltips.js" ></script>
23     <script src="libraries/RGraph.common.zoom.js" ></script>
24     <script src="libraries/RGraph.common.resizing.js" ></script>
25     <script src="libraries/RGraph.meter.js" ></script>
26     <script src="libraries/RGraph.odo.js" ></script>
27     <!--[if IE 8]><script src="excanvas/excanvas.compressed.js"></script><![endif]-->
28
29     <script>
30         window.onload = function ()
31         {
32             var meter1 = new RGraph.Meter('meter1', -20, 120, <? get_data("outsideTemp"); ?>);
33             
34             var grad1 = meter1.context.createRadialGradient(meter1.canvas.width / 2,meter1.canvas.height - 25,0,meter1.canvas.width / 2,meter1.canvas.height - 25,100);
35             grad1.addColorStop(0, 'red');
36             grad1.addColorStop(1, 'white');
37
38             var grad2 = meter1.context.createRadialGradient(meter1.canvas.width / 2, meter1.canvas.height - 25,0,meter1.canvas.width / 2, meter1.canvas.height - 25,100);
39             grad2.addColorStop(0, 'green');
40             grad2.addColorStop(1, 'white');
41             
42             var grad3 = meter1.context.createRadialGradient(meter1.canvas.width / 2, meter1.canvas.height - 25,0,meter1.canvas.width / 2, meter1.canvas.height - 25,100);
43             grad3.addColorStop(0, 'blue');
44             grad3.addColorStop(1, 'white');
45  
46             //meter1.Set('chart.contextmenu', [['Zoom in', RGraph.Zoom], ['Show palette', RGraph.Showpalette], ['Clear annotations', function () {RGraph.Clear(meter1.canvas); meter1.Draw();}], null, ['Cancel', function () {}]]);
47             meter1.Set('chart.annotatable', false);
48             meter1.Set('chart.labels.position', 'inside');
49             meter1.Set('chart.title', '<? get_data("outsideTemp"); ?>');
50             meter1.Set('chart.title.vpos', 0.5);
51             meter1.Set('chart.title.color', 'black');
52             meter1.Set('chart.red.color', grad3);
53             meter1.Set('chart.yellow.color', grad2);
54             meter1.Set('chart.green.color', grad1);
55             meter1.Set('chart.red.start', -20);
56             meter1.Set('chart.red.end', 55);
57             meter1.Set('chart.yellow.start', 55);
58             meter1.Set('chart.yellow.end', 90);
59             meter1.Set('chart.green.start', 90);
60             meter1.Set('chart.green.end', 120);
61             meter1.Set('chart.shadow', true);
62             meter1.Set('chart.shadow.color', 'gray');
63             meter1.Set('chart.shadow.offsetx', 0);
64             meter1.Set('chart.shadow.offsety', 0);
65             meter1.Set('chart.shadow.blur', 15);
66             meter1.Set('chart.zoom.hdir', 'center');
67             meter1.Set('chart.zoom.vdir', 'center');
68             meter1.Set('chart.contextmenu', [['Clear', function () {RGraph.Clear(meter1.canvas); meter1.Draw();}]]);
69             meter1.Draw();
70
71             var odo2 = new RGraph.Odometer('odo2', 0, 360, <? get_data("windDirectionDegrees"); ?>);
72             odo2.Set('chart.annotatable', false);
73             //odo2.Set('chart.needle.thickness', 6);
74             odo2.Set('chart.needle.color', 'black');
75             odo2.Set('chart.needle.tail', false);
76             //odo2.Set('chart.needle.type', 'triangle');
77             odo2.Set('chart.label.area', 22);
78             odo2.Set('chart.contextmenu', [['Clear', function () {RGraph.Clear(odo2.canvas); odo2.Draw();}]]);
79             //odo2.Set('chart.border', document.all ? false : true);
80             //odo2.Set('chart.tickmarks.highlighted', true);
81             odo2.Set('chart.labels', ['N','NE','E','SE','S','SW','W','NW']);
82             odo2.Set('chart.red.min', 360);
83             odo2.Set('chart.red.color', 'gray');
84             //odo2.Set('chart.value.text', true);
85             odo2.Set('chart.value.units.post', ' degrees');
86             odo2.Draw();
87
88         }
89     </script>
90 </head>
91 <body>
92
93 <table>
94 <tr><td>Temperature</td><td>Wind</td></tr>
95 <tr><td>
96     <div style="text-align: center">
97         <canvas id="meter1" width="300" height="150"><div class="canvasfallback">[No canvas support]</div></canvas>
98     </div>
99 </td><td>
100     <div style="text-align: center">
101         <canvas id="odo2" width="200" height="200"><div class="canvasfallback">[No canvas support]</div></canvas>
102     </div>
103
104 </td></tr>
105 </table>
106 </body>
107 </html>