2013-10-19 15:31:42 +02:00
|
|
|
|
2020-04-03 23:25:35 +02:00
|
|
|
<script type="text/html" data-template-name="sunrise">
|
2023-03-21 11:20:23 +01:00
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-lat"><i class="fa fa-globe"></i><span data-i18n="sunrise.label.latitude"></span></label>
|
|
|
|
<input type="text" id="node-input-lat" placeholder="51.025">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-lon"><i class="fa fa-globe"></i><span data-i18n="sunrise.label.longitude"></span></label>
|
|
|
|
<input type="text" id="node-input-lon" placeholder="-1.4">
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-start"><i class="fa fa-clock-o"></i><span data-i18n="sunrise.label.start"></label>
|
|
|
|
<select id="node-input-start" style='width:70%'>
|
|
|
|
<option value="nightEnd" data-i18n="sunrise.nightEnd"></option>
|
|
|
|
<option value="nauticalDawn" data-i18n="sunrise.nauticalDawn"></option>
|
|
|
|
<option value="dawn" data-i18n="sunrise.dawn"></option>
|
|
|
|
<option value="sunrise" data-i18n="sunrise.sunrise"></option>
|
|
|
|
<option value="sunriseEnd" data-i18n="sunrise.sunriseEnd"></option>
|
|
|
|
<option value="goldenHourEnd" data-i18n="sunrise.goldenHourEnd"></option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-end"><i class="fa fa-clock-o"></i><span data-i18n="sunrise.label.end"></label>
|
|
|
|
<select id="node-input-end" style='width:70%'>
|
|
|
|
<option value="goldenHour" data-i18n="sunrise.goldenHour"></option>
|
|
|
|
<option value="sunsetStart" data-i18n="sunrise.sunsetStart"></option>
|
|
|
|
<option value="sunset" data-i18n="sunrise.sunset"></option>
|
|
|
|
<option value="dusk" data-i18n="sunrise.dusk"></option>
|
|
|
|
<option value="nauticalDusk" data-i18n="sunrise.nauticalDusk"></option>
|
|
|
|
<option value="night" data-i18n="sunrise.night"></option>
|
|
|
|
</select>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label><i class="fa fa-arrows-h"></i><span data-i18n="sunrise.label.offset"></label>
|
|
|
|
<span style="margin-right:4px" data-i18n="sunrise.start"></span> <input type="text" id="node-input-soff" placeholder="minutes" style='width:60px;' > <span data-i18n="sunrise.mins"></span>
|
|
|
|
<span style="margin-left:14px; margin-right:4px" data-i18n="sunrise.end"></span> <input type="text" id="node-input-eoff" placeholder="minutes" style='width:60px;'><span data-i18n="sunrise.mins"></span>
|
|
|
|
</div>
|
|
|
|
<div class="form-row">
|
|
|
|
<label for="node-input-name"><i class="fa fa-tag"></i><span data-i18n="sunrise.label.name"></span></label>
|
|
|
|
<input type="text" id="node-input-name" data-i18n="[placeholder]sunrise.label.name">
|
|
|
|
</div>
|
2013-10-19 15:31:42 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
RED.nodes.registerType('sunrise',{
|
2019-10-20 23:43:32 +02:00
|
|
|
category: 'time',
|
2013-10-19 15:31:42 +02:00
|
|
|
color:"#ffcc66",
|
|
|
|
defaults: {
|
|
|
|
name: {value:""},
|
|
|
|
lat: {value:"", required:true, validate:RED.validators.number()},
|
|
|
|
lon: {value:"", required:true, validate:RED.validators.number()},
|
2014-09-07 22:56:49 +02:00
|
|
|
start: {value:"sunrise", required:true},
|
2020-04-18 14:55:57 +02:00
|
|
|
end: {value:"sunset", required:true},
|
|
|
|
soff: {value:0, validate:RED.validators.number()},
|
|
|
|
eoff: {value:0, validate:RED.validators.number()},
|
2013-10-19 15:31:42 +02:00
|
|
|
},
|
|
|
|
inputs:0,
|
|
|
|
outputs:2,
|
2023-03-21 11:20:23 +01:00
|
|
|
outputLabels: function(i) {
|
|
|
|
return [
|
|
|
|
this._("sunrise.onePerMin"),
|
|
|
|
this._("sunrise.onse")
|
|
|
|
][i];
|
|
|
|
},
|
2013-10-19 15:31:42 +02:00
|
|
|
icon: "sun.png",
|
|
|
|
label: function() {
|
2023-03-21 11:20:23 +01:00
|
|
|
return this.name||this._("sunrise.sunName");
|
2013-10-19 15:31:42 +02:00
|
|
|
},
|
|
|
|
labelStyle: function() {
|
|
|
|
return this.name?"node_label_italic":"";
|
2014-09-07 22:56:49 +02:00
|
|
|
},
|
|
|
|
oneditprepare: function() {
|
|
|
|
if (($("#node-input-lat").val() === "") && ($("#node-input-lon").val() === "")) {
|
|
|
|
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)));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2020-04-18 14:55:57 +02:00
|
|
|
if ($("#node-input-soff").val() === "") { $("#node-input-soff").val(0) }
|
|
|
|
if ($("#node-input-eoff").val() === "") { $("#node-input-eoff").val(0) }
|
|
|
|
$("#node-input-soff").spinner({});
|
|
|
|
$("#node-input-eoff").spinner({});
|
2013-10-19 15:31:42 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|