Bonjour,
J’ai eu besoin (ou envie) de créer des boutons en HTML afin de pouvoir en changer la couleurs.
Et javais remarqué que sur mon smartphone les « boutons d’origines » étaient un peu gros…
Et l’envie de piloter 2, 3 truc avec ma montre
Bref… je met à dispo ce Widget HTML.
Bonne journée.
<iframe width=100% height=100% allowtransparency="true" scrolling=no frameBorder="0" srcdoc='
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>wam</title>
</head>
<style>
.styled {
border: 0;
height: 65px; /* Hauteur Bouton */
width: 90px; /* Largeur Bouton */
font-size: 15px; /* Taille Texte */
text-align: center; /* Centrage Texte Bouton */
color: #fff; /* Couleur Texte Bouton */
text-shadow: 1px 1px 1px #000; /* Ombre Texte Bouton */
border-radius: 10px; /* Arrondi Bouton */
background-color: rgba(220, 0, 0, 1); /* Couleur Bouton */
box-shadow: inset 2px 2px 3px rgba(255, 255, 255, .6), /* Couleur 3D Bouton */
inset -2px -2px 3px rgba(0, 0, 0, .6); /* Couleur 3D Bouton */
}
.styled:hover {
background-color: rgba(255, 0, 0, 1); /* Couleur Bouton Over */
}
.styled:active {
box-shadow: inset -2px -2px 3px rgba(255, 255, 255, .6), /* Couleur Bouton Clic */
inset 2px 2px 3px rgba(0, 0, 0, .6); /* Couleur Bouton 3D Clic */
}
.centre {
display: flex;
align-items: center;
justify-content: center
}
</style>
<body>
<div class="centre">
<input type="button" class="styled" value="no return" id="btn1" />
  
<input type="button" class="styled" value="no return" id="btn2" />
</div>
<div class="centre">
 
</div>
<div class="centre">
<input type="button" class="styled" value="no return" id="btn3" />
  
<input type="button" class="styled" value="no return" id="btn4" />
</div>
</body>
<script>
let MyHttp = ""; /* Adresse IP IPX800 */
let MyPort = ""; /* Port IPX800 */
let MyApi = ""; /* API IPX800 */
let MyIDButton1 = ""; /* ID Bouton 1 */
let NameButton1 = ""; /* Nom Bouton 1 */
let MyIDButton2 = ""; /* ID Bouton 2 */
let NameButton2 = ""; /* Nom Bouton 2 */
let MyIDButton3 = ""; /* ID Bouton 3 */
let NameButton3 = ""; /* Nom Bouton 3 */
let MyIDButton4 = ""; /* ID Bouton 4 */
let NameButton4 = ""; /* Nom Bouton 4 */
let MyUrl1, MyUrl2, MyUrl3, MyUrl4;
d = {true:NameButton1+"\nOn", false:NameButton1+"\nOff"}
/* BOUTON 1*/
MyUrl1= MyHttp + ":";
MyUrl1+= MyPort + "/api/core/io/";
MyUrl1+= MyIDButton1 + "?ApiKey=";
MyUrl1+= MyApi;
setInterval(function() {
fetch(MyUrl1, {method: "GET"})
.then(reponseA => reponseA.json())
.then(reponseA2 => btn1.value = d[(reponseA2.on)])
}, 800) /*temps pour rafraichissement en cas de manipulation exterieure*/
btn1.onclick = () => {
fetch(MyUrl1, {method:"PUT", body:JSON.stringify({"toggle":true})}) /* Envoi du PUT */
setTimeout(function() {
fetch(MyUrl1, {method: "GET"})
.then(reponseA => reponseA.json())
.then(reponseA2 => btn1.value = d[(reponseA2.on)])
}, 200) /*temps après clic pour rafraichissement*/
}
/* BOUTON 2*/
d2 = {true:NameButton2+"\nOn", false:NameButton2+"\nOff"}
MyUrl2= MyHttp + ":";
MyUrl2+= MyPort + "/api/core/io/";
MyUrl2+= MyIDButton2 + "?ApiKey=";
MyUrl2+= MyApi;
setInterval(function() {
fetch(MyUrl2, {method: "GET"})
.then(reponseB => reponseB.json())
.then(reponseB2 => btn2.value = d2[(reponseB2.on)])
}, 800) /*temps pour rafraichissement en cas de manipulation exterieure*/
btn2.onclick = () => {
fetch(MyUrl2, {method:"PUT", body:JSON.stringify({"toggle":true})}) /* Envoi du PUT */
setTimeout(function() {
fetch(MyUrl2, {method: "GET"})
.then(reponseB => reponseB.json())
.then(reponseB2 => btn2.value = d2[(reponseB2.on)])
}, 200) /*temps après clic pour rafraichissement*/
}
/* BOUTON 3*/
d3 = {true:NameButton3+"\nOn", false:NameButton3+"\nOff"}
MyUrl3= MyHttp + ":";
MyUrl3+= MyPort + "/api/core/io/";
MyUrl3+= MyIDButton3 + "?ApiKey=";
MyUrl3+= MyApi;
setInterval(function() {
fetch(MyUrl3, {method: "GET"})
.then(reponseC => reponseC.json())
.then(reponseC2 => btn3.value = d3[(reponseC2.on)])
}, 800) /*temps pour rafraichissement en cas de manipulation exterieure*/
btn3.onclick = () => {
fetch(MyUrl3, {method:"PUT", body:JSON.stringify({"toggle":true})}) /* Envoi du PUT */
setTimeout(function() {
fetch(MyUrl3, {method: "GET"})
.then(reponseC => reponseC.json())
.then(reponseC2 => btn3.value = d3[(reponseC2.on)])
}, 200) /*temps après clic pour rafraichissement*/
}
/* BOUTON 4*/
d4 = {true:NameButton4+"\nOn", false:NameButton4+"\nOff"}
MyUrl4= MyHttp + ":";
MyUrl4+= MyPort + "/api/core/io/";
MyUrl4+= MyIDButton4 + "?ApiKey=";
MyUrl4+= MyApi;
setInterval(function() {
fetch(MyUrl4, {method: "GET"})
.then(reponseD => reponseD.json())
.then(reponseD2 => btn4.value = d4[(reponseD2.on)])
}, 800) /*temps pour rafraichissement en cas de manipulation exterieure*/
btn4.onclick = () => {
fetch(MyUrl4, {method:"PUT", body:JSON.stringify({"toggle":true})}) /* Envoi du PUT */
setTimeout(function() {
fetch(MyUrl4, {method: "GET"})
.then(reponseD => reponseD.json())
.then(reponseD2 => btn4.value = d4[(reponseD2.on)])
}, 200) /*temps après clic pour rafraichissement*/
}
</script>
'></iframe>
Il faut juste renseigner les valeurs de la ligne 58 à 68