Bonjour à tous,
j’ai récupéré un widget (script html), je ne sais vraiment plus où, qui fonctionne trés mal sur core v4.2.
1er bug: quand je clique sur l’icone, l’état de ma commande permute bien de « 0 » à « 1 », et vice versa,
mais l’animation de l’icone se mets en route qu’en actualisant avec « F5 ».
2eme bug: a chaque actualisation avec « F5 », l’animation redémarre du début.
D’avance merci à ceux qui résoudra mon problème, ou qui m’aideron à le résoudre, sachant que le code et moi…eh bien ça fait 2
Voici le code
<div id="garage#id#" style="width:180px;min-height:180px;" class="cmd tooltips cmd-widget cursor" data-type="action" data-subtype="other" data-cmd_id="#id#">
<center>
<span style="font-size : 3em;font-weight: bold;margin-top: -20px;" class="action" id="iconGarageCmd#id#"></span>
</center>
<script>
var animeGarageOpen;
var animeGarageClose;
var VitesseAnime = (parseFloat("#VitesseAnime#") >= 0) ? '#VitesseAnime#' : 1 ;
var cmdNom = '#name#'.toLowerCase();
if('#state#' == '1' || '#state#' == 1){
$('#iconGarageCmd#id#').append('<img src="data/customTemplates/dashboard/cmd.action.other.GARAGE/100.png" couleurImg="rouge" width="180" height="180"/>');
if (cmdNom.indexOf('on') == 0 || cmdNom.indexOf('marche') == 0 ) {
$('#garage#id#').hide();
}
if (cmdNom.indexOf('off') == 0 || cmdNom.indexOf('arret') == 0) {
VitesseAnime = parseFloat(VitesseAnime)*600;
animeGarageOpen = setInterval(animeGarage, VitesseAnime);
}
}
else if('#state#' == '0' || '#state#' == 0){
$('#iconGarageCmd#id#').append('<img src="data/customTemplates/dashboard/cmd.action.other.GARAGE/00.png" couleurImg2="blanc" width="180" height="180"/>');
if (cmdNom.indexOf('off') == 0 || cmdNom.indexOf('arret') == 0) {
$('#garage#id#').hide(); }
if (cmdNom.indexOf('on') == 0 || cmdNom.indexOf('marche') == 0) {
VitesseAnime = parseFloat(VitesseAnime)*600;
animeGarageClose = setInterval(animeGarage2, VitesseAnime);
}
}
$('#garage#id#').on('click', function(){
clearInterval(animeGarageOpen);
jeedom.cmd.execute({id: '#id#'});
});
$('#garage#id#').on('click', function(){
clearInterval(animeGarageClose);
jeedom.cmd.execute({id: '#id#'});
});
function animeGarage(){
var couleurImg = $('#iconGarageCmd#id# img').attr('couleurImg');
if(couleurImg == 'rouge'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/90.png',
'couleurImg': 'bleu'
});
}else if(couleurImg == 'bleu'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/80.png',
'couleurImg': 'magenta'
});
}else if(couleurImg == 'magenta'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/70.png',
'couleurImg': 'vert'
});
}else if(couleurImg == 'vert'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/60.png',
'couleurImg': 'jaune'
});
}else if(couleurImg == 'jaune'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/50.png',
'couleurImg': 'violet'
});
}else if(couleurImg == 'violet'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/40.png',
'couleurImg': 'orange'
});
}else if(couleurImg == 'orange'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/30.png',
'couleurImg': 'gris'
});
}else if(couleurImg == 'gris'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/20.png',
'couleurImg': 'rose'
});
}else if(couleurImg == 'rose'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/10.png',
'couleurImg': 'noir'
});
}else if(couleurImg == 'noir'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/00.png',
'couleurImg': 'blanc'
});
}else{
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/00.png',
'couleurImg': 'blanc'
});
}
}
function animeGarage2(){
var couleurImg2 = $('#iconGarageCmd#id# img').attr('couleurImg2');
if(couleurImg2 == 'blanc'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/10.png',
'couleurImg2': 'rose'
});
}else if(couleurImg2 == 'rose'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/20.png',
'couleurImg2': 'orange'
});
}else if(couleurImg2 == 'orange'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/30.png',
'couleurImg2': 'gris'
});
}else if(couleurImg2 == 'gris'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/40.png',
'couleurImg2': 'jaune'
});
}else if(couleurImg2 == 'jaune'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/50.png',
'couleurImg2': 'violet'
});
}else if(couleurImg2 == 'violet'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/60.png',
'couleurImg2': 'vert'
});
}else if(couleurImg2 == 'vert'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/70.png',
'couleurImg2': 'magenta'
});
}else if(couleurImg2 == 'magenta'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/80.png',
'couleurImg2': 'bleu'
});
}else if(couleurImg2 == 'bleu'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/90.png',
'couleurImg2': 'noir'
});
}else if(couleurImg2 == 'noir'){
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/100.png',
'couleurImg2': 'rouge'
});
}else{
$('#iconGarageCmd#id# img').attr({'src': 'data/customTemplates/dashboard/cmd.action.other.GARAGE/100.png',
'couleurImg2': 'rouge'
});
}
}
</script>
</div>
et les icones