UNPKG

node-red-contrib-sun-position

Version:
878 lines (838 loc) 73.1 kB
<!DOCTYPE HTML> <!-- This code is licensed under the Apache License Version 2.0. Copyright (c) 2022 Robert Gester Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. --> <script type="text/javascript"> (function() { RED.nodes.registerType('time-span', { category: 'time and astro', color: '#EDFDBF', icon: 'time-span-black.svg', inputs: 1, outputs: 1, defaults: { outputs: { value: 1 }, name: { value: '', required: false }, positionConfig: { value: '', type: 'position-config', required: true }, // #region operand1 operand1: { value: 'payload', validate: RED.validators.typedInput('operand1Type') }, operand1Type: { value: 'msgPayload' }, operand1Format: { value: 0, required: true, validate(v) { return (v !== '') || typeof v === 'undefined'; } }, operand1Offset: { value: 0, required: true, validate(v) { return RED.validators.typedInput('operand1OffsetType')(v) || $('#node-input-operand1OffsetType').val() === 'none' || this.operand1OffsetType === 'none'; } }, operand1OffsetType: { value: 'none' }, operand1OffsetMultiplier: { value: 60000, required: true, validate(v) { return RED.validators.number()(v) || $('#node-input-operand1OffsetType').val() === 'none' || this.operand1OffsetType === 'none'; } }, // #endregion operand1 // #region operand2 operand2: { value: '', validate: RED.validators.typedInput('operand2Type') }, operand2Type: { value: 'msg' }, operand2Format: { value: 0, required: true, validate(v) { return (v !== '') || typeof v === 'undefined'; } }, operand2Offset: { value: 0, required: true, validate(v) { return RED.validators.typedInput('operand2OffsetType')(v) || $('#node-input-operand2OffsetType').val() === 'none' || this.operand2OffsetType === 'none'; } }, operand2OffsetType: { value: 'none' }, operand2OffsetMultiplier: { value: 60000, required: true, validate(v) { return RED.validators.number()(v) || $('#node-input-operand2OffsetType').val() === 'none' || this.operand2OffsetType === 'none'; } }, // #endregion operand2 // #region rules rules: { value: [{ operator: 1, operatorText: '==', operandType: 'num', operandValue: '', multiplier: 60000 }] }, checkall: { value: 'true', required: true }, // #endregion rules // #region result1 results: { value: [ { p: '', pt: 'msgPayload', v: '', vt: 'input', o: 1, oT: 'none', oM: 60000, fTs: 1, f: 0, next: false, days: '*', months: '*' } ] }, result1: { value: 'none' }, // p result1Type: { value: '' }, // pt result1Value: { value: '' }, // v result1ValueType: { value: '' }, // vt result1TSFormat: { value: 0 }, // fTs result1Format: { value: 0 }, // f result1Offset: { value: 0 }, // o result1OffsetType: { value: 'none' }, // oT result1OffsetMultiplier: { value: 60000 } // oM // #endregion result1 }, outputLabels(index) { let label = ''; if (this.rules.length) { const rule = this.rules[index]; if (rule) { label = rule.operatorText + ' ' + RED.nodes.getType('position-config').getRDGNodeValLbl(this, rule.operandType, rule.operandValue); if (rule.propertyType !== 'none') { label += ' only if ' + RED.nodes.getType('position-config').getRDGNodeValLbl(this, rule.propertyType, rule.propertyValue) + ' is true'; } return label; } if (this.checkall === 'true') { return 'always'; } return 'otherwise'; // return ["msg if comparision is true", "msg if comparision is false"]; } return 'input msg after evaluation'; }, label() { if (this.name) { return this.name; } if (!this.rules || this.rules.length <= 1) { const op1 = RED.nodes.getType('position-config').getRDGNodeValLbl(this, this.operand1Type, this.operand1); const op2 = RED.nodes.getType('position-config').getRDGNodeValLbl(this, this.operand2Type, this.operand2); return op1 + ' - ' + op2; } else if (this.rules.length === 1) { const op1 = RED.nodes.getType('position-config').getRDGNodeValLbl(this, this.operand1Type, this.operand1); const op2 = RED.nodes.getType('position-config').getRDGNodeValLbl(this, this.operand2Type, this.operand2); const cmp = RED.nodes.getType('position-config').getRDGNodeValLbl(this, this.rules[0].operandType, this.rules[0].operandValue); return op1 + ' - ' + op2 + ' ' + this.rules[0].operatorText + ' ' + cmp; } const op1 = RED.nodes.getType('position-config').getRDGNodeValLbl(this, this.operand1Type, this.operand1); const op2 = RED.nodes.getType('position-config').getRDGNodeValLbl(this, this.operand2Type, this.operand2); return op1 + ' - ' + op2 + ' ' + this._('time-span.label.compare'); // return this._('time-span.label.time-span'); }, labelStyle() { return this.name ? 'node_label_italic' : ''; }, paletteLabel: 'time span', align: 'left', oneditprepare() { setTimeout(() => { $('.is-to-show-initially').show(); $('.is-to-hide-initially').hide(); }, 300); const node = this; const $nodeConfig = $('#node-input-positionConfig'); const setup = function(node) { /* global getTypes getSelectFields appendOptions setupTInput autocomplete addLabel initCombobox getBackendData bdDateToTime getCheckboxesStr setTInputValue */ const types = getTypes(node, () => $nodeConfig.val()); const selFields = getSelectFields(); // #region operand1 setupTInput(node, { typeProp: 'operand1Type', valueProp: 'operand1', width: 'calc(100% - 110px)', defaultType: types.MsgPayload.value, types: [ 'msg', types.MsgPayload, types.MsgTs, types.MsgLc, types.MsgValue, 'flow', 'global', 'date', types.DateSpecific, 'num', 'str', types.DateEntered, types.TimeSun, types.TimeSunCustom, types.TimeSunNow, types.TimeMoon, types.DayOfMonth, 'env' ], onChange(_type, _value) { const $operand1 = $('#node-input-operand1'); const opType = $operand1.typedInput('type'); if (opType === types.DateSpecific.value || opType === types.TimeEntered.value || opType === types.DateEntered.value || opType === types.TimeSun.value || opType === types.TimeSunCustom.value || opType === types.TimeMoon.value || opType === types.DayOfMonth.value) { $('.time-row-operand1Format').hide(); $('.time-row-operand1Offset').show(); } else if (opType === 'msg' || opType === types.MsgPayload.value || opType === types.MsgTs.value || opType === types.MsgLc.value || opType === types.MsgValue.value || opType === 'flow' || opType === 'global' || opType === 'str' || opType === 'num' || opType === 'env') { $('.time-row-operand1Format').show(); $('.time-row-operand1Offset').show(); } else { $('.time-row-operand1Format').hide(); $('.time-row-operand1Offset').hide(); } getBackendData(d => { const $div = $('#node-input-operand1-div'); const titleOrg = $div.attr('titleOrg'); $div.attr('title', bdDateToTime(d, ' - ') + titleOrg); }, { nodeId: node.id, kind: 'getTimeData', config: $nodeConfig.val(), type: opType, value: $operand1.typedInput('value'), next: $('#node-input-operand1Next').is(':checked'), format: $('#node-input-operand1Format').val(), offsetType: $('#node-input-operand1Offset').typedInput('type'), offset: $('#node-input-operand1Offset').typedInput('value'), multiplier: $('#node-input-operand1OffsetMultiplier').val(), noOffsetError: true }); } }); initCombobox(node, $('#node-input-operand1Formatsel'), $('#node-input-operand1Format'), 'dateParseFormat', 'parseFormats', node.operand1Format, 20); const $operand1Multiplier = $('#node-input-operand1OffsetMultiplier'); appendOptions(node, $operand1Multiplier, 'multiplier'); $operand1Multiplier.val(node.operand1OffsetMultiplier); setupTInput(node, { typeProp: 'operand1OffsetType', valueProp: 'operand1Offset', width: 'calc(100% - 255px)', defaultType: types.Undefined.value, types: [types.Undefined, 'num', 'msg', 'flow', 'global', 'env', types.randomNumber, types.randmNumCachedDay, types.randmNumCachedWeek], onChange(_type, _value) { const type = $('#node-input-operand1Offset').typedInput('type'); if (type === types.Undefined.value) { $('#node-input-operand1OffsetMultiplier').prop('disabled', true); } else { $('#node-input-operand1OffsetMultiplier').prop('disabled', false); } $('#node-input-operand1').change(); } }).change(); // #endregion operand1 // #region operand2 setupTInput(node, { typeProp: 'operand2Type', valueProp: 'operand2', width: 'calc(100% - 110px)', defaultType: types.MsgPayload.value, types: [ 'msg', types.MsgPayload, types.MsgTs, types.MsgLc, types.MsgValue, 'flow', 'global', 'date', types.DateSpecific, 'num', 'str', types.DateEntered, types.TimeSun, types.TimeSunCustom, types.TimeSunNow, types.TimeMoon, types.DayOfMonth, 'env' ], onChange(_type, _value) { const $operand2 = $('#node-input-operand2'); const opType = $operand2.typedInput('type'); if (opType === types.DateSpecific.value || opType === types.TimeEntered.value || opType === types.DateEntered.value || opType === types.TimeSun.value || opType === types.TimeSunCustom.value || opType === types.TimeMoon.value || opType === types.DayOfMonth.value) { $('.time-row-operand2Format').hide(); $('.time-row-operand2Offset').show(); } else if (opType === 'msg' || opType === types.MsgPayload.value || opType === types.MsgTs.value || opType === types.MsgLc.value || opType === types.MsgValue.value || opType === 'flow' || opType === 'global' || opType === 'str' || opType === 'num' || opType === 'env') { $('.time-row-operand2Format').show(); $('.time-row-operand2Offset').show(); } else { $('.time-row-operand2Format').hide(); $('.time-row-operand2Offset').hide(); } getBackendData(d => { const $div = $('#node-input-operand2-div'); const titleOrg = $div.attr('titleOrg'); $div.attr('title', bdDateToTime(d, ' - ') + titleOrg); }, { nodeId: node.id, kind: 'getTimeData', config: $nodeConfig.val(), type: opType, value: $operand2.typedInput('value'), format: $('#node-input-operand2Format').val(), next: $('#node-input-operand2Next').is(':checked'), offsetType: $('#node-input-operand2Offset').typedInput('type'), offset: $('#node-input-operand2Offset').typedInput('value'), multiplier: $('#node-input-operand2OffsetMultiplier').val(), noOffsetError: true }); } }); initCombobox(node, $('#node-input-operand2Formatsel'), $('#node-input-operand2Format'), 'dateParseFormat', 'parseFormats', node.operand2Format, 20); const $operand2Multiplier = $('#node-input-operand2OffsetMultiplier'); appendOptions(node, $operand2Multiplier, 'multiplier'); $operand2Multiplier.val(node.operand2OffsetMultiplier); setupTInput(node, { typeProp: 'operand2OffsetType', valueProp: 'operand2Offset', width: 'calc(100% - 255px)', defaultType: types.Undefined.value, types: [types.Undefined, 'num', 'msg', 'flow', 'global', 'env', types.randomNumber, types.randmNumCachedDay, types.randmNumCachedWeek], onChange(_type, _value) { const type = $('#node-input-operand2Offset').typedInput('type'); if (type === types.Undefined.value) { $('#node-input-operand2OffsetMultiplier').prop('disabled', true); } else { $('#node-input-operand2OffsetMultiplier').prop('disabled', false); } $('#node-input-operand2').change(); } }).change(); // #endregion operand2 // #region rule-container /** * resizes the rule container */ function resizeRuleContainer() { const editorRow = $('.node-input-rule-container-row ol'); const height = editorRow.outerHeight(true); const rowCount = $('#node-input-rule-container').editableList('length'); if (rowCount > 0) { $('#node-input-rule-container').editableList('height', height + 40); } else { $('#node-input-rule-container').editableList('height', 20); } } /** * resizes a rule * @param {jQuery} rule - the jQuery selector of the rule */ function resizeRule(rule) { const newWidth = rule.width() - 10; const $operator = rule.find('.node-input-rule-operator'); const $operand = rule.find('.node-input-rule-operand'); const $multiplier = rule.find('.node-input-rule-multiplier'); const lblWidth = 25; // row1 if (Number($operator.val()) === 99) { $operator.width(newWidth - lblWidth - 20); } else { const operatorWidth = 60; const multiplierWidth = 125; $operator.width(operatorWidth); $multiplier.width(multiplierWidth); $operand.typedInput('width', (newWidth - operatorWidth - multiplierWidth - lblWidth - 45)); } } $('#node-input-rule-container').css('min-height', '20px').css('min-width', '200px').editableList({ addItem($containerRow, containerIndex, data) { $containerRow.css({overflow: 'hidden', whiteSpace: 'nowrap'}); const $row = $('<div/>').appendTo($containerRow); // row1 // operator const $operator = $('<select/>', { class: 'node-input-rule-operator', id: 'node-input-rule-operator' + containerIndex }).appendTo($row); appendOptions(node, $operator, 'operators'); $operator.val(data.operator || selFields.operators[0].id); const $operandDiv = $('<span />').appendTo($row); // , { style: 'display: inline-block;' } $('<input/>', { class: 'node-input-rule-operand', id: 'node-input-rule-operand' + containerIndex, type: 'text', value: (data.operandValue || '') }).appendTo($operandDiv).typedInput({ default: (data.operandType || 'num'), types: ['msg', 'flow', 'global', 'num', 'env', 'jsonata'] }); const $multiplier = $('<select/>', { class: 'node-input-rule-multiplier', id: 'node-input-rule-multiplier' + containerIndex }).appendTo($operandDiv); appendOptions(node, $multiplier, 'multiplier', data => (data.id > 0) ); $multiplier.val(data.multiplier || 60000); const finalspan = $('<span/>', { style: 'float: right; margin-top: 6px;' }).appendTo($row); finalspan.append(' &#8594; <span class="node-input-rule-index">' + (containerIndex + 1) + '</span> '); $operator.change(() => { if (Number($operator.val()) === 99) { $operandDiv.hide(); } else { $operandDiv.show(); } resizeRule($containerRow); }); $operator.change(); // resizeRule($containerRow); resizeRuleContainer(); }, sortItems(rules) { rules.each(function (i) { $(this).find('.node-input-rule-index').html(i + 1); }); }, resizeItem: resizeRule, sortable: true, removable: true, removeItem: resizeRuleContainer }); if (node.rules) { for (let i = 0; i < node.rules.length; i++) { const rule = node.rules[i]; $('#node-input-rule-container').editableList('addItem', rule); } } // #endregion rule-container // #region result-container /** resizes result container */ function resizeResultContainer() { const editorRow = $('.node-input-result-container-row ol'); const height = editorRow.outerHeight(true); const rowCount = $('#node-input-result-container').editableList('length'); if (rowCount > 0) { $('#node-input-result-container').editableList('height', height + 40); } else { $('#node-input-result-container').editableList('height', 20); } } $('#node-input-result-container').css('min-height', '40px').css('min-width', '400px').editableList({ addItem($containerRow, containerIndex, data) { $containerRow.css({ overflow: 'hidden', whiteSpace: 'nowrap' }); const $row1 = $('<div/>').appendTo($containerRow); const $row2a = $('<div/>', { style: 'padding-top: 5px;' }).appendTo($containerRow); const $row2b = $('<div/>', { style: 'padding-top: 5px;' }).appendTo($containerRow); const $row3 = $('<div/>', { style: 'padding-top: 5px;' }).appendTo($containerRow); const $row4 = $('<div/>', { style: 'padding-top: 5px;' }).appendTo($containerRow); // row1 - Property / Type Selection let prop = data; if (!Object.prototype.hasOwnProperty.call(prop, 'p')) { prop = { p: '', pt: types.MsgPayload.value, v: '', vt: 'input', o: '', oT: types.Undefined.value, oM: 60000, fTs: 1, f: 0, next: false, days: '*', months: '*' }; } if (prop.p === 'payload' && (!prop.pt || prop.pt === 'msg')) { prop.pt = types.MsgPayload.value; } else if (prop.p === 'topic' && (!prop.pt || prop.pt === 'msg')) { prop.pt = types.MsgTopic.value; } else if (prop.p === 'ts' && (!prop.pt || prop.pt === 'msg')) { prop.pt = types.MsgTs.value; } else if (prop.p === 'lc' && (!prop.pt || prop.pt === 'msg')) { prop.pt = types.MsgLc.value; } else if (prop.p === 'value' && (!prop.pt || prop.pt === 'msg')) { prop.pt = types.MsgValue.value; } const $propertyName = $('<input/>', { class: 'node-input-prop-result-name', type: 'text' }) .css('width', '40%') .appendTo($row1) .typedInput({ default: types.MsgPayload.value, types: [ types.MsgPayload, types.MsgTopic, types.MsgTs, types.MsgLc, types.MsgValue, 'msg', 'flow', 'global' ] }); setTInputValue($propertyName, prop.p, prop.pt); $('<div/>', { style: 'display:inline-block; padding:0px 6px;' }) .text('=') .appendTo($row1); const $propertyValue = $('<input/>', { class: 'node-input-prop-result-value', type: 'text' }) .css('width', 'calc(60% - 30px)') .appendTo($row1) .typedInput({ default: 'timespan', types: [ { value: 'timespan', label: node._('time-span.typeLabel.timespan'), hasValue: false }, { value: 'operand1', label: node._('time-span.typeLabel.operand1'), hasValue: false }, { value: 'operand2', label: node._('time-span.typeLabel.operand2'), hasValue: false }, 'date', types.DateSpecific, types.TimeEntered, types.DateEntered, types.TimeSun, types.TimeSunCustom, types.TimeSunNow, types.TimeMoon, types.DayOfMonth, 'str', 'num', 'bool', 'json', 'bin', 'env', 'msg', 'flow', 'global', 'jsonata', types.strPlaceholder, types.SunCalc, types.SunInSky, types.MoonCalc, types.MoonPhase, types.SunAzimuth, types.SunElevation, types.SunTimeByAzimuth, types.SunTimeByElevationObj, types.SunTimeByElevationNext, types.SunTimeByElevationRise, types.SunTimeByElevationSet, types.isDST, types.WeekOfYear, types.WeekOfYearEven, types.DayOfYear, types.DayOfYearEven, types.numPercent, types.randomNumber, types.randmNumCachedDay, types.randmNumCachedWeek, types.nodeId, types.nodeName, types.nodePath ] }); setTInputValue($propertyValue, prop.v, prop.vt); // row2a - Format Selection const operandFormatTSSelFieldName = 'node-input-prop-result-FormatTSSel'; addLabel($row2a, operandFormatTSSelFieldName, 'fa fa-sign-out'); // data-i18n="time-span.label.result1TSFormat" const $formatTSSel = $('<select/>', { class: operandFormatTSSelFieldName }).appendTo($row2a); const $formatTSIp = $('<input/>', { class: 'node-input-prop-result-FormatTSIp', type: 'text' }) .css('width', 'calc(100% - 30px)') .appendTo($row2a); initCombobox(node, $formatTSSel, $formatTSIp, 'dateOutTSFormat', 'outputTSFormats', prop.fTs ? prop.fTs : 1, -70); // initCombobox(node, $('#node-input-result1TSFormatSel'), $('#node-input-result1TSFormat'), 'dateOutTSFormat', 'outputTSFormats', node.result1TSFormat, 30); // row2b - Format Selection const operandFormatSelFieldName = 'node-input-prop-result-FormatSel'; addLabel($row2b, operandFormatSelFieldName, 'fa fa-file-code-o'); const $formatSel = $('<select/>', { class: operandFormatSelFieldName }).appendTo($row2b); const $formatIp = $('<input/>', { class: 'node-input-prop-result-FormatIp', type: 'text' }) .css('width', 'calc(100% - 30px)') .appendTo($row2b); initCombobox(node, $formatSel, $formatIp, 'dateOutFormat', 'outputFormats', prop.f ? prop.f : 0, -70); // initCombobox(node, $('#node-input-result1FormatSel'), $('#node-input-result1Format'), 'dateOutFormat', 'outputFormats', node.result1Format, 30); // row3 - Offset and Multiplier addLabel($row3, 'node-input-prop-result-offset', 'fa fa-plus'); const $offset = $('<input/>', { class: 'node-input-prop-result-offset', type: 'text', value: (prop.o ? prop.o : '') }) .css('width', '70%') .appendTo($row3) .typedInput({ default: (prop.oT ? prop.oT : types.Undefined.value), types: [types.Undefined, 'num', 'msg', 'flow', 'global', 'env', types.randomNumber, types.randmNumCachedDay, types.randmNumCachedWeek] }); setTInputValue($offset, prop.o, prop.oT); const $multiplier = $('<select/>', { class: 'node-input-prop-result-multiplier' }) .css('width', 'calc(30% - 30px)') .appendTo($row3); appendOptions(node, $multiplier, 'multiplier'); $multiplier.val(prop.oM ? prop.oM : 60000); /* org const $resultMultiplier = $('#node-input-result1OffsetMultiplier'); appendOptions(node, $resultMultiplier, 'multiplier'); $resultMultiplier.val(node.result1OffsetMultiplier); setupTInput(node, { typeProp: 'result1OffsetType', valueProp: 'result1Offset', width: 'calc(100% - 265px)', defaultType: types.Undefined.value, types: [types.Undefined, 'num', 'msg', 'flow', 'global', 'env', types.randmNumCachedDay, types.randmNumCachedWeek], onChange(_type, _value) { const type = $('#node-input-result1Offset').typedInput('type'); if (type === types.Undefined.value) { $('#node-input-result1OffsetMultiplier').prop('disabled', true); } else { $('#node-input-result1OffsetMultiplier').prop('disabled', false); } } }).change(); */ // row4 - Next, Day, Month selection // row4 - 1 - Next selection const $divNext = $('<div/>').appendTo($row4); addLabel($divNext, 'node-input-prop-result-Next', 'fa fa-clock-o', node._('node-red-contrib-sun-position/position-config:common.label.nextOccurrence')); const $cbNext = $('<input/>', { class: 'node-input-prop-result-Next', type: 'checkbox', style: 'display:inline-block; width:15px; vertical-align:baseline;' }) .css('width', 'calc(30% - 30px)') .appendTo($divNext); if (typeof prop.next === 'undefined' || prop.next === null || prop.next == true) { // eslint-disable-line eqeqeq $cbNext.prop('checked', true); } else { $cbNext.prop('checked', false); } // row4 - 2 - Day selection const $divMnDays = $('<div/>', { style: 'margin-top:5px;border-top: 1px solid #000;margin-bottom: 0;' } ).appendTo($row4); addLabel($divMnDays, 'node-input-prop-result-days', 'fa fa-clock-o', node._('node-red-contrib-sun-position/position-config:common.label.validForDays')); const $divDays = $('<div/>', { class: 'node-input-prop-result-days', style: 'style="display:inline-block;' }).appendTo($divMnDays); const $divDays2 = $('<div/>').appendTo($divDays); for (let d = 0; d < 7; d++) { const $lbl = $('<label/>', { title: node._('node-red-contrib-sun-position/position-config:common.days.' + d) }) .css('width', 'calc(14% - 7px)') // (100% / 7 = 14%) - (30 px / 7 = 7px) .appendTo($divDays2); const $cb = $('<input/>', { type: 'checkbox', class: 'node-input-prop-result-day-' + d, value: d, style: 'width: auto;' }).appendTo($lbl); $('<span/>').text(node._('node-red-contrib-sun-position/position-config:common.days.' + (d + 7))).appendTo($lbl); if (typeof prop.days === 'undefined' || prop.days === null || prop.days === '*') { $cb.prop('checked', true); } else if (prop.days !== '' && prop.days !== 'none') { $cb.prop('checked', false); prop.days.split(',').forEach(v => { if (v == d) { // eslint-disable-line eqeqeq $cb.prop('checked', true); } }); } } // row4 - 3 - Special Limit selection const $divSpecLimit = $('<div/>', { style: 'margin-top:5px;border-top: 1px solid #000;margin-bottom: 0;' } ).appendTo($row4); addLabel($divSpecLimit, 'node-input-prop-result-speciallimits', 'fa fa-clock-o', node._('node-red-contrib-sun-position/position-config:common.label.specialLimits')); const $divSpecLimits = $('<div/>', { class: 'node-input-prop-result-speciallimits', style: 'style="display:inline-block;' }).appendTo($divSpecLimit); const $divSpecLimits2 = $('<div/>').appendTo($divSpecLimits); const $divSpecLimits3 = $('<div/>').appendTo($divSpecLimits); const $lblSL1 = $('<label/>', { title: node._('node-red-contrib-sun-position/position-config:common.label.onlyEvenDays'), style: 'width:calc(50% - 15px);' // (100% / 2) - (30 px / 2) }) .appendTo($divSpecLimits2); const $cbOnlyEvenDays = $('<input/>', { type: 'checkbox', class: 'node-input-prop-result-onlyEvenDays', style: 'width: auto;' }).appendTo($lblSL1); $('<span/>').text(node._('node-red-contrib-sun-position/position-config:common.label.onlyEvenDays')).appendTo($lblSL1); $cbOnlyEvenDays.prop('checked', (prop.onlyEvenDays === 'true' || prop.onlyEvenDays === true)); const $lblSL2 = $('<label/>', { title: node._('node-red-contrib-sun-position/position-config:common.label.onlyOddDays'), style: 'width:calc(50% - 15px);' // (100% / 2) - (30 px / 2) }) .appendTo($divSpecLimits2); const $cbOnlyOddDays = $('<input/>', { type: 'checkbox', class: 'node-input-prop-result-onlyOddDays', style: 'width: auto;' }).appendTo($lblSL2); $('<span/>').text(node._('node-red-contrib-sun-position/position-config:common.label.onlyOddDays')).appendTo($lblSL2); $cbOnlyOddDays.prop('checked', (prop.onlyOddDays === 'true' || prop.onlyOddDays === true)); const $lblSL3 = $('<label/>', { title: node._('node-red-contrib-sun-position/position-config:common.label.onlyEvenWeeks'), style: 'width:calc(50% - 15px);' // (100% / 2) - (30 px / 2) }) .appendTo($divSpecLimits3); const $cbOnlyEvenWeeks = $('<input/>', { type: 'checkbox', class: 'node-input-prop-result-onlyEvenWeeks', style: 'width: auto;' }).appendTo($lblSL3); $('<span/>').text(node._('node-red-contrib-sun-position/position-config:common.label.onlyEvenWeeks')).appendTo($lblSL1); $cbOnlyEvenWeeks.prop('checked', (prop.onlyEvenWeeks === 'true' || prop.onlyEvenWeeks === true)); const $lblSL4 = $('<label/>', { title: node._('node-red-contrib-sun-position/position-config:common.label.onlyOddWeeks'), style: 'width:calc(50% - 15px);' // (100% / 2) - (30 px / 2) }) .appendTo($divSpecLimits3); const $cbOnlyOddWeeks = $('<input/>', { type: 'checkbox', class: 'node-input-prop-result-onlyOddWeeks', style: 'width: auto;' }).appendTo($lblSL4); $('<span/>').text(node._('node-red-contrib-sun-position/position-config:common.label.onlyOddWeeks')).appendTo($lblSL2); $cbOnlyOddWeeks.prop('checked', (prop.onlyOddWeeks === 'true' || prop.onlyOddWeeks === true)); // row4 - 3 - Month selection const $divMnMonth = $('<div/>', { style: 'margin-top:5px;border-top: 1px solid #000;margin-bottom: 0;' } ).appendTo($row4); addLabel($divMnMonth, 'node-input-prop-result-months', 'fa fa-clock-o', node._('node-red-contrib-sun-position/position-config:common.label.validForMonths')); const $divMonths = $('<div/>', { class: 'node-input-prop-result-months', style: 'style="display:inline-block;' }).appendTo($divMnMonth); const $divMonths2 = $('<div/>').appendTo($divMonths); const $divMonths3 = $('<div/>').appendTo($divMonths); for (let m = 0; m < 12; m++) { const $lbl = $('<label/>', { title: node._('node-red-contrib-sun-position/position-config:common.months.' + m) }) .css('width', 'calc(16% - 6px)') // (100% / 7 = 14%) - (30 px / 7 = 6px) .appendTo((m > 5) ? $divMonths3 : $divMonths2); const $cb = $('<input/>', { type: 'checkbox', class: 'node-input-prop-result-month-' + m, value: m, style: 'width: auto;' }).appendTo($lbl); $('<span/>').text(node._('node-red-contrib-sun-position/position-config:common.months.' + (m + 12))).appendTo($lbl); if (typeof prop.months === 'undefined' || prop.months === null || prop.months === '*') { $cb.prop('checked', true); } else if (prop.months !== '' && prop.months !== 'none') { $cb.prop('checked', false); prop.months.split(',').forEach(v => { if (v == m) { // eslint-disable-line eqeqeq $cb.prop('checked', true); } }); } } // changes $propertyValue.change(() => { // $operand.show(); // const plNType = $propertyName.typedInput('type'); const plVType = $propertyValue.typedInput('type'); if (plVType === types.TimeEnt