diff -r 35675eadc655 -r 3cccf4392a25 www/js/profile_fermentation.js --- a/www/js/profile_fermentation.js Fri Oct 18 16:21:54 2019 +0200 +++ b/www/js/profile_fermentation.js Fri Oct 18 19:24:05 2019 +0200 @@ -22,336 +22,335 @@ function createDelElements() { - $('#eventWindow').jqxWindow({ - theme: theme, - position: { x: 490, y: 210 }, - width: 300, - height: 175, - 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: 490, y: 210 }, + width: 300, + height: 175, + 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() { - // tooltips - $("#name").jqxTooltip({ content: 'De naam voor dit vergisting profiel.' }); - $("#inittemp_lo").jqxTooltip({ content: 'De minimale begin temperatuur van dit profiel.' }); - $("#inittemp_hi").jqxTooltip({ content: 'De maximale begin temperatuur van dit profiel.' }); + // tooltips + $('#name').jqxTooltip({ content: 'De naam voor dit vergisting profiel.' }); + $('#inittemp_lo').jqxTooltip({ content: 'De minimale begin temperatuur van dit profiel.' }); + $('#inittemp_hi').jqxTooltip({ content: 'De maximale begin temperatuur van dit profiel.' }); - var dataRecord = {}, - url = 'includes/db_profile_fermentation.php', - // prepare the data - source = { - datatype: "json", - cache: false, - datafields: [ - { name: 'record', type: 'number' }, - { 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: url, - deleterow: function (rowid, commit) { - // synchronize with the server - send delete command - var data = "delete=true&" + $.param({ record: rowid }); - $.ajax({ - dataType: 'json', - url: url, - cache: false, - data: data, - type: "POST", - success: function (data, status, xhr) { - commit(true); - location.reload( true ); - }, - error: function (jqXHR, textStatus, errorThrown) { - commit(false); - } - }); - }, - addrow: function (rowid, rowdata, position, commit) { - var data = "insert=true&" + $.param(rowdata); - $.ajax({ - dataType: 'json', - url: url, - cache: false, - data: data, - type: "POST", - success: function (data, status, xhr) { - commit(true); - location.reload( true ); - }, - error: function(jqXHR, textStatus, errorThrown) { - commit(false); - } - }); - }, - updaterow: function (rowid, rowdata, commit) { - var data = "update=true&" + $.param(rowdata); - $.ajax({ - dataType: 'json', - url: url, - cache: false, - data: data, - type: "POST", - success: function (data, status, xhr) { - commit(true); - location.reload( true ); - }, - error: function(jqXHR, textStatus, errorThrown) { - commit(false); - } - }); - } - }, - dataAdapter = new $.jqx.dataAdapter(source), - editrow = -1, + var dataRecord = {}, + url = 'includes/db_profile_fermentation.php', + source = { + datatype: 'json', + cache: false, + datafields: [ + { name: 'record', type: 'number' }, + { 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: url, + deleterow: function(rowid, commit) { + var data = 'delete=true&' + $.param({ record: rowid }); + $.ajax({ + dataType: 'json', + url: url, + cache: false, + data: data, + type: 'POST', + success: function(data, status, xhr) { + commit(true); + location.reload(true); + }, + error: function(jqXHR, textStatus, errorThrown) { + commit(false); + } + }); + }, + addrow: function(rowid, rowdata, position, commit) { + var data = 'insert=true&' + $.param(rowdata); + $.ajax({ + dataType: 'json', + url: url, + cache: false, + data: data, + type: 'POST', + success: function(data, status, xhr) { + commit(true); + location.reload(true); + }, + error: function(jqXHR, textStatus, errorThrown) { + commit(false); + } + }); + }, + updaterow: function(rowid, rowdata, commit) { + var data = 'update=true&' + $.param(rowdata); + $.ajax({ + dataType: 'json', + url: url, + cache: false, + data: data, + type: 'POST', + success: function(data, status, xhr) { + commit(true); + location.reload(true); + }, + error: function(jqXHR, textStatus, errorThrown) { + commit(false); + } + }); + } + }, + dataAdapter = new $.jqx.dataAdapter(source), + editrow = -1, - // Inline steps editor - editsteps = function (data) { - var generaterow = function () { - var row = {}; - row["name"] = "Stap 1"; - row['steptime'] = 12; - row['resttime'] = 24; - row['target_lo'] = 22.0; - row['target_hi'] = 23.0; - row['fridgemode'] = 0; - return row; - }, - stepSource = { - localdata: data.steps, - datatype: "local", - datafields: [ - { name: 'name', type: 'string' }, - { name: 'steptime', type: 'float' }, - { name: 'resttime', type: 'float' }, - { name: 'target_lo', type: 'float' }, - { name: 'target_hi', type: 'float' }, - { name: 'fridgemode', type: 'int' } - ], - addrow: function (rowid, rowdata, position, commit) { - commit(true); - }, - deleterow: function (rowid, commit) { - commit(true); - } - }, - stepAdapter = new $.jqx.dataAdapter(stepSource); - $("#grid").jqxGrid({ - width: 800, - height: 330, - source: stepAdapter, - theme: theme, - selectionmode: 'singlerow', - editmode: 'selectedcell', - editable: true, - showtoolbar: true, - rendertoolbar: function (toolbar) { - var container = $("
"); - toolbar.append(container); - container.append(''); - container.append(''); - $("#addrowbutton").jqxButton({ template: "primary", theme: theme, width: 150 }); - $("#deleterowbutton").jqxButton({ template: "danger", theme: theme, width: 150 }); - // create new row. - $("#addrowbutton").on('click', function () { - var datarow = generaterow(); - $("#grid").jqxGrid('addrow', null, datarow); - }); - // delete row. - $("#deleterowbutton").on('click', function () { - var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'), - rowscount = $("#grid").jqxGrid('getdatainformation').rowscount, - id; - if (selectedrowindex >= 0 && selectedrowindex < rowscount) { - id = $("#grid").jqxGrid('getrowid', selectedrowindex); - $("#grid").jqxGrid('deleterow', id); - } - }); - }, - columns: [ - { text: 'Stap naam', datafield: 'name' }, - { text: 'Min. °C', datafield: 'target_lo', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1', - validation: function (cell, value) { - if (value < 0 || value > 40) { - return { result: false, message: "De temperatuur moet tussen 0 en 40 zijn." }; - } - return true; - } - }, - { text: 'Max. °C', datafield: 'target_hi', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1', - validation: function (cell, value) { - if (value < 0 || value > 40) { - return { result: false, message: "De temperatuur moet tussen 0 en 40 zijn." }; - } - return true; - } - }, - { text: 'Koelkast', datafield: 'fridgemode', columntype: 'checkbox', width: 80 }, - { text: 'Stap tijd', datafield: 'steptime', width: 80, align: 'right', cellsalign: 'right', - validation: function (cell, value) { - if (value < 0 || value > 14400) { - return { result: false, message: "De tijd moet tussen 0 en 14400 zijn." }; - } - return true; - } - }, - { text: 'Rust tijd', datafield: 'resttime', width: 80, align: 'right', cellsalign: 'right', - validation: function (cell, value) { - if (value < 0 || value > 14400) { - return { result: false, message: "De tijd moet tussen 0 en 14400 zijn." }; - } - return true; - } - } - ] - }); - }; + // Inline steps editor + editsteps = function(data) { + var generaterow = function() { + var row = {}; + row['name'] = 'Stap 1'; + row['steptime'] = 12; + row['resttime'] = 24; + row['target_lo'] = 22.0; + row['target_hi'] = 23.0; + row['fridgemode'] = 0; + return row; + }; + var stepSource = { + localdata: data.steps, + datatype: 'local', + datafields: [ + { name: 'name', type: 'string' }, + { name: 'steptime', type: 'float' }, + { name: 'resttime', type: 'float' }, + { name: 'target_lo', type: 'float' }, + { name: 'target_hi', type: 'float' }, + { name: 'fridgemode', type: 'int' } + ], + addrow: function(rowid, rowdata, position, commit) { + commit(true); + }, + deleterow: function(rowid, commit) { + commit(true); + } + }, + stepAdapter = new $.jqx.dataAdapter(stepSource); + $('#grid').jqxGrid({ + width: 800, + height: 330, + source: stepAdapter, + theme: theme, + selectionmode: 'singlerow', + editmode: 'selectedcell', + editable: true, + showtoolbar: true, + rendertoolbar: function(toolbar) { + var container = $(''); + toolbar.append(container); + container.append(''); + container.append(''); + $('#addrowbutton').jqxButton({ template: 'primary', theme: theme, width: 150 }); + $('#deleterowbutton').jqxButton({ template: 'danger', theme: theme, width: 150 }); + // create new row. + $('#addrowbutton').on('click', function() { + var datarow = generaterow(); + $('#grid').jqxGrid('addrow', null, datarow); + }); + // delete row. + $('#deleterowbutton').on('click', function() { + var selectedrowindex = $('#grid').jqxGrid('getselectedrowindex'), + rowscount = $('#grid').jqxGrid('getdatainformation').rowscount, + id; + if (selectedrowindex >= 0 && selectedrowindex < rowscount) { + id = $('#grid').jqxGrid('getrowid', selectedrowindex); + $('#grid').jqxGrid('deleterow', id); + } + }); + }, + columns: [ + { text: 'Stap naam', datafield: 'name' }, + { text: 'Min. °C', datafield: 'target_lo', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1', + validation: function(cell, value) { + if (value < 0 || value > 50) { + return { result: false, message: 'De temperatuur moet tussen 0 en 50 zijn.' }; + } + return true; + } + }, + { text: 'Max. °C', datafield: 'target_hi', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1', + validation: function(cell, value) { + if (value < 0 || value > 50) { + return { result: false, message: 'De temperatuur moet tussen 0 en 50 zijn.' }; + } + return true; + } + }, + { text: 'Koelkast', datafield: 'fridgemode', columntype: 'checkbox', width: 80 }, + { text: 'Stap tijd', datafield: 'steptime', width: 80, align: 'right', cellsalign: 'right', + validation: function(cell, value) { + if (value < 0 || value > 14400) { + return { result: false, message: 'De tijd moet tussen 0 en 14400 zijn.' }; + } + return true; + } + }, + { text: 'Rust tijd', datafield: 'resttime', width: 80, align: 'right', cellsalign: 'right', + validation: function(cell, value) { + if (value < 0 || value > 14400) { + return { result: false, message: 'De tijd moet tussen 0 en 14400 zijn.' }; + } + return true; + } + } + ] + }); + }; - // initialize the input fields. - $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); - $("#inittemp_lo").jqxNumberInput( Spin1dec ); - $("#inittemp_lo").jqxNumberInput({ max: 40 }); - $("#inittemp_hi").jqxNumberInput( Spin1dec ); - $("#inittemp_hi").jqxNumberInput({ max: 40 }); - $("#fridgemode").jqxCheckBox({ theme: theme, height: 23, enableContainerClick: false }); + // initialize the input fields. + $('#name').jqxInput({ theme: theme, width: 640, height: 23 }); + $('#inittemp_lo').jqxNumberInput(Spin1dec); + $('#inittemp_lo').jqxNumberInput({ max: 40 }); + $('#inittemp_hi').jqxNumberInput(Spin1dec); + $('#inittemp_hi').jqxNumberInput({ max: 40 }); + $('#fridgemode').jqxCheckBox({ theme: theme, height: 23, enableContainerClick: false }); - // initialize jqxGrid - $("#jqxgrid").jqxGrid({ - width: 1280, - height: 630, - source: dataAdapter, - theme: theme, - showstatusbar: true, - renderstatusbar: function (statusbar) { - var addButton, container = $(""); - addButton = $("