Public
Edited
Jan 2, 2024
Insert cell
Insert cell
MoonCalc = require('https://cdn.jsdelivr.net/npm/mooncalc@1.0.7/mooncalc.min.js')
Insert cell
moonData = {
var date = new Date();
var moonData = MoonCalc.datasForDay(date);
return moonData
}
Insert cell
mp = await import('https://cdn.jsdelivr.net/npm/moon-phase-widget@1.5.1/+esm')
Insert cell
geoData = (new mp.MoonPhaseWidget()).getGeoDataFn()
Insert cell
getMoonPhaseData = async(latitude, longitude) => {
const apiUrl = 'https://moonorganizer.com/api/public/moon-phase'

let currentDate = new Date();

// Subtract Timezone Offset hours
currentDate.setHours(currentDate.getHours() - currentDate.getTimezoneOffset()/60 + future);

const res = await fetch(apiUrl, {
method: 'POST',
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: JSON.stringify({latitude, longitude, date: currentDate})
});

const moonPhaseData = await res.json();

return moonPhaseData;
}
Insert cell
viewof future = Inputs.range([0, 24], {step: 1, value: 0})
Insert cell
html`<img src=${moonDataLocal.phaseIco} style='width:5rem'/>`
Insert cell
moonDataLocal = {
let moonPhaseData = await getMoonPhaseData(geoData.latitude, geoData.longitude)

//moonPhaseData.rise
//moonPhaseData.set

return moonPhaseData

}

Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more