www/js/mon_fermenter.js

changeset 526
2991acd35cdb
parent 494
af28ebe4a779
child 548
c67cd0d9249b
--- a/www/js/mon_fermenter.js	Fri Oct 18 20:49:07 2019 +0200
+++ b/www/js/mon_fermenter.js	Sat Oct 19 12:17:29 2019 +0200
@@ -21,661 +21,656 @@
  *****************************************************************************/
 
 function createAbortElements() {
-	$('#eventWindow').jqxWindow({
-		theme: theme,
-		position: { x: 440, y: 210 },
-		width: 400,
-		height: 200,
-		resizable: false,
-		isModal: true,
-		modalOpacity: 0.4,
-		okButton: $('#delOk'),
-		cancelButton: $('#delCancel'),
-		initContent: function () {
-			$('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme });
-			$('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme });
-			$('#delCancel').focus();
-		}
-	});
-	$('#eventWindow').jqxWindow('hide');
+ $('#eventWindow').jqxWindow({
+  theme: theme,
+  position: { x: 440, y: 210 },
+  width: 400,
+  height: 200,
+  resizable: false,
+  isModal: true,
+  modalOpacity: 0.4,
+  okButton: $('#delOk'),
+  cancelButton: $('#delCancel'),
+  initContent: function() {
+   $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme });
+   $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme });
+   $('#delCancel').focus();
+  }
+ });
+ $('#eventWindow').jqxWindow('hide');
 }
 
 
-$(document).ready(function () {
+$(document).ready(function() {
+
+ var record = {},
+ blank = {},
+ ppayload = '',
+ newBase = false,
+ newProduct = false,
+ newSwitch = false,
+ newProfile = false,
+ schedule = 0,
+ yl = 12, // Normal yeast temp range
+ yh = 24,
 
-	var record = {},
-	blank = {},
-	ppayload = '',
-	newBase = false,
-	newProduct = false,
-	newSwitch = false,
-	newProfile = false,
-	schedule = 0,
-	yl = 12, // Normal yeast temp range
-	yh = 24,
+ productSource = {
+  datatype: 'json',
+  cache: false,
+  datafields: [
+   { name: 'code', type: 'string' },
+   { name: 'name', type: 'string' },
+   { name: 'uuid', type: 'string' },
+   { name: 'stage', type: 'int' },
+   { name: 'yeast_lo', type: 'float' },
+   { name: 'yeast_hi', type: 'float' }
+  ],
+  id: 'code',
+  url: 'includes/db_product.php?select=ferment'
+ },
+ productlist = new $.jqx.dataAdapter(productSource, {
+  beforeLoadComplete: function(records) {
+   var row, i, data = new Array();
+   // Create a dummy beer on top to store in idle fermenters.
+   blank['code'] = 'Free';  // Will override this later.
+   blank['name'] = 'Dummy';
+   blank['uuid'] = '66ecccbf-e942-4a35-af49-8b02314561a5';
+   blank['stage'] = 10;
+   blank['yeast_lo'] = 12.0;
+   blank['yeast_hi'] = 24.0;
+   data.push(blank);
+   for (i = 0; i < records.length; i++) {
+    row = records[i];
+    data.push(row);
+   }
+   return data;
+  },
+  loadError: function(jqXHR, status, error) {
+   $('#err').text(status + ' ' + error);
+  },
+ }),
+ profileSource = {
+  datatype: 'json',
+  cache: false,
+  datafields: [
+   { name: 'record', type: 'int' },
+   { name: 'uuid', type: 'string' },
+   { name: 'name', type: 'string' },
+   { name: 'inittemp_lo', type: 'float' },
+   { name: 'inittemp_hi', type: 'float' },
+   { name: 'fridgemode', type: 'int' },
+   { name: 'totalsteps', type: 'int' },
+   { name: 'duration', type: 'int' },
+   { name: 'steps', type: 'array' }
+  ],
+  id: 'record',
+  url: 'includes/db_profile_fermentation.php'
+ },
+ profilelist = new $.jqx.dataAdapter(profileSource, {
+  beforeLoadComplete: function(records) {
+   var data = new Array(),
+   empty = {}, i, row;
+   // Create a dummy profile on top of the list.
+   empty['record'] = -1;
+   empty['uuid'] = '';
+   empty['name'] = 'Wis profiel';
+   empty['inittemp_lo'] = 20;
+   empty['inittemp_hi'] = 20;
+   empty['fridgemode'] = 0;
+   empty['totalsteps'] = 0;
+   empty['duration'] = 0;
+   empty['steps'] = '[]';
+   data.push(empty);
+   for (i = 0; i < records.length; i++) {
+    row = records[i];
+    data.push(row);
+   }
+   return data;
+  },
+  loadError: function(jqXHR, status, error) {
+   $('#err').text(status + ' ' + error);
+  },
+ }),
+ gaugeoptions = {
+  min: 0, max: 40, width: 375, height: 375,
+  ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 },
+           { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
+           { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }],
+  ticksMinor: { interval: 1, size: '5%' },
+  ticksMajor: { interval: 5, size: '9%' },
+  labels: { interval: 5 },
+  style: { fill: '#eeeeee', stroke: '#666666' },
+  value: 0,
+  colorScheme: 'scheme05'
+ },
+ gaugeSmalloptions = {
+  min: -15, max: 25, width: 190, height: 190,
+  ranges: [{ startValue: -15, endValue: 0, startWidth: 5, endWidth: 5, style: { fill: '#3399FF', stroke: '#3399FF' }},
+           { startValue: 0, endValue: 10, startWidth: 5, endWidth: 5, style: { fill: '#00CC33', stroke: '#00CC33' }},
+           { startValue: 10, endValue: 25, startWidth: 5, endWidth: 5, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }}],
+  ticksMinor: { interval: 1, size: '5%' },
+  ticksMajor: { interval: 5, size: '9%' },
+  labels: { interval: 5 },
+  style: { fill: '#eeeeee', stroke: '#666666' },
+  value: 0,
+  colorScheme: 'scheme05',
+  caption: { value: 'Koeler', position: 'bottom', offset: [0, 10] }
+ },
+ switchoptions = {
+  height: 68,
+  width: 35,
+  onLabel: 'AAN',
+  offLabel: 'UIT',
+  theme: theme,
+  thumbSize: '50%',
+  orientation: 'vertical'
+ },
+ targetoptions = { inputMode: 'simple', theme: theme, width: 70, min: 0, max: 40, decimalDigits: 1, spinButtons: true },
+ url = 'getfermenter.php?uuid="' + my_uuid + '"',
+ source = {
+  datatype: 'json',
+  datafields: [
+   { name: 'record', type: 'int' },
+   { name: 'uuid', type: 'string' },
+   { name: 'alias', type: 'string' },
+   { name: 'node', type: 'string' },
+   { name: 'online', type: 'int' },
+   { name: 'beercode', type: 'string' },
+   { name: 'beername', type: 'string' },
+   { name: 'air_state', type: 'string' },
+   { name: 'air_temperature', type: 'float' },
+   { name: 'beer_state', type: 'string' },
+   { name: 'beer_temperature', type: 'float' },
+   { name: 'chiller_state', type: 'string' },
+   { name: 'chiller_temperature', type: 'float' },
+   { name: 'heater_state', type: 'int' },
+   { name: 'heater_usage', type: 'int' },
+   { name: 'cooler_state', type: 'int' },
+   { name: 'cooler_usage', type: 'int' },
+   { name: 'fan_state', type: 'int' },
+   { name: 'fan_usage', type: 'int' },
+   { name: 'light_address', type: 'string' },
+   { name: 'light_state', type: 'int' },
+   { name: 'light_usage', type: 'int' },
+   { name: 'door_address', type: 'string' },
+   { name: 'door_state', type: 'int' },
+   { name: 'psu_address', type: 'string' },
+   { name: 'psu_state', type: 'int' },
+   { name: 'mode', type: 'string' },
+   { name: 'alarm', type: 'int' },
+   { name: 'setpoint_high', type: 'float' },
+   { name: 'setpoint_low', type: 'float' },
+   { name: 'profile_uuid', type: 'string' },
+   { name: 'profile_name', type: 'string' },
+   { name: 'profile_state', type: 'string' },
+   { name: 'profile_percent', type: 'int' },
+   { name: 'profile_inittemp_high', type: 'float' },
+   { name: 'profile_inittemp_low', type: 'float' },
+   { name: 'profile_steps', type: 'string' },
+   { name: 'stage', type: 'string' },
+   { name: 'beeruuid', type: 'string' },
+   { name: 'yeast_lo', type: 'float' },
+   { name: 'yeast_hi', type: 'float' },
+   { name: 'webcam_url', type: 'string' },
+   { name: 'webcam_light', type: 'int' }
+  ],
+  id: 'record',
+  url: url
+ },
+ dataAdapter = new $.jqx.dataAdapter(source, {
+  loadComplete: function(records) {
+   record = dataAdapter.records[0];
+   var range, oline = (record.online) ? 'On-line' : 'Off-line';
+   $('#info_uuid').html(record.uuid);
+   $('#info_system').html(record.node + '/' + record.alias);
+   $('#info_online').html(oline);
+   $('#info_beer').html(record.beercode + ' - ' + record.beername);
+   $('#info_mode').jqxDropDownList('selectItem', record.mode);
+   $('#info_stage').jqxDropDownList('selectItem', record.stage);
+   $('#info_profile').html(record.profile_name);
+   blank['name'] = record.alias;
+   blank['code'] = record.alias.toUpperCase();
+   blank['uuid'] = record.uuid;
+   if (record.profile_name == '')
+    $('#info_mode').jqxDropDownList('disableItem', 'PROFILE');
+   else
+    $('#info_mode').jqxDropDownList('enableItem', 'PROFILE');
+   $('#target_lo').val(record.setpoint_low);
+   $('#target_hi').val(record.setpoint_high);
+   if (record.online && ((record.mode == 'FRIDGE') || (record.mode == 'BEER'))) {
+    $('#target_lo').jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true });
+    $('#target_hi').jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true });
+   } else {
+    $('#target_lo').jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false });
+    $('#target_hi').jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false });
+   }
+
+   if (record.online && record.door_address && (record.door_state != '0')) {
+    $('#fermenter_doorled').html('<div class="LEDyellow_on"></div>Door');
+   } else {
+    $('#fermenter_doorled').html('<div class="LEDyellow_off"></div>Door');
+   }
+   if (record.online && record.light_address && (record.light_state != '0')) {
+    $('#fermenter_lightled').html('<div class="LEDyellow_on"></div>Light');
+   } else {
+    $('#fermenter_lightled').html('<div class="LEDyellow_off"></div>Light');
+   }
 
