diff --git a/README.md b/README.md index 6a801d8..32c5229 100644 --- a/README.md +++ b/README.md @@ -56,8 +56,8 @@ SOFTWARE. ## Attribution The following icons have been taken from Node-RED provided nodes: -* Timer icon (delay node) -* Switch icon (switch node) +* Timer icon (Node-RED delay node) +* Switch icon (Node-RED switch node) The following icons have been taken from Flaticon: * Hour glass icon made by Freepik from www.flaticon.com diff --git a/nodes/delay.html b/nodes/delay.html index 1bd05f2..2f10afc 100644 --- a/nodes/delay.html +++ b/nodes/delay.html @@ -38,11 +38,11 @@
- + - +
diff --git a/nodes/locales/en-US/config.json b/nodes/locales/en-US/config.json index d36c1ac..895c63d 100644 --- a/nodes/locales/en-US/config.json +++ b/nodes/locales/en-US/config.json @@ -10,7 +10,9 @@ "time": "Time of Day", "sun": "Sun Position", "moon": "Moon Position", - "fullMessage": "full message" + "fullMessage": "full message", + "offset": "Offset", + "random": "Randomized" }, "list": { diff --git a/nodes/locales/en-US/delay.json b/nodes/locales/en-US/delay.json index fbf6c89..2862626 100644 --- a/nodes/locales/en-US/delay.json +++ b/nodes/locales/en-US/delay.json @@ -5,9 +5,7 @@ { "outputPort": "delayed message", "min": " min.", - "when": "When", - "offset": "Offset", - "random": "Randomized" + "when": "When" }, "status": { diff --git a/nodes/switch.html b/nodes/switch.html index 4873ad3..eefc2dd 100644 --- a/nodes/switch.html +++ b/nodes/switch.html @@ -82,7 +82,7 @@ }, conditions: { - value: [{operator: "before", operands: {type: "time", value: ""}, label: ""}] + value: [{operator: "before", operands: {type: "time", value: "", offset: 0, random: false}, label: ""}] }, stopOnFirstMatch: { @@ -200,9 +200,33 @@ options: moonTimes }; + const offsetInput = + { + min: -300, + max: 300, + step: 5, + change: function(event, ui) + { + var value = parseInt(this.value, 10); + var min = $(this).spinner("option", "min"); + var max = $(this).spinner("option", "max"); + if (isNaN(value) || + (value < min)) + { + $(this).spinner("value", min); + } + else if (value > max) + { + $(this).spinner("value", max); + } + } + }; + let fragment = document.createDocumentFragment(); let operatorBox = $("
", {style: "display: inline-block; vertical-align: middle; width: auto;"}).appendTo(fragment); - let operandBox = $("
", {style: "display: inline-block; vertical-align: middle; width: auto; padding-left: 2px;"}).appendTo(fragment); + let timeBox = $("
", {style: "display: inline-block; vertical-align: middle; width: auto; margin-left: 2px;"}).appendTo(fragment); + let weekdaysBox = $("
", {style: "display: inline-block; vertical-align: middle; width: auto; margin-left: 2px;"}).appendTo(fragment); + let monthsBox = $("
", {style: "display: inline-block; vertical-align: middle; width: auto; margin-left: 2px;"}).appendTo(fragment); $("
", {class: "node-input-index", style: "position: absolute; width: auto; top: 50%; right: 26px; margin-top: -9px;"}) .html("→ " + (index + 1)) .appendTo(fragment); @@ -216,117 +240,140 @@ .append($("").val("months").text(node._("node-red-contrib-chronos/chronos-config:common.list.operator.months"))) .appendTo(operatorBox); - let subRow1 = $("
").appendTo(operandBox); - let subRow2 = $("
", {style: "margin-top: 5px;"}).appendTo(operandBox); - let subRow3 = $("
", {style: "margin-top: 5px;"}).appendTo(operandBox); - - let time1 = $("", {type: "text", class: "node-input-time1", style: "margin-left: 4px"}) - .appendTo(subRow1) + let time1Box = $("
", {style: "margin-left: 4px;"}).appendTo(timeBox); + let time2Box = $("
", {style: "margin-left: 4px; margin-top: 5px;"}).appendTo(timeBox); + let time1Row1 = $("
").appendTo(time1Box); + let time1Row2 = $("
", {style: "margin-top: 5px;"}).appendTo(time1Box); + let time2Row1 = $("
").appendTo(time2Box); + let time2Row2 = $("
", {style: "margin-top: 5px;"}).appendTo(time2Box); + let monthsRow1 = $("
").appendTo(monthsBox); + let monthsRow2 = $("
", {style: "margin-top: 5px;"}).appendTo(monthsBox); + let monthsRow3 = $("
", {style: "margin-top: 5px;"}).appendTo(monthsBox); + + let time1 = $("", {type: "text", class: "node-input-time1"}) + .appendTo(time1Row1) .typedInput({types: [timeInput, sunTimeInput, moonTimeInput]}); time1.typedInput("width", "280px"); + let extend1 = $("", {href: "#", style: "margin-left: 6px;"}) + .html("") + .appendTo(time1Row1); - let time2 = $("", {type: "text", class: "node-input-time2", style: "margin-left: 4px;"}) - .appendTo(subRow2) + let time2 = $("", {type: "text", class: "node-input-time2"}) + .appendTo(time2Row1) .typedInput({types: [timeInput, sunTimeInput, moonTimeInput]}); time2.typedInput("width", "280px"); + let extend2 = $("", {href: "#", style: "margin-left: 6px;"}) + .html("") + .appendTo(time2Row1); + + $("