Monitor - page météo - phases lunaire
Publié : 27 mars 2017, 16:17
Bonjour,
J'ai réinstallé mon Pi avec la dernière version de Domoticz/Monitor
Dans la version précédente, j'avais l'affichage suivant :

Depuis la nouvelle version, je n'arrive plus à afficher la phase lunaire
J'ai procédé comme suit :
- j'ai ajouté le script suivant à la fin de meteo.html
-dans météo.css j'ai ajouté #moon à #meteo3, #meteo25
- dans météo.css j'ai également ajouté
- dans météo.html j'ai modifié la ligne suivante :
Mais rien ne s'affiche...
Un petit coup de pouce ?
Merci.

J'ai réinstallé mon Pi avec la dernière version de Domoticz/Monitor
Dans la version précédente, j'avais l'affichage suivant :
Depuis la nouvelle version, je n'arrive plus à afficher la phase lunaire
J'ai procédé comme suit :
- j'ai ajouté le script suivant à la fin de meteo.html
Code : Tout sélectionner
<script type="text/javascript" language="javascript">
//============= phases lunaire ========================
//source https://forums.coronalabs.com/topic/54547-source-for-moon-cycles-phases/
function julianDate(d, m, y) {
var yy = y - Math.floor((12 - m) / 10);
var mm = m + 9;
if (mm >= 12) {
mm = mm - 12
}
var k1 = Math.floor(365.25 * (yy + 4712));
var k2 = Math.floor(30.6001 * mm + 0.5);
var k3 = Math.floor(Math.floor((yy / 100) + 49) * 0.75) - 38;
var j = k1 + k2 + d + 59;
if (j > 2299160) {
j = j - k3
// console.log( " Julian Date : " + j )
}
return j
}
function moonAge(d, m, y){
var j = julianDate(d, m, y);
var ip = (j + 4.867) / 29.53059;
ip = ip - Math.floor(ip);
if (ip < 0.5) {
var ag = ip * 29.53059 + 29.53059 / 2;
} else {
var ag = ip * 29.53059 - 29.53059 / 2;
}
console.log( " moonAge : " + ag ) // +1
//return Math.round(ag) +1
return ag //+1
}
console.log( " Day : " + day )
var theMoon = moonAge(day, mois, annee)
/*if ( 1 < theMoon && theMoon >= 29) {
theMoon = 0
} else {
theMoon = theMoon -1
}*/
console.log( "Phase Lunaire : " + theMoon )
if (theMoon >= 29) {
moonText = "Nouvelle Lune";
moonPNG = "moon0.png";
} else if (theMoon < 29 && theMoon > 23) {
moonText = "Dernier croissant";
moonPNG = "moon7.png";
} else if (theMoon < 23 && theMoon > 22) {
moonText = "Dernier quartier";
moonPNG = "moon6.png";
} else if (theMoon < 22 && theMoon > 15) {
moonText = "Gibbeuse décroissante";
moonPNG = "moon5.png";
} else if (theMoon < 15 && theMoon > 13) {
moonText = "Pleine lune";
moonPNG = "moon4.png";
} else if (theMoon < 13 && theMoon > 8) {
moonText = "Gibbeuse croissante";
moonPNG = "moon3.png";
} else if (theMoon < 8 && theMoon > 6) {
moonText = "Premier Quartier";
moonPNG = "moon2.png";
} else if (theMoon < 6 && theMoon > 1) {
moonText = "Premier croissant";
moonPNG = "moon1.png";
} else {
moonText = "Nouvelle Lune";
moonPNG = "moon0.png";
/*if theMoon >= 29 then
moonText.text = "New Moon"
elseif theMoon < 29 and theMoon > 23 then
moonText.text = "Waning Crescent"
elseif theMoon < 23 and theMoon > 22 then
moonText.text = "Last Quarter"
elseif theMoon < 22 and theMoon > 15 then
moonText.text = "Waning gibbous"
elseif theMoon < 15 and theMoon > 13 then
moonText.text = "Full Moon"
elseif theMoon < 13 and theMoon > 8 then
moonText.text = "Waxing gibbous"
elseif theMoon < 8 and theMoon > 6 then
moonText.text = "First Moon"
elseif theMoon < 6 and theMoon > 1 then
moonText.text = "Waxing crescent"
else
moonText.text = "New Moon"
end */
}
$( "#moontxt").append( moonText );
$( "#moon").append("<img src=\"./icons/meteo/" + moonPNG + "\" alt=\"\" />");
</script>Code : Tout sélectionner
#meteo3, #meteo25, #moonCode : Tout sélectionner
#moontxt
{
font-family: arimo;
font-weight: normal;
color: #F2DDB3;
font-size: 14px;
margin-top: -20px;
height: 25px;
line-height: 15px;
text-shadow: 1px 1px 4px black;
}
Code : Tout sélectionner
<!--<div id="ls_meteo25"></div><div id="meteo25">--</div><div id="desc_meteo25">meteo25</div> -->
<div id="ls_meteo25"></div><div id="moon"></div><div id="moontxt"></div>Mais rien ne s'affiche...
Un petit coup de pouce ?
Merci.