-	productSource = {
-		datatype: "json",
-		cache: false,
-		datafields: [
-			{ name: 'code', type: 'string' },
-			{ name: 'name', type: 'string' },
-			{ name: 'uuid', type: 'string' },
-			{ name: 'stage', type: 'int' },
-			{ name: 'yeast_lo', type: 'float' },
-			{ name: 'yeast_hi', type: 'float' }
-		],
-		id: 'code',
-		url: "includes/db_product.php?select=ferment"
-	},
-	productlist = new $.jqx.dataAdapter(productSource, {
-		beforeLoadComplete: function (records) {
-			var row, i, data = new Array();
-			// Create a dummy beer on top to store in idle fermenters.
-			blank['code'] = "Free";	 // Will override this later.
-			blank['name'] = 'Dummy';
-			blank['uuid'] = '66ecccbf-e942-4a35-af49-8b02314561a5';
-			blank['stage'] = 10;
-			blank['yeast_lo'] = 12.0;
-			blank['yeast_hi'] = 24.0;
-			data.push(blank);
-			for (i = 0; i < records.length; i++) {
-				row = records[i];
-				data.push(row);
-			}
-			return data;
-		},
-        	loadError: function(jqXHR, status, error) {
-                	$('#err').text(status + ' ' + error);
-		},
-	}),
-        profileSource = {
-                datatype: "json",
-                cache: false,
-                datafields: [
-                        { name: 'record', type: 'int' },
-                        { name: 'uuid', type: 'string' },
-                        { name: 'name', type: 'string' },
-                        { name: 'inittemp_lo', type: 'float' },
-                        { name: 'inittemp_hi', type: 'float' },
-                        { name: 'fridgemode', type: 'int' },
-                        { name: 'totalsteps', type: 'int' },
-                        { name: 'duration', type: 'int' },
-                        { name: 'steps', type: 'array' }
-                ],
-                id: 'record',
-                url: "includes/db_profile_fermentation.php"
-        },
-        profilelist = new $.jqx.dataAdapter(profileSource, {
-                beforeLoadComplete: function (records) {
-                        var data = new Array(),
-                        empty = {}, i, row;
-                        // Create a dummy profile on top of the list.
-                        empty['record'] = -1;
-                        empty['uuid'] = '';
-                        empty['name'] = 'Wis profiel';
-                        empty['inittemp_lo'] = 20;
-                        empty['inittemp_hi'] = 20;
-                        empty['fridgemode'] = 0;
-                        empty['totalsteps'] = 0;
-                        empty['duration'] = 0;
-                        empty['steps'] = '[]';
-                        data.push(empty);
-                        for (i = 0; i < records.length; i++) {
-                                row = records[i];
-                                data.push(row);
-                        }
-                        return data;
-                },
-                loadError: function(jqXHR, status, error) {
-                        $('#err').text(status + ' ' + error);
-                },
-        }),
-        gaugeoptions = {
-                min: 0, max: 40, width: 375, height: 375,
-                ranges: [{ startValue:  0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 },
-                         { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
-                         { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }],
-                ticksMinor: { interval: 1, size: '5%' },
-                ticksMajor: { interval: 5, size: '9%' },
-                labels: { interval: 5 },
-                style: { fill: '#eeeeee', stroke: '#666666' },
-                value: 0,
-                colorScheme: 'scheme05'
-        },
-        gaugeSmalloptions = {
-                min: -15, max: 25, width: 190, height: 190,
-                ranges: [{ startValue: -15, endValue:  0, startWidth: 5, endWidth: 5, style: { fill: '#3399FF', stroke: '#3399FF' }},
-                         { startValue:   0, endValue: 10, startWidth: 5, endWidth: 5, style: { fill: '#00CC33', stroke: '#00CC33' }},
-                         { startValue:  10, endValue: 25, startWidth: 5, endWidth: 5, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }}],
-                ticksMinor: { interval: 1, size: '5%' },
-                ticksMajor: { interval: 5, size: '9%' },
-                labels: { interval: 5 },
-                style: { fill: '#eeeeee', stroke: '#666666' },
-                value: 0,
-                colorScheme: 'scheme05',
-                caption: { value: 'Chiller', position: 'bottom', offset: [0, 10] }
-        },
-        switchoptions = {
-                height: 68,
-                width: 35,
-                onLabel:'AAN',
-                offLabel:'UIT',
-                theme: theme,
-                thumbSize:'50%',
-                orientation: 'vertical'
-        },
-	targetoptions = { inputMode: 'simple', theme: theme, width: 70, min: 0, max: 40, decimalDigits: 1, spinButtons: true },
-        url = "getfermenter.php?uuid='" + my_uuid + "'",
-        source = {
-                datatype: "json",
-                datafields: [
-                        { name: 'record', type: 'int' },
-                        { name: 'uuid', type: 'string' },
-                        { name: 'alias', type: 'string' },
-                        { name: 'node', type: 'string' },
-                        { name: 'online', type: 'int' },
-                        { name: 'beercode', type: 'string' },
-                        { name: 'beername', type: 'string' },
-                        { name: 'air_state', type: 'string' },
-                        { name: 'air_temperature', type: 'float' },
-                        { name: 'beer_state', type: 'string' },
-                        { name: 'beer_temperature', type: 'float' },
-                        { name: 'chiller_state', type: 'string' },
-                        { name: 'chiller_temperature', type: 'float' },
-                        { name: 'heater_state', type: 'int' },
-                        { name: 'heater_usage', type: 'int' },
-                        { name: 'cooler_state', type: 'int' },
-                        { name: 'cooler_usage', type: 'int' },
-                        { name: 'fan_state', type: 'int' },
-                        { name: 'fan_usage', type: 'int' },
-                        { name: 'light_address', type: 'string' },
-                        { name: 'light_state', type: 'int' },
-                        { name: 'light_usage', type: 'int' },
-                        { name: 'door_address', type: 'string' },
-                        { name: 'door_state', type: 'int' },
-                        { name: 'psu_address', type: 'string' },
-                        { name: 'psu_state', type: 'int' },
-                        { name: 'mode', type: 'string' },
-                        { name: 'alarm', type: 'int' },
-                        { name: 'setpoint_high', type: 'float' },
-                        { name: 'setpoint_low', type: 'float' },
-                        { name: 'profile_uuid', type: 'string' },
-                        { name: 'profile_name', type: 'string' },
-                        { name: 'profile_state', type: 'string' },
-                        { name: 'profile_percent', type: 'int' },
-                        { name: 'profile_inittemp_high', type: 'float' },
-                        { name: 'profile_inittemp_low', type: 'float' },
-                        { name: 'profile_steps', type: 'string' },
-                        { name: 'stage', type: 'string' },
-                        { name: 'beeruuid', type: 'string' },
-                        { name: 'yeast_lo', type: 'float' },
-                        { name: 'yeast_hi', type: 'float' },
-                        { name: 'webcam_url', type: 'string' },
-                        { name: 'webcam_light', type: 'int' }
-                ],
-                id: 'record',
-                url: url
-        },
-        dataAdapter = new $.jqx.dataAdapter(source, {
-                loadComplete: function (records) {
-                        record = dataAdapter.records[0];
-                        var range, oline = (record.online) ? "On-line" : "Off-line";
-                        $("#info_uuid").html(record.uuid);
-                        $("#info_system").html(record.node +  "/" + record.alias);
-                        $("#info_online").html(oline);
-                        $("#info_beer").html(record.beercode + " - " + record.beername);
-                        $("#info_mode").jqxDropDownList('selectItem', record.mode);
-                        $("#info_stage").jqxDropDownList('selectItem', record.stage);
-                        $("#info_profile").html(record.profile_name);
-                        blank['name'] = record.alias;
-                        blank['code'] = record.alias.toUpperCase();
-                        blank['uuid'] = record.uuid;
-                        if (record.profile_name == "")
-                                $("#info_mode").jqxDropDownList('disableItem', "PROFILE");
-                        else
-                                $("#info_mode").jqxDropDownList('enableItem', "PROFILE");
-                        $("#target_lo").val(record.setpoint_low);
-                        $("#target_hi").val(record.setpoint_high);
-                        if (record.online && ((record.mode == "FRIDGE") || (record.mode == "BEER"))) {
-                                $("#target_lo").jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true });
-                                $("#target_hi").jqxNumberInput({ readOnly: false, Width: 70, spinButtons: true });
-                        } else {
-                                $("#target_lo").jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false });
-                                $("#target_hi").jqxNumberInput({ readOnly: true, Width: 50, spinButtons: false });
-                        }
+   if (record.online && (record.mode != 'OFF')) {
+    $('#fermenter_powerled').html('<div class="LEDblue_on"></div>Power');
+    $('#select_beer').jqxDropDownList({ disabled: true });
+    $('#select_beer').jqxDropDownList('clearSelection');
+    $('#select_beer').hide();
+   } else {
+    $('#fermenter_powerled').html('<div class="LEDblue_off"></div>Power');
+    $('#select_beer').show();
+    $('#select_beer').jqxDropDownList({ disabled: false });
+   }
+   if (record.online && (record.alarm != '0')) {
+    $('#fermenter_alarmled').html('<div class="LEDred_on"></div>Alarm');
+   } else {
+    $('#fermenter_alarmled').html('<div class="LEDred_off"></div>Alarm');
+   }
+
+   if (record.online && (record.heater_state != '0')) {
+    $('#fermenter_led1').html('<div class="LEDgreen_on"></div>Heat');
+   } else {
+    $('#fermenter_led1').html('<div class="LEDgreen_off"></div>Heat');
+   }
+   if (record.online && (record.cooler_state != '0')) {
+    $('#fermenter_led2').html('<div class="LEDgreen_on"></div>Cool');
+   } else {
+    $('#fermenter_led2').html('<div class="LEDgreen_off"></div>Cool');
+   }
+   if (record.online && (record.fan_state != '0')) {
+    $('#fermenter_led3').html('<div class="LEDgreen_on"></div>Fan');
+   } else {
+    $('#fermenter_led3').html('<div class="LEDgreen_off"></div>Fan');
+   }
+   if (record.online && (record.mode == 'NONE')) {
+    $('#fermenter_toggle1').jqxSwitchButton('enable');
+    $('#fermenter_toggle2').jqxSwitchButton('enable');
+    $('#fermenter_toggle3').jqxSwitchButton('enable');
+   } else {
+    $('#fermenter_toggle1').jqxSwitchButton('disable');
+    $('#fermenter_toggle2').jqxSwitchButton('disable');
+    $('#fermenter_toggle3').jqxSwitchButton('disable');
+    $('#fermenter_toggle1').val(record.heater_state != '0');
+    $('#fermenter_toggle2').val(record.cooler_state != '0');
+    $('#fermenter_toggle3').val(record.fan_state != '0');
+   }
+
+   if (record.online && (record.mode == 'PROFILE')) {
+    if (record.profile_state == 'OFF') {
+     $('#select_profile').show();
+     $('#select_profile').jqxDropDownList({ disabled: false });
+     $('#info_mode').jqxDropDownList({ disabled: false });
+     $('#Profile1').jqxButton({ template: 'success', value: 'Starten' });
+     $('#Profile1').show();
+     $('#Profile2').hide();
+     $('#status_profile').html('');
+    } else if (record.profile_state == 'RUN') {
+     $('#select_profile').jqxDropDownList({ disabled: true });
+     $('#select_profile').hide();
+     $('#info_mode').jqxDropDownList({ disabled: true });
+     $('#Profile1').jqxButton({ template: 'danger', value: 'Afbreken' });
+     $('#Profile2').jqxButton({ template: 'primary', value: 'Pauze' });
+     $('#Profile1').show();
+     $('#Profile2').show();
+     $('#status_profile').html('Profiel actief, ' + record.profile_percent + '% gereed');
+    } else if (record.profile_state == 'PAUSE') {
+     $('#select_profile').jqxDropDownList({ disabled: true });
+     $('#select_profile').hide();
+     $('#info_mode').jqxDropDownList({ disabled: true });
+     $('#Profile1').jqxButton({ template: 'danger', value: 'Afbreken' });
+     $('#Profile2').jqxButton({ template: 'success', value: 'Doorgaan' });
+     $('#Profile1').show();
+     $('#Profile2').show();
+     $('#status_profile').html('Profiel pauze, ' + record.profile_percent + '% gereed');
+    } else if (record.profile_state == 'DONE') {
+     $('#select_profile').jqxDropDownList({ disabled: true });
+     $('#select_profile').hide();
+     $('#info_mode').jqxDropDownList({ disabled: true });
+     $('#Profile1').jqxButton({ template: 'primary', value: 'Profiel Ok' });
+     $('#Profile1').show();
+     $('#Profile2').hide();
+     $('#status_profile').html('Profiel is gereed');
+    }
+   } else {
+    $('#select_profile').show();
+    $('#select_profile').jqxDropDownList({ disabled: false });
+    $('#info_mode').jqxDropDownList({ disabled: false });
+    $('#Profile1').hide();
+    $('#Profile2').hide();
+    $('#status_profile').html('');
+   }
+   if (record.online && (record.webcam_url != '')) {
+    $('#Camera').show();
+   } else {
+    $('#Camera').hide();
+   }
+
+   yl = record.yeast_lo;
+   yh = record.yeast_hi;
+   range = { ranges: [{ startValue: 0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 },
+                      { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
+                      { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }]};
+   $('#gaugeContainer_air').jqxGauge(range);
+   $('#gaugeContainer_beer').jqxGauge(range);
 
-                        if (record.online && record.door_address && (record.door_state != "0")) {
-                                $("#fermenter_doorled").html('<div class="LEDyellow_on"></div>Door');
-                        } else {
-                                $("#fermenter_doorled").html('<div class="LEDyellow_off"></div>Door');
-                        }
-                        if (record.online && record.light_address && (record.light_state != "0")) {
-                                $("#fermenter_lightled").html('<div class="LEDyellow_on"></div>Light');
-                        } else {
-                                $("#fermenter_lightled").html('<div class="LEDyellow_off"></div>Light');
-                        }
-
-                        if (record.online && (record.mode != "OFF")) {
-                                $("#fermenter_powerled").html('<div class="LEDblue_on"></div>Power');
-                                $("#select_beer").jqxDropDownList({ disabled: true });
-                                $("#select_beer").jqxDropDownList('clearSelection');
-                                $("#select_beer").hide();
-                        } else {
-                                $("#fermenter_powerled").html('<div class="LEDblue_off"></div>Power');
-                                $("#select_beer").show();
-                                $("#select_beer").jqxDropDownList({ disabled: false });
-                        }
-                        if (record.online && (record.alarm != "0")) {
-                                $("#fermenter_alarmled").html('<div class="LEDred_on"></div>Alarm');
-                        } else {
-                                $("#fermenter_alarmled").html('<div class="LEDred_off"></div>Alarm');
-                        }
+   $('#gaugeContainer_air').jqxGauge({ caption: { value: 'Lucht: ' + record.air_temperature.toFixed(3) }});
+   $('#gaugeContainer_air').jqxGauge({ value: record.air_temperature });
+   if (record.air_state == 'OK') {
+    $('#gaugeContainer_air').jqxGauge({ disabled: false });
+   } else {
+    $('#gaugeContainer_air').jqxGauge({ disabled: true });
+   }
+   $('#gaugeContainer_beer').jqxGauge({ caption: { value: 'Bier: ' + record.beer_temperature.toFixed(3) }});
+   $('#gaugeContainer_beer').jqxGauge({ value: record.beer_temperature });
+   if (record.beer_state == 'OK') {
+    $('#gaugeContainer_beer').jqxGauge({ disabled: false });
+   } else {
+    $('#gaugeContainer_beer').jqxGauge({ disabled: true });
+   }
+   $('#gaugeContainer_chiller').jqxGauge({ value: record.chiller_temperature });
+   if (record.chiller_state == 'OK') {
+    $('#gaugeContainer_chiller').jqxGauge({ disabled: false });
+   } else {
+    $('#gaugeContainer_chiller').jqxGauge({ disabled: true });
+   }
+  }
+ });
 
-                        if (record.online && (record.heater_state != "0")) {
-                                $("#fermenter_led1").html('<div class="LEDgreen_on"></div>Heat');
-                        } else {
-                                $("#fermenter_led1").html('<div class="LEDgreen_off"></div>Heat');
-                        }
-                        if (record.online && (record.cooler_state != "0")) {
-                                $("#fermenter_led2").html('<div class="LEDgreen_on"></div>Cool');
-                        } else {
-                                $("#fermenter_led2").html('<div class="LEDgreen_off"></div>Cool');
-                        }
-                        if (record.online && (record.fan_state != "0")) {
-                                $("#fermenter_led3").html('<div class="LEDgreen_on"></div>Fan');
-                        } else {
-                                $("#fermenter_led3").html('<div class="LEDgreen_off"></div>Fan');
-                        }
-                        if (record.online && (record.mode == "NONE")) {
-                                $("#fermenter_toggle1").jqxSwitchButton( 'enable' );
-                                $("#fermenter_toggle2").jqxSwitchButton( 'enable' );
-                                $("#fermenter_toggle3").jqxSwitchButton( 'enable' );
-                        } else {
-                                $("#fermenter_toggle1").jqxSwitchButton( 'disable' );
-                                $("#fermenter_toggle2").jqxSwitchButton( 'disable' );
-                                $("#fermenter_toggle3").jqxSwitchButton( 'disable' );
-                                $("#fermenter_toggle1").val( (record.heater_state != "0") );
-                                $("#fermenter_toggle2").val( (record.cooler_state != "0") );
-                                $("#fermenter_toggle3").val( (record.fan_state != "0") );
-                        }
+ $('#select_beer').jqxDropDownList({
+  placeHolder: 'Kies bier:',
+  theme: theme,
+  source: productlist,
+  displayMember: 'code',
+  width: 150,
+  height: 24,
+  dropDownWidth: 500,
+  autoDropDownHeight: true,
+  renderer: function(index, label, value) {
+   var datarecord = productlist.records[index];
+   return datarecord.code + ' - ' + datarecord.name;
+  }
+ });
+ $('#select_profile').jqxDropDownList({
+  placeHolder: 'Kies profiel:',
+  theme: theme,
+  source: profilelist,
+  displayMember: 'name',
+  width: 150,
+  height: 24,
+  dropDownWidth: 500,
+  autoDropDownHeight: true,
+ });
+
+ $('#gaugeContainer_air').jqxGauge(gaugeoptions);
+ $('#gaugeContainer_air').jqxGauge({ caption: { value: 'Lucht: 00.000' }});
+ $('#gaugeContainer_beer').jqxGauge(gaugeoptions);
+ $('#gaugeContainer_beer').jqxGauge({ caption: { value: 'Bier: 00.000' }});
+ $('#gaugeContainer_chiller').jqxGauge(gaugeSmalloptions);
+
+ $('#fermenter_toggle1').jqxSwitchButton(switchoptions);
+ $('#fermenter_toggle2').jqxSwitchButton(switchoptions);
+ $('#fermenter_toggle3').jqxSwitchButton(switchoptions);
+
+ srcMode = ['OFF', 'NONE', 'FRIDGE', 'BEER', 'PROFILE'];
+ srcStage = ['PRIMARY', 'SECONDARY', 'TERTIARY', 'CARBONATION'];
+ $('#info_mode').jqxDropDownList({ theme: theme, source: srcMode, width: 100, height: 24, dropDownHeight: 156 });
+ $('#info_stage').jqxDropDownList({ theme: theme, source: srcStage, width: 150, height: 24, dropDownHeight: 125 });
 
-                        if (record.online && (record.mode == "PROFILE")) {
-                                if (record.profile_state == "OFF") {
-                                        $("#select_profile").show();
-                                        $("#select_profile").jqxDropDownList({ disabled: false });
-                                        $("#info_mode").jqxDropDownList({ disabled: false });
-                                        $('#Profile1').jqxButton({ template: "success", value: "Starten" });
-                                        $("#Profile1").show();
-                                        $("#Profile2").hide();
-                                        $("#status_profile").html('');
-                                } else if (record.profile_state == "RUN") {
-                                        $("#select_profile").jqxDropDownList({ disabled: true });
-                                        $("#select_profile").hide();
-                                        $("#info_mode").jqxDropDownList({ disabled: true });
-                                        $('#Profile1').jqxButton({ template: "danger", value: "Afbreken" });
-                                        $('#Profile2').jqxButton({ template: "primary", value: "Pauze" });
-                                        $("#Profile1").show();
-                                        $("#Profile2").show();
-                                        $("#status_profile").html('Profiel actief, '+record.profile_percent+'% gereed');
-                                } else if (record.profile_state == "PAUSE") {
-                                        $("#select_profile").jqxDropDownList({ disabled: true });
-                                        $("#select_profile").hide();
-                                        $("#info_mode").jqxDropDownList({ disabled: true });
-                                        $('#Profile1').jqxButton({ template: "danger", value: "Afbreken" });
-                                        $('#Profile2').jqxButton({ template: "success", value: "Doorgaan" });
-                                        $("#Profile1").show();
-                                        $("#Profile2").show();
-                                        $("#status_profile").html('Profiel pauze, '+record.profile_percent+'% gereed');
-                                } else if (record.profile_state == "DONE") {
-                                        $("#select_profile").jqxDropDownList({ disabled: true });
-                                        $("#select_profile").hide();
-                                        $("#info_mode").jqxDropDownList({ disabled: true });
-                                        $('#Profile1').jqxButton({ template: "primary", value: "Profiel Ok" });
-                                        $("#Profile1").show();
-                                        $("#Profile2").hide();
-                                        $("#status_profile").html('Profiel is gereed');
-                                }
-                        } else {
-                                $("#select_profile").show();
-                                $("#select_profile").jqxDropDownList({ disabled: false });
-                                $("#info_mode").jqxDropDownList({ disabled: false });
-                                $("#Profile1").hide();
-                                $("#Profile2").hide();
-                                $("#status_profile").html('');
-                        }
-                        if (record.online && (record.webcam_url != "")) {
-                                $("#Camera").show();
-                        } else {
-                                $("#Camera").hide();
-                        }
+ $('#target_lo').jqxNumberInput(targetoptions);
+ $('#target_hi').jqxNumberInput(targetoptions);
+
+ $('#Profile1').jqxButton({ template: 'info', width: '150px', height: 24, theme: theme });
+ $('#Profile2').jqxButton({ template: 'info', width: '150px', height: 24, theme: theme });
+ $('#Profile1').hide(); // Hide these until they are needed.
+ $('#Profile2').hide();
+
+ function sendBase(stage, mode, tlo, thi) {
+
+  console.log('sendBase(' + stage + ', ' + mode + ', ' + tlo + ', ' + thi + ')');
+  var data = 'node=' + record.node + '&alias=' + record.alias + '&payload={"stage":"' + stage;
+  data += '","mode":"' + mode + '","setpoint":{"low":' + tlo + ',"high":' + thi + '}}';
+  $.ajax({
+   url: 'cmd_fermenter.php',
+   data: data,
+   type: 'POST',
+   success: function(data) {},
+   error: function(jqXHR, textStatus, errorThrown) { console.log('sendBase() error'); }
+  });
+ }
+
+ function sendSwitch(sw1, sw2, sw3, sw4) {
 
-                        yl = record.yeast_lo;
-                        yh = record.yeast_hi;
-                        range = { ranges: [{ startValue:  0, endValue: yl, style: { fill: '#3399FF', stroke: '#3399FF' }, endWidth: 10, startWidth: 10 },
-                                               { startValue: yl, endValue: yh, style: { fill: '#00CC33', stroke: '#00CC33' }, endWidth: 10, startWidth: 10 },
-                                               { startValue: yh, endValue: 40, style: { fill: '#FC6A6A', stroke: '#FC6A6A' }, endWidth: 10, startWidth: 10 }] };
-                        $("#gaugeContainer_air").jqxGauge( range );
-                        $("#gaugeContainer_beer").jqxGauge( range );
+  console.log('sendSwitch(' + sw1 + ', ' + sw2 + ', ' + sw3 + ', ' + sw4 + ')');
+  var data = 'node=' + record.node + '&alias=' + record.alias + '&payload=';
+  data += '{"heater":{"state":' + sw1 + '},"cooler":{"state":' + sw2 + '},"fan":{"state":' + sw3 + '},"light":{"state":' + sw4 + '}}';
+  $.ajax({
+   url: 'cmd_fermenter.php',
+   data: data,
+   type: 'POST',
+   success: function(data) {},
+   error: function(jqXHR, textStatus, errorThrown) { console.log('sendSwitch() error'); }
+  });
+ }
+
+ function sendProduct(code, name, uuid, yeast_lo, yeast_hi) {
 
-                        $("#gaugeContainer_air").jqxGauge({ caption: { value: 'Air: '+record.air_temperature.toFixed(3) }});
-                        $('#gaugeContainer_air').jqxGauge({ value: record.air_temperature });
-                        if (record.air_state == "OK") {
-                                $("#gaugeContainer_air").jqxGauge({ disabled: false });
-                        } else {
-                                $("#gaugeContainer_air").jqxGauge({ disabled: true });
-                        }
-                        $("#gaugeContainer_beer").jqxGauge({ caption: { value: 'Beer: '+record.beer_temperature.toFixed(3) }});
-                        $('#gaugeContainer_beer').jqxGauge({ value: record.beer_temperature });
-                        if (record.beer_state == "OK") {
-                                $("#gaugeContainer_beer").jqxGauge({ disabled: false });
-                        } else {
-                                $("#gaugeContainer_beer").jqxGauge({ disabled: true });
-                        }
-                        $("#gaugeContainer_chiller").jqxGauge({ value: record.chiller_temperature });
-                        if (record.chiller_state == "OK") {
-                                $("#gaugeContainer_chiller").jqxGauge({ disabled: false });
-                        } else {
-                                $("#gaugeContainer_chiller").jqxGauge({ disabled: true });
-                        }
-                }
-        });
+  console.log('sendProduct(' + code + ', ' + name + ', ' + uuid + ', ' + yeast_lo + ', ' + yeast_hi + ')');
+  var data = 'node=' + record.node + '&alias=' + record.alias + '&payload=';
+  data += '{"product":{"code":"' + code + '","name":"' + name + '","uuid":"' + uuid + '","yeast_lo":' + yeast_lo + ',"yeast_hi":' + yeast_hi + '}}';
+  $.ajax({
+   url: 'cmd_fermenter.php',
+   data: data,
+   type: 'POST',
+   success: function(data) {},
+   error: function(jqXHR, textStatus, errorThrown) { console.log('sendProduct() error'); }
+  });
+ }
+
+ function sendProfile(payload) {
+
+  console.log('sendProfile(' + payload + ')');
+  var data = 'node=' + record.node + '&alias=' + record.alias + '&payload=' + payload;
+  $.ajax({
+   url: 'cmd_fermenter.php',
+   data: data,
+   type: 'POST',
+   success: function(data) {},
+   error: function(jqXHR, textStatus, errorThrown) { console.log('sendProfile() error'); }
+  });
+ }
 
 
-
-
-
-
-	$("#select_beer").jqxDropDownList({
-		placeHolder: "Kies bier:",
-		theme: theme,
-		source: productlist,
-		displayMember: "code",
-		width: 150,
-		height: 24,
-		dropDownWidth: 500,
-		autoDropDownHeight: true,
-		renderer: function (index, label, value) {
-			var datarecord = productlist.records[index];
-			return datarecord.code + " - " + datarecord.name;
-		}
-	});
-	$("#select_profile").jqxDropDownList({
-		placeHolder: "Kies profiel:",
-		theme: theme,
-		source: profilelist,
-		displayMember: "name",
-		width: 150,
-		height: 24,
-		dropDownWidth: 500,
-		autoDropDownHeight: true,
-	});
+ // Get the data immediatly and then at regular intervals to refresh.
+ dataAdapter.dataBind();
+ setInterval(function() {
+  var skip = false;
+  if (newBase) {
+   sendBase(record.stage, record.mode, record.setpoint_low, record.setpoint_high);
+   newBase = false;
+   skip = true;
+  }
+  if (newSwitch) {
+   sendSwitch(record.heater_state, record.cooler_state, record.fan_state, record.light_state);
+   newSwitch = false;
+   skip = true;
+  }
+  if (newProduct) {
+   sendProduct(record.beercode, record.beername, record.beeruuid, record.yeast_lo, record.yeast_hi);
+   newProduct = false;
+   skip = true;
+  }
+  if (newProfile) {
+   sendProfile(ppayload);
+   newProfile = false;
+   skip = true;
+  }
+  if (skip) {
+   schedule = 4; // 2 seconds wait to get the results
+  } else {
+   if (schedule > 0)
+    schedule--;
+  }
 
-	$("#gaugeContainer_air").jqxGauge( gaugeoptions );
-	$("#gaugeContainer_air").jqxGauge( { caption: { value: 'Air: 00.000' }} );
-	$("#gaugeContainer_beer").jqxGauge( gaugeoptions );
-	$("#gaugeContainer_beer").jqxGauge( { caption: { value: 'Beer: 00.000' }} );
-	$("#gaugeContainer_chiller").jqxGauge( gaugeSmalloptions );
-
-	$("#fermenter_toggle1").jqxSwitchButton( switchoptions );
-	$("#fermenter_toggle2").jqxSwitchButton( switchoptions );
-	$("#fermenter_toggle3").jqxSwitchButton( switchoptions );
-
-	srcMode = [ "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" ];
-	srcStage = [ "PRIMARY", "SECONDARY", "TERTIARY", "CARBONATION" ];
-	$("#info_mode").jqxDropDownList({  theme: theme, source: srcMode, width: 100, height: 24, dropDownHeight: 156 });
-	$("#info_stage").jqxDropDownList({ theme: theme, source: srcStage, width: 150, height: 24, dropDownHeight: 125 });
-
-	$("#target_lo").jqxNumberInput( targetoptions );
-	$("#target_hi").jqxNumberInput( targetoptions );
-
-	$("#Profile1").jqxButton({ template: "info", width: '150px', height: 24, theme: theme });
-	$("#Profile2").jqxButton({ template: "info", width: '150px', height: 24, theme: theme });
-	$("#Profile1").hide();	// Hide these until they are needed.
-	$("#Profile2").hide();
-
-	function sendBase(stage, mode, tlo, thi) {
-
-		console.log("sendBase("+stage+", "+mode+", "+tlo+", "+thi+")");
-		var data  = 'node=' + record.node + '&alias=' + record.alias + '&payload={"stage":"' + stage;
-		    data += '","mode":"' + mode + '","setpoint":{"low":' + tlo + ',"high":' + thi + '}}';
-		$.ajax({
-			url: "cmd_fermenter.php",
-			data: data,
-			type: "POST",
-			success: function(data) {},
-			error: function(jqXHR, textStatus, errorThrown) { console.log("sendBase() error"); }
-		});
-	}
-
-	function sendSwitch(sw1, sw2, sw3, sw4) {
+  if (schedule <= 0) {
+   dataAdapter.dataBind();
+   schedule = 20;
+  }
+ }, 500);
 
-		console.log("sendSwitch("+sw1+", "+sw2+", "+sw3+", "+sw4+")");
-		var data  = 'node='+record.node+'&alias='+record.alias+'&payload=';
-		    data += '{"heater":{"state":'+sw1+'},"cooler":{"state":'+sw2+'},"fan":{"state":'+sw3+'},"light":{"state":'+sw4+'}}';
-		$.ajax({
-			url: "cmd_fermenter.php",
-			data: data,
-			type: "POST",
-			success: function(data) {},
-			error: function(jqXHR, textStatus, errorThrown) { console.log("sendSwitch() error"); }
-		});
-	}
-
-	function sendProduct(code, name, uuid, yeast_lo, yeast_hi) {
-
-		console.log("sendProduct("+code+", "+name+", "+uuid+", "+yeast_lo+", "+yeast_hi+")");
-		var data  = 'node='+record.node+'&alias='+record.alias+'&payload=';
-		    data += '{"product":{"code":"'+code+'","name":"'+name+'","uuid":"'+uuid+'","yeast_lo":'+yeast_lo+',"yeast_hi":'+yeast_hi+'}}';
-		$.ajax({
-			url: "cmd_fermenter.php",
-			data: data,
-			type: "POST",
-			success: function(data) {},
-			error: function(jqXHR, textStatus, errorThrown) { console.log("sendProduct() error"); }
-		});
-	}
-
-	function sendProfile(payload) {
-
-		console.log("sendProfile("+payload+")");
-		var data  = 'node='+record.node+'&alias='+record.alias+'&payload='+payload;
-		$.ajax({
-			url: "cmd_fermenter.php",
-			data: data,
-			type: "POST",
-			success: function(data) {},
-			error: function(jqXHR, textStatus, errorThrown) { console.log("sendProfile() error"); }
-		});
-	}
-
-
-	// Get the data immediatly and then at regular intervals to refresh.
-	dataAdapter.dataBind();
-	setInterval(function() {
-		var skip = false;
-		if (newBase) {
-			sendBase(record.stage, record.mode, record.setpoint_low, record.setpoint_high);
-			newBase = false;
-			skip = true;
-		}
-		if (newSwitch) {
-			sendSwitch(record.heater_state, record.cooler_state, record.fan_state, record.light_state);
-			newSwitch = false;
-			skip = true;
-		}
-		if (newProduct) {
-			sendProduct(record.beercode, record.beername, record.beeruuid, record.yeast_lo, record.yeast_hi);
-			newProduct = false;
-			skip = true;
-		}
-		if (newProfile) {
-			sendProfile(ppayload);
-			newProfile = false;
-			skip = true;
-		}
-		if (skip) {
-			schedule = 4;	// 2 seconds wait to get the results
-		} else {
-			if (schedule > 0)
-				schedule--;
-		}
-
-		if (schedule <= 0) {
-			dataAdapter.dataBind();
-			schedule = 20;
-		}
-	}, 500);
+ $('#info_mode').on('change', function(event) {
+  var args = event.args;
+  if (args) {
+   record.mode = args.item.value;
+   $('#fermenter_toggle1').val(0);
+   $('#fermenter_toggle2').val(0);
+   $('#fermenter_toggle3').val(0);
+  }
+  newBase = true;
+ });
+ $('#info_stage').on('select', function(event) {
+  var args = event.args;
+  if (args)
+   record.stage = args.item.value;
+  newBase = true;
+ });
+ $('#select_beer').on('select', function(event) {
+  if (event.args) {
+   var index = event.args.index,
+   datarecord = productlist.records[index];
+   record.beercode = datarecord.code;
+   record.beername = datarecord.name;
+   record.beeruuid = datarecord.uuid;
+   record.yeast_lo = datarecord.yeast_lo;
+   record.yeast_hi = datarecord.yeast_hi;
+   newProduct = true;
+  }
+ });
+ $('#select_profile').on('select', function(event) {
+  if (event.args) {
+   var index = event.args.index,
+   datarecord = profilelist.records[index],
+   row, i;
+   if (datarecord.record == -1) {
+    ppayload = '{"profile":null}';
+   } else {
+    ppayload = '{"profile":{"uuid":"' + datarecord.uuid + '","name":"' + datarecord.name + '",';
+    ppayload += '"inittemp":{"low":' + datarecord.inittemp_lo + ',"high":' + datarecord.inittemp_hi + '},';
+    ppayload += '"fridgemode":' + datarecord.fridgemode + ',"steps":[';
+    for (i = 0; i < datarecord.steps.length; i++) {
+     row = datarecord.steps[i];
+     if (i > 0)
+      ppayload += ',';
+     ppayload += '{"steptime":' + row['steptime'] + ',"resttime":' + row['resttime'];
+     ppayload += ',"target_lo":' + row['target_lo'] + ',"target_hi":' + row['target_hi'];
+     ppayload += ',"fridgemode":' + row['fridgemode'] + ',"name":"' + row['name'] + '"}';
+    }
+    ppayload += ']}}';
+   }
+   newProfile = true;
+  }
+ });
 
