Use wasm ephemeris locally and document Caddy serving
This commit is contained in:
parent
dbe9758b7c
commit
ba47f6dae4
7 changed files with 3876 additions and 25 deletions
|
|
@ -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();
|
||||
|
|
|
|||
3841
js/pmom.js
Normal file
3841
js/pmom.js
Normal file
File diff suppressed because it is too large
Load diff
BIN
js/pmom.wasm
Executable file
BIN
js/pmom.wasm
Executable file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue