www-thermferm/archives.php

changeset 357
64cd9865bd11
parent 334
d40a2f61b4f7
child 359
12734a3774e8
equal deleted inserted replaced
356:44bcfe087f9e 357:64cd9865bd11
20 * along with ThermFerm; see the file COPYING. If not, write to the Free 20 * along with ThermFerm; see the file COPYING. If not, write to the Free
21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 21 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
22 *****************************************************************************/ 22 *****************************************************************************/
23 23
24 require_once('utilities.php'); 24 require_once('utilities.php');
25 $my_style = 'ui-redmond';
25 26
26 if (isset($_GET['action'])) { 27 if (isset($_GET['action'])) {
27 switch ($_GET['action']) { 28 switch ($_GET['action']) {
28 case 'dl': archive_dl(); 29 case 'dl': archive_dl();
29 break; 30 break;
39 40
40 /**************************************************************************** 41 /****************************************************************************
41 * 42 *
42 */ 43 */
43 44
45 /*
46 * View an archived file in graph format
47 */
48 function archive_view() {
49
50 global $my_style;
51
52 $name = urldecode($_GET['name']);
53
54 $answer = send_cmd('GLOBAL GET');
55 $arr = explode("\r\n", $answer);
56 $version = "?";
57
58 if (startsWith($arr[0], "213")) {
59 $j = 1;
60 while (1) {
61 if (strcmp($arr[$j], ".") == 0)
62 break;
63 $f = explode(",", $arr[$j]);
64
65 if ($f[0] == "RELEASE")
66 $version = $f[1];
67 $j++;
68 }
69 }
70
71 $outstr = '<!DOCTYPE html>'.PHP_EOL;
72 $outstr .= '<html>'.PHP_EOL;
73 $outstr .= ' <head>'.PHP_EOL;
74 $outstr .= ' <meta http-equiv="content-type" content="text/html; charset=utf-8" />'.PHP_EOL;
75 $outstr .= ' <title>Archive View '.$name.'</title>'.PHP_EOL;
76 $outstr .= ' <link type="text/css" href="css/style.css" rel="stylesheet" media="all" />'.PHP_EOL;
77 $outstr .= ' <link type="text/css" href="jqwidgets/styles/jqx.base.css" rel="stylesheet" />'.PHP_EOL;
78 $outstr .= ' <link type="text/css" href="jqwidgets/styles/jqx.'.$my_style.'.css" rel="stylesheet" />'.PHP_EOL;
79 $outstr .= ' <script type="text/javascript" src="js/jquery-2.1.1.min.js"></script>'.PHP_EOL;
80 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxcore.js"></script>'.PHP_EOL;
81 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxwindow.js"></script>'.PHP_EOL;
82 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxbuttons.js"></script>'.PHP_EOL;
83 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxchart.core.js"></script>'.PHP_EOL;
84 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxdraw.js"></script>'.PHP_EOL;
85 $outstr .= ' <script type="text/javascript" src="jqwidgets/jqxdata.js"></script>'.PHP_EOL;
86 $outstr .= ' </head>'.PHP_EOL;
87
88 $outstr .= ' <body class="default">'.PHP_EOL;
89 $outstr .= ' <div id="jqxWidget">'.PHP_EOL;
90 $outstr .= ' <div id="header">'.PHP_EOL;
91 $outstr .= ' <div id="title">'.PHP_EOL;
92 $outstr .= ' ThermFerm '.$version.PHP_EOL;
93 $outstr .= ' </div>'.PHP_EOL;
94 $outstr .= ' <form action="archives.php" style="margin:30px; float:right">'.PHP_EOL;
95 $outstr .= ' <input type="submit" id="archives" value="Archives directory" />'.PHP_EOL;
96 $outstr .= ' </form>'.PHP_EOL;
97 $outstr .= ' </div> <!-- header -->'.PHP_EOL;
98 $outstr .= ' <div id="content">'.PHP_EOL;
99
100 $outstr .= ' <script type="text/javascript">'.PHP_EOL;
101 $outstr .= ' $(document).ready(function () {'.PHP_EOL;
102
103 $outstr .= ' function getExportServer() {'.PHP_EOL;
104 $outstr .= ' return "http://www.jqwidgets.com/export_server/export.php";'.PHP_EOL;
105 $outstr .= ' }'.PHP_EOL;
106
107 $outstr .= ' var sourceA ='.PHP_EOL;
108 $outstr .= ' {'.PHP_EOL;
109 $outstr .= ' datatype: "json",'.PHP_EOL;
110 $outstr .= ' datafields: ['.PHP_EOL;
111 $outstr .= ' { name: "Date", type: "date", format: "yyyy-MM-ddTHH:mm" },'.PHP_EOL;
112 $outstr .= ' { name: "Mode" },'.PHP_EOL;
113 $outstr .= ' { name: "Air", type: "float" },'.PHP_EOL;
114 $outstr .= ' { name: "Beer", type: "float" },'.PHP_EOL;
115 $outstr .= ' { name: "Target", type: "float" },'.PHP_EOL;
116 $outstr .= ' { name: "Heater", type: "int" },'.PHP_EOL;
117 $outstr .= ' { name: "Cooler", type: "int" },'.PHP_EOL;
118 $outstr .= ' { name: "HeatUse", type: "int" },'.PHP_EOL;
119 $outstr .= ' { name: "CoolUse", type: "int" },'.PHP_EOL;
120 $outstr .= ' { name: "Room", type: "float" }'.PHP_EOL;
121 $outstr .= ' ],'.PHP_EOL;
122 $outstr .= ' url: \'getalog.php?name='.urlencode($name).'\''.PHP_EOL;
123 $outstr .= ' };'.PHP_EOL;
124
125 $outstr .= ' var dataAdapter = new $.jqx.dataAdapter(sourceA,'.PHP_EOL;
126 $outstr .= ' {'.PHP_EOL;
127 $outstr .= ' autoBind: true,'.PHP_EOL;
128 $outstr .= ' async: false,'.PHP_EOL;
129 $outstr .= ' downloadComplete: function () { },'.PHP_EOL;
130 $outstr .= ' loadComplete: function () { },'.PHP_EOL;
131 $outstr .= ' loadError: function () { }'.PHP_EOL;
132 $outstr .= ' });'.PHP_EOL;
133
134 $outstr .= ' var settings = {'.PHP_EOL;
135 $outstr .= ' title: "'.$name.'",'.PHP_EOL;
136 $outstr .= ' description: "",'.PHP_EOL;
137 $outstr .= ' padding: { left: 5, top: 5, right: 5, bottom: 5 },'.PHP_EOL;
138 $outstr .= ' titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },'.PHP_EOL;
139 $outstr .= ' source: dataAdapter,'.PHP_EOL;
140 $outstr .= ' categoryAxis:'.PHP_EOL;
141 $outstr .= ' {'.PHP_EOL;
142 $outstr .= ' dataField: \'Date\','.PHP_EOL;
143 $outstr .= ' textRotationAngle: 45,'.PHP_EOL;
144 $outstr .= ' showGridLines: false'.PHP_EOL;
145 $outstr .= ' },'.PHP_EOL;
146 $outstr .= ' colorScheme: \'scheme01\','.PHP_EOL;
147 $outstr .= ' seriesGroups:'.PHP_EOL;
148 $outstr .= ' [{'.PHP_EOL;
149 $outstr .= ' type: "line",'.PHP_EOL;
150 $outstr .= ' valueAxis:'.PHP_EOL;
151 $outstr .= ' {'.PHP_EOL;
152 $outstr .= ' minValue: 0,'.PHP_EOL;
153 $outstr .= ' maxValue: 100,'.PHP_EOL;
154 $outstr .= ' displayValueAxis: false,'.PHP_EOL;
155 $outstr .= ' description: "Heat/Cool %"'.PHP_EOL;
156 $outstr .= ' },'.PHP_EOL;
157 $outstr .= ' series: ['.PHP_EOL;
158 $outstr .= ' { dataField: "CoolUse", lineWidth: 1, displayText: "Cool %", opacity: 0.5 },'.PHP_EOL;
159 $outstr .= ' { dataField: "HeatUse", lineWidth: 1, displayText: "Heat %", opacity: 0.5 }'.PHP_EOL;
160 $outstr .= ' ]'.PHP_EOL;
161 $outstr .= ' },'.PHP_EOL;
162 $outstr .= ' {'.PHP_EOL;
163 $outstr .= ' type: \'spline\','.PHP_EOL;
164 $outstr .= ' valueAxis:'.PHP_EOL;
165 $outstr .= ' {'.PHP_EOL;
166 $outstr .= ' minValue: 0,'.PHP_EOL;
167 $outstr .= ' description: \'Degrees C\''.PHP_EOL;
168 $outstr .= ' },'.PHP_EOL;
169 $outstr .= ' series: ['.PHP_EOL;
170 $outstr .= ' { dataField: "Air", lineWidth: 1, displayText: "Air" },'.PHP_EOL;
171 $outstr .= ' { dataField: "Beer", lineWidth: 2, displayText: "Beer" },'.PHP_EOL;
172 $outstr .= ' { dataField: "Target", lineWidth: 1, displayText: "Target", opacity: 0.7 },'.PHP_EOL;
173 $outstr .= ' { dataField: "Room", lineWidth: 1, displayText: "Room", opacity: 0.5 }'.PHP_EOL;
174 $outstr .= ' ]'.PHP_EOL;
175 $outstr .= ' }]'.PHP_EOL;
176 $outstr .= ' };'.PHP_EOL;
177 /* Direct draw for the first time */
178 $outstr .= ' $("#fermentor_chart").jqxChart(settings);'.PHP_EOL;
179
180 $outstr .= ' $("#print").click(function () {'.PHP_EOL;
181 $outstr .= ' var content = $("#fermentor_chart")[0].outerHTML;'.PHP_EOL;
182 $outstr .= ' var newWindow = window.open("", "", "width=750, height=400"),'.PHP_EOL;
183 $outstr .= ' document = newWindow.document.open(),'.PHP_EOL;
184 $outstr .= ' pageContent ='.PHP_EOL;
185 $outstr .= ' \'<!DOCTYPE html>\' +'.PHP_EOL;
186 $outstr .= ' \'<html>\' +'.PHP_EOL;
187 $outstr .= ' \'<head>\' +'.PHP_EOL;
188 $outstr .= ' \'<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />\' +'.PHP_EOL;
189 $outstr .= ' \'<meta charset="utf-8" />\' +'.PHP_EOL;
190 $outstr .= ' \'<title>jQWidgets Chart</title>\' +'.PHP_EOL;
191 $outstr .= ' \'</head>\' +'.PHP_EOL;
192 $outstr .= ' \'<body>\' + content + \'</body></html>\';'.PHP_EOL;
193 $outstr .= ' document.write(pageContent);'.PHP_EOL;
194 $outstr .= ' document.close();'.PHP_EOL;
195 $outstr .= ' newWindow.print();'.PHP_EOL;
196 $outstr .= ' });'.PHP_EOL;
197 $outstr .= ' $("#print").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL;
198
199 $outstr .= ' $("#pngButton").click(function () {'.PHP_EOL;
200 $outstr .= ' $("#fermentor_chart").jqxChart("saveAsPNG", "Chart_'.$name.'.png", getExportServer());'.PHP_EOL;
201 $outstr .= ' });'.PHP_EOL;
202 $outstr .= ' $("#pngButton").jqxButton({ width: 100, height: 25, theme: "ui-redmond" });'.PHP_EOL;
203
204 $outstr .= ' });'.PHP_EOL;
205 $outstr .= ' </script>'.PHP_EOL;
206 $outstr .= ' <div id="fermentor">'.PHP_EOL;
207 $outstr .= ' <div id="fermentor_chart" style="width:720px; height:377px; float:left"></div>'.PHP_EOL;
208 $outstr .= ' <div style="margin-top: 2px; margin-left: 10px;">'.PHP_EOL;
209 $outstr .= ' <input style="float: left; margin-left: 15px;" id="print" type="button" value="Print Graph" />'.PHP_EOL;
210 $outstr .= ' <input style="float: left; margin-left: 15px;" id="pngButton" type="button" value="Save Graph" />'.PHP_EOL;
211 $outstr .= ' </div>'.PHP_EOL;
212 $outstr .= ' </div> <!-- fermentor -->'.PHP_EOL;
213
214 $outstr .= ' <script type="text/javascript">'.PHP_EOL;
215 $outstr .= ' $(document).ready(function () {'.PHP_EOL;
216 $outstr .= ' $("#archives").jqxButton({ width: 150, height: 25, theme: \'ui-redmond\' });'.PHP_EOL;
217 $outstr .= ' });'.PHP_EOL;
218 $outstr .= ' </script>'.PHP_EOL;
219 $outstr .= build_footer();
220 echo $outstr;
221 }
44 222
45 223
46 224
47 /* 225 /*
48 * 226 *

mercurial