-	$('#info_mode').on('change', function (event) {
-		var args = event.args;
-		if (args) {
-			record.mode = args.item.value;
-			$("#fermenter_toggle1").val(0);
-			$("#fermenter_toggle2").val(0);
-			$("#fermenter_toggle3").val(0);
-		}
-		newBase = true;
-	});
-	$('#info_stage').on('select', function (event) {
-		var args = event.args;
-		if (args)
-			record.stage = args.item.value;
-		newBase = true;
-	});
-	$("#select_beer").on('select', function (event) {
-		if (event.args) {
-			var index = event.args.index,
-			datarecord = productlist.records[index];
-			record.beercode = datarecord.code;
-			record.beername = datarecord.name;
-			record.beeruuid = datarecord.uuid;
-			record.yeast_lo = datarecord.yeast_lo;
-			record.yeast_hi = datarecord.yeast_hi;
-			newProduct = true;
-		}
-	});
-	$("#select_profile").on('select', function (event) {
-		if (event.args) {
-			var index = event.args.index,
-			datarecord = profilelist.records[index],
-			row, i;
-			if (datarecord.record == -1) {
-				ppayload  = '{"profile":null}';
-			} else {
-				ppayload  = '{"profile":{"uuid":"'+datarecord.uuid+'","name":"'+datarecord.name+'",';
-				ppayload += '"inittemp":{"low":'+datarecord.inittemp_lo+',"high":'+datarecord.inittemp_hi+'},';
-				ppayload += '"fridgemode":'+datarecord.fridgemode+',"steps":[';
-				for (i = 0; i < datarecord.steps.length; i++) {
-					row = datarecord.steps[i];
-					if (i > 0)
-						ppayload += ',';
-					ppayload += '{"steptime":'+row['steptime']+',"resttime":'+row['resttime'];
-					ppayload += ',"target_lo":'+row['target_lo']+',"target_hi":'+row['target_hi'];
-					ppayload += ',"fridgemode":'+row['fridgemode']+',"name":"'+row['name']+'"}';
-				}
-				ppayload += ']}}';
-			}
-			newProfile = true;
-		}
-	});
-
-	$('#target_lo').on('change', function (event) {
-		record.setpoint_low = parseFloat(event.args.value);
-		// Keep the high target above the low.
-		if (record.setpoint_low > record.setpoint_high) {
-			record.setpoint_high = record.setpoint_low;
-			$("#target_hi").val(record.setpoint_high);
-		}
-		newBase = true;
-	});
-	$('#target_hi').on('change', function (event) {
-		record.setpoint_high = parseFloat(event.args.value);
-		// Keep the low target below the high.
-		if (record.setpoint_high < record.setpoint_low) {
-			record.setpoint_low = record.setpoint_high;
-			$("#target_lo").val(record.setpoint_low);
-		}
-		newBase = true;
-	});
+ $('#target_lo').on('change', function(event) {
+  record.setpoint_low = parseFloat(event.args.value);
+  // Keep the high target above the low.
+  if (record.setpoint_low > record.setpoint_high) {
+   record.setpoint_high = record.setpoint_low;
+   $('#target_hi').val(record.setpoint_high);
+  }
+  newBase = true;
+ });
+ $('#target_hi').on('change', function(event) {
+  record.setpoint_high = parseFloat(event.args.value);
+  // Keep the low target below the high.
+  if (record.setpoint_high < record.setpoint_low) {
+   record.setpoint_low = record.setpoint_high;
+   $('#target_lo').val(record.setpoint_low);
+  }
+  newBase = true;
+ });
 
