-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsmartpi-modules-digital-out.html
More file actions
172 lines (157 loc) · 5.18 KB
/
smartpi-modules-digital-out.html
File metadata and controls
172 lines (157 loc) · 5.18 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<script type="text/javascript">
RED.nodes.registerType('smartpi-e.digital-out', {
category: 'SmartPi',
color: '#a6bbcf',
defaults: {
name: {
value: 'smartpi-e.digital-out',
},
bits: {
value: [false, false, false],
},
indicator: {
value: '',
},
server: {
value: 'http://127.0.0.1:1080',
},
token: {
value:
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJlbmVyc2VydmUiLCJyb2xlIjpbInNtYXJ0cGkiLCJhZG0iLCJkaWFsb3V0IiwiY2Ryb20iLCJzdWRvIiwiYXVkaW8iLCJ2aWRlbyIsInBsdWdkZXYiLCJnYW1lcyIsInVzZXJzIiwiaW5wdXQiLCJyZW5kZXIiLCJuZXRkZXYiLCJzcGkiLCJpMmMiLCJncGlvIiwic21hcnRwaWFkbWluIiwic21hcnRwaXVzZXJzIl0sInVzZXJuYW1lIjoic21hcnRwaSJ9.ilRjtk-_p1-meNlNutQDSDacW1AOpZFhB9DVfQ4V2lQ',
},
output: {
value: 1,
},
readonly: {
value: false,
},
},
oneditsave: Save,
oneditprepare: Restore,
inputs: 1,
outputs: 1,
icon: 'arrow-in.png',
label: function () {
return (
this.name + ' ' + this.indicator ||
'smartpi-e.digital-out ' + this.indicator
);
},
});
function Save() {
const NumCheckBoxes = 3;
this.bits = [];
for (let i = 0; i < NumCheckBoxes; i++) {
this.bits.push($(`#digitaloutA${i}`).is(':checked'));
}
}
function Restore() {
for (let i = 0; i < this.bits.length; i++) {
$(`#digitaloutA${i}`).prop('checked', this.bits[i]);
}
}
</script>
<script type="text/x-red" data-template-name="smartpi-e.digital-out">
<style>
.labelleft {
float: left;
width: 150px !important;
}
.customswitch {
position: relative;
display: inline-block;
width: 23px !important;
height: 40px;
}
.customswitch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 17px;
width: 17px;
left: 3px;
bottom: 3px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked+.slider {
background-color: #2196F3;
}
input:focus+.slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked+.slider:before {
-webkit-transform: translateY(-17px);
-ms-transform: translateY(-17px);
transform: translateY(-17px);
}
/* Rounded sliders */
.slider.round {
border-radius: 23px;
}
.slider.round:before {
border-radius: 50%;
}
</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="name">
</div>
<div class="form-row">
<label for="digitaloutA0" class="labelleft"><i class="fa fa-microchip"></i> Jumpersettings / </br> Deviceaddress</label>
<span>
<label class="customswitch">
<input type="checkbox" id="digitaloutA0">
<span class="slider round"></span>
</label>
<label class="customswitch">
<input type="checkbox" id="digitaloutA1">
<span class="slider round"></span>
</label>
<label class="customswitch">
<input type="checkbox" id="digitaloutA2">
<span class="slider round"></span>
</label>
</span>
</div>
<div class="form-row">
<label for="node-input-output"><i class="fa fa-sign-out"></i> Output:</label>
<select id="node-input-output" style="width: 250px;">
<option selected="selected" value="1">Output1</option>
<option selected="selected" value="2">Output2</option>
<option selected="selected" value="3">Output3</option>
<option selected="selected" value="4">Output4</option>
</select>
</div>
<div class="form-row">
<label for="node-input-server"><i class="fa fa-globe"></i> Server:port</label>
<input type="text" id="node-input-server" placeholder="http://127.0.0.1:1080">
</div>
<div class="form-row">
<label for="node-input-token"> <i class="fa fa-lock"></i> Baerer-Token<span id="node-span-token" style="display:none"></span></label>
<input type="password" id="node-input-token">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-readonly" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-readonly" style="width: 70%;"> <i class="fa fa-book"></i> Readonly (Outputs will not set)</label>
</div>
</script>
<script type="text/x-red" data-help-name="smartpi-e.digital-out">
<p>Output module</p>
</script>