-
Notifications
You must be signed in to change notification settings - Fork 592
/
79-suncalc.html
93 lines (91 loc) · 4.77 KB
/
79-suncalc.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<script type="text/html" data-template-name="sunrise">
<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>
<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-sendAtStartup"><i class="fa fa-refresh"></i><span data-i18n="sunrise.label.startup"></span></label>
<input type="checkbox" id="node-input-sendAtStartup" style='width:auto ;border:none; vertical-align:baseline;'>
<span for="node-input-sendAtStartup" data-i18n="sunrise.sendAtStartup"></span>
</div>
</script>
<script type="text/javascript">
RED.nodes.registerType('sunrise',{
category: 'time',
color:"#ffcc66",
defaults: {
name: {value:""},
lat: {value:"", required:true, validate:RED.validators.number()},
lon: {value:"", required:true, validate:RED.validators.number()},
start: {value:"sunrise", required:true},
end: {value:"sunset", required:true},
soff: {value:0, validate:RED.validators.number()},
eoff: {value:0, validate:RED.validators.number()},
sendAtStartup: {value:false}
},
inputs:0,
outputs:2,
outputLabels: function(i) {
return [
this._("sunrise.onePerMin"),
this._("sunrise.onse")
][i];
},
icon: "sun.png",
label: function() {
return this.name||this._("sunrise.sunName");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
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)));
});
}
}
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({});
}
});
</script>