Use wasm ephemeris locally and document Caddy serving

This commit is contained in:
randogoth 2025-12-22 15:00:43 +02:00
parent dbe9758b7c
commit ba47f6dae4
7 changed files with 3876 additions and 25 deletions

View file

@ -158,26 +158,19 @@ SL.Calendar = (function() {
var files = document.getElementById('fileInput').files;
// check if JSON file is loaded. If not, calculate...
if (files.length <= 0) {
// checks if usecase is offline, then uses WebAssembly
if ( $("body").attr("use") != "online" ) {
var astrologer = new Worker('js/sweph.js');
astrologer.postMessage([days, ts, lat, lon]);
astrologer.onmessage = function(response) {
Hours.moments = response.data;
maker();
}
// checks if usecase is online, then uses server based calculation
} else {
var url = "https://almanac.sublunar.space/pmom.php?days="+days+"&ts="+ts+"&lat="+lat+"&lon="+lon;
fetch(url)
.then(function(response) {
return response.json();
})
.then(function(json) {
Hours.moments = json.query;
maker();
});
}
// always use the local WASM worker (no PHP backend needed)
var astrologer = new Worker('js/sweph.js');
astrologer.postMessage([days, ts, lat, lon]);
astrologer.onmessage = function(response) {
Hours.moments = response.data;
maker();
};
astrologer.onerror = function(err) {
NProgress.done();
$('#settings').modal('show');
alert("Ephemeris calculation failed. Please ensure pmom.js/pmom.wasm are available.\n\n" + err.message);
console.error(err);
};
} else {
// display calendar data from JSON file
var fr = new FileReader();