UNPKG

node-red-contrib-issurmelacha

Version:

A Filter for Node-Red to divide the flow when an Issur melacha is in effect

112 lines (109 loc) 4.51 kB
<script type="text/javascript"> RED.nodes.registerType('issur-melacha',{ category: 'function', color: '#a6bbcf', defaults: { name: {value:""}, lat: {value: 0, required:true}, lon: {value: 0, required:true}, diaspora: {value:true}, startoffset: {value:0}, endoffset: {value:72}, delay: {value:0}, delaytype: {value:60000} }, inputs:1, outputs:2, outputLabels: ["In Effect", "Not in Effect"], icon: "switch.png", label: function() { return this.name||"Issur Melacha?"; }, oneditprepare: function() { if (($("#node-input-lat").val() === "0") && ($("#node-input-lon").val() === "0")) { if ("geolocation" in navigator) { navigator.geolocation.getCurrentPosition(function(position) { $("#node-input-lat").val(Number(position.coords.latitude.toFixed(5))); $("#node-input-lon").val(Number(position.coords.longitude.toFixed(5))); }); } } } }); </script> <script type="text/html" data-template-name="issur-melacha"> <style> div.checkbox-field{ max-width:200px; } div.checkbox-field input { width:20px; margin-bottom:4px; } .large-label { width:100%; } </style> <div class="form-row"> <label for="node-input-name"><i class="fa fa-tag"></i> Name</label> <input type="text" id="node-input-name" placeholder="Issur Melacha?"> </div> <div class="form-row"> <label for="node-input-lat"><i class="fa fa-compass"></i> Lat</label> <input type="text" id="node-input-lat" placeholder="0"> </div> <div class="form-row"> <label for="node-input-lon"><i class="fa fa-compass"></i> Lon</label> <input type="text" id="node-input-lon" placeholder="0"> </div> <div class="form-row checkbox-field"> <label for="node-input-diaspora"><i class="fa fa-map"></i> Diaspora</label> <input type="checkbox" checked id="node-input-diaspora" style="width:20px;margin-bottom:4px;"> </div> <hr/> <h5>Custom Zmanim Offset (in minutes)</h5> <div class="form-row"> <label for="node-input-startoffset" class="large-label" style="width:100%"><i class="fa fa-time"></i>Start Offset (based on Sunset - default 0)</label> <input type="text" id="node-input-startoffset" placeholder="0"> </div> <div class="form-row"> <label for="node-input-endoffset" class="large-label" style="width:100%"><i class="fa fa-time"></i>End Offset (based on Sunset - default 72 min)</label> <input type="text" id="node-input-endoffset" placeholder="72"> </div> <hr/> <h5>Optional Repeat msg (when Issur Melacha only)</h5> <div class="form-row"> <label for="node-input-delay" style="width:100%">Repeat every</label> <input type="number" id="node-input-delay" placeholder="0" style="width:60px;"> <select id="node-input-delaytype" name="node-input-delaytype"> <option value="1000">Seconds</option> <option value="60000" selected="selected">Minutes</option> <option value="3600000">Hours</option> </select> </div> <div class="form-row"> <input id="node-input-onlyifstartonissur" type="checkbox" /> <label for="node-input-onlyifstartonissur"> <span>Only Repeat if event was triggered while issur melacha is in effect:</span> <br/> <i>(will also stop repeating when issur melacha ends)</i> </label> </div> </script> <script type="text/html" data-help-name="issur-melacha"> <h3>Overview</h3> <p>Issur Melacha is a simple filter which will output an incoming msg to one of two different outputs depending if an Issur Melacha (on Jewish Holidays and Shabbet) is in effect.</p> <h3>Options</h3> <h4>Lat (required)</h4> The Latitude to calculate the Zmanim. <h4>Lon (required)</h4> The Longitude to calculate the Zmanim. <h4>Diaspora</h4> Whether to apply Zmanim for the Diaspora (2 days on Holidays). <h4>Start Offset</h4> You can add a custom offset (in minutes) calculated on Sunset when the Zman for Issur Melacha starts (can be either positive or negative), the default is at Sunset. <h4>End Offset</h4> You can add a custom offset (in minutes) calculated on Sunset when the Zman for Issur Melacha ends (can be either positive or negative), the default is 72 min after Sunset. <h4>Repeat msg</h4> While an Issur Melacha is in effect the msg can be repated by a preset interval. </script>