-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcmd.action.other.nooGlowingButton.html
239 lines (209 loc) · 9.33 KB
/
cmd.action.other.nooGlowingButton.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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<div id="glowingContainer#id#">
<!-- ################ nooGlowingButton ################
********** Paramètres Optionnels ***************
logo : logo au format fontawesome ('fa fa-home' si non renseigné)
colorButtonOn : couleur du bouton en mode On ('rgba(0, 176, 255, 1)' si non renseigné)
colorButtonOff : couleur du bouton en mode Off ('#222' si non renseigné)
colorLogo : couleur du logo fixe (couleurs du bouton On/Off si non renseigné)
time : affichage des informations de temps depuis le dernier allumage/extinction,
valeurs possibles :
- duree': affiche la durée depuis le dernier allumage/extinction, '
- heure': affiche l'heure de dernier allumage extinction,
- 'date': affiche la date et l'heure de dernier allumage/extinction)
colorTime : couleur du texte des infos de temps
colorBackgroundTime : couleur de fond des infos de temps
showLogo : rend visible/invisible le logo (1 par défaut, valeurs possibles : 0 logo invisible, 1 logo visible)
Pensez au café pour les nuits blanches de codage ;)
https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=noodom.fr%40gmail.com¤cy_code=EUR&source=url
########### by @noodom ;) ############# -->
<!--
nooGlowingButton : widget for Jeedom
Copyright (C) 2023 @noodom
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-->
<template>
<div>logo : logo au format fontawesome ('fa fa-home' si non renseigné)</div>
<div>showLogo : rend visible/invisible le logo (1 par défaut, valeurs possibles : 0 logo invisible, 1 logo visible)</div>
<div>colorButtonOn : couleur du bouton en mode On ('rgba(0, 176, 255, 1)' si non renseigné)</div>
<div>colorButtonOff : couleur du bouton en mode Off ('#222' si non renseigné)</div>
<div>colorLogo : couleur du logo fixe (couleurs du bouton On/Off si non renseigné)</div>
<div>time : affichage des informations de temps depuis le dernier allumage/extinction (valeurs possibles : 'duree', 'heure', 'date')</div>
<div>colorTime : couleur du texte des infos de temps</div>
<div>colorBackgroundTime : couleur de fond des infos de temps</div>
</template>
<div class="glowingButton#id#">
<label class="glowingLabel#id#">
<input type="checkbox" id="glowingInput#id#" class="glowingInput#id#" class="toggle cursor cmd tooltips cmd-widget"
data-type="action" data-subtype="other" data-cmd_id="#id#" data-cmd_uid="#uid#">
<!-- <input type="checkbox" checked name=""> -->
<i id="mylogo#id#" aria-hidden="true"></i>
<span class="check"></span>
<span class="timeCmd label label-default" data-type="info"></span>
</label>
</div>
</div>
<script type="text/javascript">
var cmd#id# = $('.glowingLabel#id#');
// Chargement des paramètres optionnels
// choix du logo et du bouton (font-awesome)
var logo#id# = ('#logo#' != '#' + 'logo#') ? "#logo#" : 'fa fa-home';
// couleurs On/Off du bouton
var colorButtonOn#id# = ('#colorButtonOn#' != '#' + 'colorButtonOn#') ? "#colorButtonOn#" : 'rgba(0, 176, 255, 1)';
var colorButtonOff#id# = ('#colorButtonOff#' != '#' + 'colorButtonOff#') ? "#colorButtonOff#" : '#222';
// couleurs On/Off du logo
var colorLogoOn#id# = ('#colorLogo#' != '#' + 'colorLogo#') ? "#colorLogo#" : colorButtonOn#id#;
var colorLogoOff#id# = ('#colorLogo#' != '#' + 'colorLogo#') ? "#colorLogo#" : colorButtonOff#id#;
// couleurs time
var colorTime#id# = ('#colorTime#' != '#' + 'colorTime#') ? "#colorTime#" : '';
var colorBackgroundTime#id# = ('#colorBackgroundTime#' != '#' + 'colorBackgroundTime#') ? "#colorBackgroundTime#" : '';
// Logo
var showLogo#id# = (isNaN(parseFloat('#showLogo#'))) ? true : (parseFloat('#showLogo#') == 1);
document.documentElement.style.setProperty('--color-button-on#id#', colorButtonOn#id#);
document.documentElement.style.setProperty('--color-button-off#id#', colorButtonOff#id#);
document.documentElement.style.setProperty('--color-logo-on#id#', colorLogoOn#id#);
document.documentElement.style.setProperty('--color-logo-off#id#', colorLogoOff#id#);
if (colorTime#id# != '') {
cmd#id#.find('.timeCmd').css('color', colorTime#id#);
}
if (colorBackgroundTime#id# != '') {
cmd#id#.find('.timeCmd').css('background-color', colorBackgroundTime#id#);
}
jeedom.cmd.update['#id#'] = function(_options){
$('#mylogo#id#').addClass(logo#id#);
if (!showLogo#id#) {
$('#mylogo#id#').hide();
}
if (_options.display_value == '1' || _options.display_value == 1 || _options.display_value == '99' || _options.display_value == 99 || _options.display_value == 'on') {
document.getElementById('glowingInput#id#').checked = true;
if (jeedom.cmd.normalizeName('#name#') == 'on') {
$('.cmd[data-cmd_uid=#uid#]').hide();
}else{
$('.cmd[data-cmd_uid=#uid#]').show();
}
} else {
document.getElementById('glowingInput#id#').checked = false;
if (jeedom.cmd.normalizeName('#name#') == 'off') {
$('.cmd[data-cmd_uid=#uid#]').hide();
}else{
$('.cmd[data-cmd_uid=#uid#]').show();
}
}
if ('#time#' == 'duree') {
jeedom.cmd.displayDuration(_options.valueDate,cmd#id#.find('.timeCmd'));
}
else if ('#time#' == 'date') {
var week = ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'];
var date = new Date(_options.valueDate.replace(' ', 'T'));
var t = _options.valueDate.split(/[- :]/);
var format = week[date.getDay()]+" "+t[2]+"/"+t[1];
var time = "à "+t[3]+":"+t[4];
cmd#id#.find('.timeCmd').html(format+'<br>'+time);
}
else if ('#time#' == 'heure') {
var date = new Date(_options.valueDate.replace(' ', 'T'));
var t = _options.valueDate.split(/[- :]/);
var time = "à "+t[3]+":"+t[4]+":"+t[5];
cmd#id#.find('.timeCmd').html(time);
}
}
jeedom.cmd.update['#id#']({display_value:'#state#',valueDate:'#valueDate#',collectDate:'#collectDate#',alertLevel:'#alertLevel#'});
$('#glowingInput#id#').off().on('click', function () {
jeedom.cmd.execute({id: '#id#'});
});
//# sourceURL=nooGlowingButton.js
</script>
<style>
:root {
--color-button-on#id# : rgba(0, 176, 255, 1);
--color-button-off#id# : #222;
--color-logo-on#id# : rgba(0, 176, 255, 1);
--color-logo-off#id# : #222;
}
#glowingContainer#id# {
margin: 0;
padding: 0;
display: flex;
list-style: none;
}
#glowingContainer#id# .glowingButton#id# {
width: 100px;
text-align: center;
}
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .fa,
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .glowingInput#id#[type="checkbox"] {
display: block;
text-align: center;
}
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .fa {
font-size: 30px;
color: var(--color-logo-off#id#);
transition: 0.5s;
}
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .glowingInput#id#[type="checkbox"] {
display: none;
}
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .check {
position: relative;
display: block;
width: 50px;
height: 50px;
background: linear-gradient(#000, #333);
border-radius: 50%;
margin: 10px auto 0;
display: flex;
justify-content: center;
align-items: center;
}
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .check::before {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--color-button-off#id#);
transition: 0.5s;
z-index: 3;
}
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .check::after {
content: "";
position: absolute;
top: 6px;
left: 6px;
right: 6px;
bottom: 6px;
background-color: #222;
border-radius: 50%;
z-index: 2;
border: 2px solid #161616;
}
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .glowingInput#id#[type="checkbox"]:checked ~ .check::before {
background-color: var(--color-button-on#id#);
box-shadow: 0 0 10px var(--color-button-on#id#),
0 0 15px var(--color-button-on#id#),
0 0 20px var(--color-button-on#id#),
0 0 25px var(--color-button-on#id#),
0 0 0 2px var(--color-button-on#id#);
}
#glowingContainer#id# .glowingButton#id# .glowingLabel#id# .glowingInput#id#[type="checkbox"]:checked ~ .fa {
color: var(--color-logo-on#id#);
}
.glowingLabel#id# .timeCmd {
width: 90px;
margin-top: 4px;
font-size: 12px;
font-weight: bold;
border-radius: 5px !important;
box-shadow: 0px 2px 2px 0px rgba(0, 0, 0, 1) inset,
0px 2px 2px 0px rgba(255, 255, 255, 0.5);
text-shadow: 1px 2px 8px #000;
}
</style>