-	$("#fermenter_toggle1").on('checked', function (event) {
-		if (record.mode == "NONE") {
-			record.heater_state = 0;
-			newSwitch = true;
-		}
-	});
-	$("#fermenter_toggle1").on('unchecked', function (event) {
-		if (record.mode == "NONE") {
-			record.heater_state = 100;
-			record.cooler_state = 0;
-			$("#fermenter_toggle2").val(0);
-			newSwitch = true;
-		}
-	});
-	$("#fermenter_toggle2").on('checked', function (event) {
-		if (record.mode == "NONE") {
-			record.cooler_state = 0;
-			newSwitch = true;
-		}
-	});
-	$("#fermenter_toggle2").on('unchecked', function (event) {
-		if (record.mode == "NONE") {
-			record.cooler_state = 100;
-			record.heater_state = 0;
-			$("#fermenter_toggle1").val(0);
-			newSwitch = true;
-		}
-	});
-	$("#fermenter_toggle3").on('checked', function (event) {
-		if (record.mode == "NONE") {
-			record.fan_state = 0;
-			newSwitch = true;
-		}
-	});
-	$("#fermenter_toggle3").on('unchecked', function (event) {
-		if (record.mode == "NONE") {
-			record.fan_state = 100;
-			newSwitch = true;
-		}
-	});
-	$("#Profile1").click(function () {
-		if (record.mode == "PROFILE") {
-			if (record.profile_state == "OFF") {
-				ppayload  = '{"profile":{"command":"start"}}';
-				newProfile = true;
-			} else if ((record.profile_state == "RUN") || (record.profile_state == "PAUSE")) {
-				// Open a popup to confirm this action.
-				$('#eventWindow').jqxWindow('open');
-				$("#delOk").click(function () {
-					ppayload  = '{"profile":{"command":"abort"}}';
-					newProfile = true;
-				});
-			} else if (record.profile_state == "DONE") {
-				ppayload  = '{"profile":{"command":"done"}}';
-				newProfile = true;
-			}
-		}
-	});
-	$("#Profile2").click(function () {
-		if (record.mode == "PROFILE") {
-			if ((record.profile_state == "RUN") || (record.profile_state == "PAUSE")) {
-				ppayload  = '{"profile":{"command":"pause"}}';
-				newProfile = true;
-			}
-		}
-	});
+ $('#fermenter_toggle1').on('checked', function(event) {
+  if (record.mode == 'NONE') {
+   record.heater_state = 0;
+   newSwitch = true;
+  }
+ });
+ $('#fermenter_toggle1').on('unchecked', function(event) {
+  if (record.mode == 'NONE') {
+   record.heater_state = 100;
+   record.cooler_state = 0;
+   $('#fermenter_toggle2').val(0);
+   newSwitch = true;
+  }
+ });
+ $('#fermenter_toggle2').on('checked', function(event) {
+  if (record.mode == 'NONE') {
+   record.cooler_state = 0;
+   newSwitch = true;
+  }
+ });
+ $('#fermenter_toggle2').on('unchecked', function(event) {
+  if (record.mode == 'NONE') {
+   record.cooler_state = 100;
+   record.heater_state = 0;
+   $('#fermenter_toggle1').val(0);
+   newSwitch = true;
+  }
+ });
+ $('#fermenter_toggle3').on('checked', function(event) {
+  if (record.mode == 'NONE') {
+   record.fan_state = 0;
+   newSwitch = true;
+  }
+ });
+ $('#fermenter_toggle3').on('unchecked', function(event) {
+  if (record.mode == 'NONE') {
+   record.fan_state = 100;
+   newSwitch = true;
+  }
+ });
+ $('#Profile1').click(function() {
+  if (record.mode == 'PROFILE') {
+   if (record.profile_state == 'OFF') {
+    ppayload = '{"profile":{"command":"start"}}';
+    newProfile = true;
+   } else if ((record.profile_state == 'RUN') || (record.profile_state == 'PAUSE')) {
+    // Open a popup to confirm this action.
+    $('#eventWindow').jqxWindow('open');
+    $('#delOk').click(function() {
+     ppayload = '{"profile":{"command":"abort"}}';
+     newProfile = true;
+    });
+   } else if (record.profile_state == 'DONE') {
+    ppayload = '{"profile":{"command":"done"}}';
+    newProfile = true;
+   }
+  }
+ });
+ $('#Profile2').click(function() {
+  if (record.mode == 'PROFILE') {
+   if ((record.profile_state == 'RUN') || (record.profile_state == 'PAUSE')) {
+    ppayload = '{"profile":{"command":"pause"}}';
+    newProfile = true;
+   }
+  }
+ });
 
-	// The chart button.
-   	$("#FLog").jqxButton({ template: "primary", width: '150px', theme: theme });
-	$("#FLog").click(function () {
-		window.open('log_fermentation.php?code=' + record.beercode + '&name=' + record.beername);
-	});
-	$("#Camera").jqxButton({ template: "primary", width: '150px', theme: theme });
-	$("#Camera").click(function () {
-		record.light_state = 100;
-		newSwitch = true;
-		window.open(record.webcam_url);
-	});
-	createAbortElements();
+ // The chart button.
+ $('#FLog').jqxButton({ template: 'primary', width: '150px', theme: theme });
+ $('#FLog').click(function() {
+  window.open('log_fermentation.php?code=' + record.beercode + '&name=' + record.beername);
+ });
+ $('#Camera').jqxButton({ template: 'primary', width: '150px', theme: theme });
+ $('#Camera').click(function() {
+  record.light_state = 100;
+  newSwitch = true;
+  window.open(record.webcam_url);
+ });
+ createAbortElements();
 });

mercurial