- bugfixes

- offline modes
This commit is contained in:
Sublunar Space 2019-01-15 13:17:02 +01:00
parent ac264cc82d
commit c27a517746
6 changed files with 548 additions and 175 deletions

View file

@ -2,7 +2,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--
* SUBLUNAR ALMANAC v.1.1b "Yeshua"
* SUBLUNAR ALMANAC v.1.0.0 "Yeshua"
*-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
@ -41,6 +41,7 @@
<link rel="stylesheet" href="style.css" />
<script type="text/javascript" src="js/SL.Astro.js"></script>
<script type="text/javascript" src="js/SL.Calendar.js"></script>
<script type="text/javascript" src="js/SL.App.js"></script>
<!--
* load SUBLUNAR ALMANAC plugin modules
@ -92,7 +93,7 @@
<div id="calendar">
<div id="caption">
<center>
<h3 class="stoke">How does this work? <a href="http://sublunar.space/2018-12-sublunar-almanac.html#doc">Read!</a></h3>
<h3 class="stoke">How does this work? <a href="http://sublunar.space/2018-12-sublunar-almanac.html#doc" target="_blank">Read!</a></h3>
</center>
</div>
<div id="grid">
@ -117,11 +118,11 @@
</div>
<div class="modal-body">
<div class="row">
<div class="form-group col-md-6">
<div class="form-group col-md-6 autolocate">
<label for="offset">Automatic Geolocation</label><br />
<button id="locate" class="btn btn-default"><span class="glyphicon glyphicon-map-marker"></span> Locate Me</button>
</div>
<div class="form-group col-md-6">
<div class="form-group col-md-6 manuallocate">
<label for="lon">Manual Geolocation</label>
<input type="text" autocomplete="off" id="search" class="address form-control args" placeholder="City"/>
</div>
@ -240,6 +241,48 @@
</div>
</script>
<!--
* template for about modal
*-->
<script type="text/html" id="about-modal">
<center>
<p>
If you like this this project and want it to stay alive, please support the author by <a href="https://ko-fi.com/U7U4NQ0Q" target="_blank">buying some coffees</a>.<br />
For updates, feedback and discussions, please visit our <a href="" target="_blank">Facebook Group</a>.<br />
If you are interested in contributing, please check out our <a href="https://github.com/sublunarspace/sublunar.almanac" target="_blank">GitHub Repo</a>
</p>
<p>
<a href="https://opensource.org/licenses/MIT" target="_blank">MIT License</a> © 2018 T. F. Raaion / <a href="http://sublunar.space">sublunar space</a><br />
contact: <a href=\'mailto:&#105;&#110;&#102;&#111;&#64;&#115;&#117;&#98;&#108;&#117;&#110;&#97;&#114;&#46;&#115;&#112;&#97;&#99;&#101;\'>&#105;&#110;&#102;&#111;&#64;&#115;&#117;&#98;&#108;&#117;&#110;&#97;&#114;&#46;&#115;&#112;&#97;&#99;&#101;</a>
</p>
</center>
<hr />
<center id="3rdparty">
<p>
Astronomical calculations are based on<br />
<a href="http://www.astro.com/swisseph/swephinfo_e.htm" target="_blank">Swiss Ephemeris API</a>, © 1997-2016 Astrodienst AG, <a href="https://opensource.org/licenses/GPL-2.0" target="_blank">(GPLv2.0+)</a><br />
and the <a href="http://www.moshier.net/#Astronomy" target="_blank">Table of New Moon Dates</a> by Steve Moshier.
</p>
<p>
The front-end relies on the following Javascript Libraries:<br />
<a href="https://jquery.com/" target="_blank">jQuery 3.2.1</a>, © JS Foundation, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br />
<a href="https://getbootstrap.com/" target="_blank">Bootstrap 3.3.7</a>, © Twitter, Inc., <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br />
<a href="https://github.com/codepb/jquery-template/" target="_blank">jQuery.loadTemplate</a>, © 2013 Paul Burgess and other contributors, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br />
<a href="http://momentjs.com" target="_blank">MomentJS 2.18.1</a>, © Tim Wood, Iskren Chernev, Moment.js contributors, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br />
<a href="http://isotope.metafizzy.co" target="_blank">Isotope 3.0.4</a>, © 2017 Metafizzy, <a href="https://opensource.org/licenses/GPL-3.0" target="_blank">(GPLv3)</a><br />
<a href="http://defiantjs.com" target="_blank">DefiantJS 1.4.1</a>, © 2013-2017, Hakan Bilgin, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br />
<a href="http://ricostacruz.com/nprogress" target="_blank">NProgress</a>, © 2013, 2014 Rico Sta. Cruz, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br />
<a href="https://github.com/klokantech/javascript" target="_blank">OsmNamesAutocomplete</a>, © 2016 Klokan Technologies GmbH, <a href="https://opensource.org/licenses/GPL-3.0" target="_blank">(GPLv3)</a><br />
<a href="https://github.com/darkskyapp/tz-lookup" target="_blank">tzlookup</a>, by The Dark Sky, LLC, <a href="https://creativecommons.org/publicdomain/zero/1.0/" target="_blank">(CC0 1.0 Universal)</a><br />
<a href="https://github.com/nwcell/ics.js/" target="_blank">ics.js</a>, © 2018 Travis Krause, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a>
</p>
<p>
The design is based on<br />
<a href="http://bootswatch.com" target="_blank">bootswatch v3.3.7</a>, © 2012-2017 Thomas Park, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a>.
</p>
</center>
</script>
<!--
* main SUBLUNAR ALMANAC Javascript
*-->
@ -284,16 +327,20 @@
// get browser location when button "locate" is clicked
$("#locate").on("click", function() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var item = {
lat: position.coords.latitude,
lon: position.coords.longitude
}
SL.Calendar.getGeoCode(item);
});
if ( $("body").attr("use") == "offline" ) {
SL.App.geoLocate();
} else {
alert("Geolocation is not supported by this browser.");
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(position) {
var item = {
lat: position.coords.latitude,
lon: position.coords.longitude
}
SL.Calendar.getGeoCode(item);
});
} else {
alert("Geolocation is not supported by this browser.");
}
}
});
@ -312,7 +359,7 @@
});
// "About" modal
$('#about').on('click', SL.Calendar.about);
SL.Calendar.about();
// "Generate" button in Settings
$('#generate').on("click", function(e) {
@ -337,14 +384,14 @@
// "Reset" button in navbar menu bar
$('#filterreset').on('click', function() {
if ( $("body").attr("use") == "offline" ) {
if ( $("body").attr("use") == "offline" && document.getElementById("loadpreset") != null ) {
$("#grid").empty();
if ( $('#calendar').data('isotope') ) $('#calendar').isotope('destroy');
}
$('.actionlistfilter input').prop('checked', false);
$('.filteroptions input').prop('checked', false);
filters = {};
$('#calendar').isotope({ filter: '*' });
if ( $('#calendar').data('isotope') ) $('#calendar').isotope('destroy');
});
/*--
@ -403,6 +450,10 @@
});
});
if ( $("body").attr("use") == "offline" ) {
SL.App.authorize();
}
</script>
</body>
</html>

336
js/SL.App.js Normal file
View file

@ -0,0 +1,336 @@
/**
* @preserve Copyright (c) 2018 T. F. Raaion, www.sublunar.space
* License MIT: http://www.opensource.org/licenses/MIT
*
* SUBLUNAR ALMANAC
*/
var SL = SL || {};
/**
* Offline App Functions
*/
SL.App = (function() {
const fs = require('fs');
const path = require('path');
const http = require('http');
const AutoUpdater = require( "nw-autoupdater" );
const mid = require( "node-machine-id" );
const crypto = require('crypto');
const config = path.normalize(nw.App.dataPath+'/config.json');
var editJson = '';
var waiting = false;
function downloadStatus(file, response) {
var num = parseInt($(".stoke span").text());
$(".stoke span").html(++num);
if ( num == 4 ) {
waiting = false;
file.hasFiles = true;
writeHash(file, response);
}
}
function downloadPreset(file, url, filename, response) {
var p = path.normalize(nw.App.dataPath+"/presets/"+filename);
waiting = true;
http.get(url, function(r) {
r.pipe(fs.createWriteStream(p)).on('finish', function () {
downloadStatus(file, response);
});
});
}
function writeHash(file, response) {
if ( waiting == false) {
file.hash = response.hash;
fs.writeFile(config, JSON.stringify(file, null, 2), 'utf8', function(err) {
if(err) {
return console.log(err);
} else {
$('#caption .stoke').html('All set. Restarting application...');
console.log(file);
window.setTimeout(chrome.runtime.reload,2000);
}
});
} else {
console.log("still waiting for download...");
}
}
function authorize() {
$("#navigation").css({"visibility":"hidden"});
if (!fs.existsSync(config)){
fs.writeFile(config, JSON.stringify({"config" : "Sublunar Almanac"}), 'utf8', function(err) {
if(err) {
return console.log(err);
} else {
$('#caption .stoke').html('Created configuration file... Restarting application...');
window.setTimeout(chrome.runtime.reload,2000);
}
});
} else {
editJson = require(config);
let file = editJson;
if ( !file.hasOwnProperty("userEmail") ) {
if ( !navigator.onLine) {
$('#caption .stoke').html('You need to be online for activation...');
return;
}
var email = prompt("Please enter the email address you registered with");
file.userEmail = email;
/*
fs.writeFile(config, JSON.stringify(file, null, 2), 'utf8', function(err) {
if(err) {
return console.log(err);
}
});
*/
}
if ( !file.hasOwnProperty("hash") ) {
if ( !navigator.onLine) {
$('#caption .stoke').html('You need to be online for activation...');
return;
}
$.ajax({
url : "http://release.sublunar.space/index.php",
type: "POST",
data: {
email: file.userEmail,
mid: mid.machineIdSync({original: true})
},
success:function(response) {
console.log(response);
if ( response.status == "authorized") {
var dir = path.normalize(nw.App.dataPath+"/presets");
if (!fs.existsSync(dir)){
fs.mkdirSync(dir);
}
if ( response.hasOwnProperty("files") ) {
var url = "http://release.sublunar.space/presets/";
$('#caption .stoke').html('downloaded preset file <span>0</span> of 4');
downloadPreset(file, url+response.files.file1, "modals.html", response);
downloadPreset(file, url+response.files.file2, "filtermenu.html", response);
downloadPreset(file, url+response.files.file3, "grid.html", response);
downloadPreset(file, url+response.files.file4, "ephemeris.json", response);
} else {
writeHash(file, response);
}
} else {
$('#caption .stoke').html('Sorry, there is something wrong with your authorization. <a onClick="SL.App.reset()">Reset?</a>');
}
},
error:function(){
console.log("error");
}
});
} else {
const check = crypto.createHash('sha256');
check.update(mid.machineIdSync({original: true}));
if ( file.hash == check.digest('hex') ) {
$("#navigation").css({"visibility":"visible"});
if ( file.hasOwnProperty("hasFiles") && file.hasFiles == true )
$("#filterreset").closest('li').before('<li><p class="navbar-btn"><a id="loadpreset" class="btn btn-default" onClick="SL.App.loadPreset()" href="#"><span class="glyphicon glyphicon-open"></span> Load Preset</a></p></li>');
if ( !navigator.onLine ) {
offlineUse();
} else {
updateApp();
}
} else {
$('#caption .stoke').html('Sorry, there is something wrong with your authorization. <a onClick="SL.App.reset()">Reset?</a>');
}
}
}
}
function reset() {
file = require(config);
if ( file.hasOwnProperty("userEmail") ) delete file.userEmail;
if ( file.hasOwnProperty("hash") ) delete file.hash;
if ( file.hasOwnProperty("hasFiles") ) delete file.hasFiles;
var presetfiles = ['/presets/modals.html', '/presets/filtermenu.html', '/presets/grid.html', '/presets/ephemeris.json', '/config.json'];
presetfiles.forEach( function(fn) {
var p = path.normalize(nw.App.dataPath+fn);
fs.unlink(p, (err) => {
if (err) throw err;
console.log(p+' was deleted');
});
});
$('#caption .stoke').html('App has been reset. <a onClick="chrome.runtime.reload()">Reload?</a>');
fs.writeFile(config, JSON.stringify(file, null, 2), 'utf8', function(err) {
if(err) {
return console.log(err);
}
});
$('#aboutSLC').modal('hide');
}
function geoLocate() {
$.ajax({ type : 'POST', data: '', url: "https://www.googleapis.com/geolocation/v1/geolocate?key=AIzaSyA7DG6Kz0VawkYVONoq7Yk8igTAQFGxGN4", success: function(data){
var item = {
lat: data.location.lat,
lon: data.location.lng
}
SL.Calendar.getGeoCode(item);
}
});
}
/**
* loadPreset loads precalculated menubar, modals and hour grid
*/
function loadPreset() {
$('#caption .stoke').html('loading preset...please wait.');
fs.readFile(path.normalize(nw.App.dataPath+"/presets/filtermenu.html"), "utf8", function(err, html) {
if (err) throw err;
$("#filterList").empty();
$("#filterList").append(html);
});
fs.readFile(path.normalize(nw.App.dataPath+"/presets/modals.html"), "utf8", function(err, html) {
if (err) throw err;
$("#modals").empty();
$("#modals").append(html);
SL.Calendar.about();
});
fs.readFile(path.normalize(nw.App.dataPath+"/presets/grid.html"), "utf8", function(err, html) {
if (err) throw err;
$("#grid").empty();
$("#grid").append(html);
$('#caption .stoke').empty();
$('#moduleSelect input:checkbox').prop('checked', true);
$(".planetaryhour").each(function() {
if ( $(this).attr("ts") < (moment.utc().startOf("day").unix()) ) $(this).remove();
});
$('.planetaryhour').on('click', SL.Calendar.hourInfo);
});
fs.readFile(path.normalize(nw.App.dataPath+"/presets/ephemeris.json"), "utf8", function(err, data) {
if (err) throw err;
var json = JSON.parse(data);
SL.Calendar.load(json.query);
});
if ( $('#calendar').data('isotope') ) $('#calendar').isotope('destroy');
}
/**
* updateApp function updates the offline App
* from https://github.com/dsheiko/nw-autoupdater/blob/master/example/client-strategy-app/index.html
*/
async function updateApp() {
const updater = new AutoUpdater( require( "./package.json" ) ),
output = $("#caption .stoke");
try {
// Update copy is running to replace app with the update
if ( updater.isSwapRequest() ) {
output.html("Swapping...");
await updater.swap();
output.html("Done.");
await updater.restart();
return;
}
// Download/unpack update if any available
const rManifest = await updater.readRemoteManifest();
const needsUpdate = await updater.checkNewVersion( rManifest );
if ( !needsUpdate ) {
return;
}
if ( !confirm( "New release is available. Do you want to upgrade?" ) ) {
return;
}
// Subscribe for progress events
updater.on( "download", ( downloadSize, totalSize ) => {
output.html("Downloading "+Math.floor( downloadSize / totalSize * 100 )+"%" );
});
updater.on( "install", ( installFiles, totalFiles ) => {
output.html("Installing "+Math.floor( installFiles / totalFiles * 100 )+"%" );
});
reset();
const updateFile = await updater.download( rManifest );
await updater.unpack( updateFile );
alert( `The application will automatically restart to finish installing the update` );
await updater.restartToSwap();
} catch ( e ) {
console.error( e );
}
}
function offlineUse() {
$(".autolocate label").html("Save Coordinates");
$(".autolocate button").attr('id', 'savePlace').html("Save Place");
$(".manuallocate label").html("Last Searched & Saved Places");
$(".manuallocate input").remove();
$(".manuallocate").append("<br />");
$('<button/>').attr('type', 'button').attr('data-toggle', 'dropdown').attr('id', 'placeList').html('Place <span class="caret"></span>').addClass('btn btn-default dropdown-toggle').appendTo('.manuallocate');
$('<ul />').addClass('dropdown-menu placeSelect').appendTo('.manuallocate');
$('#savePlace').on('click', function() {
var placeName = prompt("Please enter a name for the place you want to save.");
if (placeName != "" ) savePlace(placeName);
});
getPlaces();
}
function savePlace(name) {
let file = editJson;
if ( !file.hasOwnProperty("place") ) file.place = {};
var placeData = {
lat : $("#lat").val(),
lon : $("#lon").val(),
offset : $("#offset").val(),
}
file.place[name] = placeData;
fs.writeFile(config, JSON.stringify(file, null, 2), 'utf8', function(err) {
if(err) return console.log(err);
});
}
function getPlace(name) {
let file = editJson;
$("#lat").val(file.place[name].lat);
$("#lon").val(file.place[name].lon);
$("#offset").val(file.place[name].offset);
}
function delPlace(name) {
console.log(name);
let file = editJson;
if ( file.place.hasOwnProperty(name) ) {
delete file.place[name];
}
console.log(file);
fs.writeFile(config, JSON.stringify(file, null, 2), 'utf8', function(err) {
if(err) return console.log(err);
getPlaces();
});
}
function getPlaces() {
let file = editJson;
$('.placeSelect').empty();
Object.keys(file.place).forEach(function(key) {
$('<li />').html('<a href="#">'+key+'</a>').appendTo('.placeSelect').on('click', function() {
getPlace(key);
$('#placeList').html( key+' <span class="caret"></span>' );
});
});
$('<span />').html(' &#10005;').appendTo('.placeSelect li a').on('click', function(e) {
e.stopPropagation();
var placeName = $(this).parent().text().slice(0, -2);
delPlace(placeName);
$(this).parent().remove();
});
}
return {
authorize : authorize,
geoLocate : geoLocate,
loadPreset : loadPreset,
updateApp : updateApp,
reset : reset,
place : {
get : getPlace,
set : savePlace
}
}
}());

View file

@ -19,6 +19,7 @@ var SL = SL || {};
* @public {function} reset() - simulates a resizing of the browser window. Needed hack for a display glitch in the modals.
* @public {function} resetFileInput() - resets the file selection button in Settings
* @public {function} download() - download a JSON object as a file
* @public {function} update() - updates the offline app
*/
SL.Calendar = (function() {
@ -28,7 +29,7 @@ SL.Calendar = (function() {
function about() {
$('<div/>').loadTemplate($("#tpl-modal"), {
title : '<center><h1 class="stoke">SUBLUNAR ALMANAC</h1></center>',
right : '<center><p>If you like this tool, please <a href="https://ko-fi.com/U7U4NQ0Q" target="_blank">Buy Me a Coffee</a>.<br />For updates, feedback and discussions, please visit our <a href="" target="_blank">Facebook Group</a>.<br />If you are interested in contributing, please check out our <a href="https://github.com/sublunarspace/sublunar.almanac" target="_blank">GitHub Repo</a></p><p><a href="https://opensource.org/licenses/MIT" target="_blank">MIT License</a> © 2018 T. F. Raaion / <a href="http://sublunar.space">sublunar space</a><br />contact: <a href=\'mailto:&#105;&#110;&#102;&#111;&#64;&#115;&#117;&#98;&#108;&#117;&#110;&#97;&#114;&#46;&#115;&#112;&#97;&#99;&#101;\'>&#105;&#110;&#102;&#111;&#64;&#115;&#117;&#98;&#108;&#117;&#110;&#97;&#114;&#46;&#115;&#112;&#97;&#99;&#101;</a></p></center><hr /><center><p>Astronomical calculations are based on <br /><a href="http://www.astro.com/swisseph/swephinfo_e.htm" target="_blank">Swiss Ephemeris API</a>, © 1997-2016 Astrodienst AG, <a href="https://opensource.org/licenses/GPL-2.0" target="_blank">(GPLv2.0+)</a><br />and the <a href="http://www.moshier.net/#Astronomy" target="_blank">Table of New Moon Dates</a> by Steve Moshier.</p><p>The front-end relies on the following Javascript Libraries:<br /><a href="https://jquery.com/" target="_blank">jQuery 3.2.1</a>, © JS Foundation, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="https://getbootstrap.com/" target="_blank">Bootstrap 3.3.7</a>, © Twitter, Inc., <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="https://github.com/codepb/jquery-template/" target="_blank">jQuery.loadTemplate</a>, © 2013 Paul Burgess and other contributors, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="http://momentjs.com" target="_blank">MomentJS 2.18.1</a>, © Tim Wood, Iskren Chernev, Moment.js contributors, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="http://isotope.metafizzy.co" target="_blank">Isotope 3.0.4</a>, © 2017 Metafizzy, <a href="https://opensource.org/licenses/GPL-3.0" target="_blank">(GPLv3)</a><br /><a href="http://defiantjs.com" target="_blank">DefiantJS 1.4.1</a>, © 2013-2017, Hakan Bilgin, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="http://ricostacruz.com/nprogress" target="_blank">NProgress</a>, © 2013, 2014 Rico Sta. Cruz, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="https://github.com/klokantech/javascript" target="_blank">OsmNamesAutocomplete</a>, © 2016 Klokan Technologies GmbH, <a href="https://opensource.org/licenses/GPL-3.0" target="_blank">(GPLv3)</a><br /><a href="https://github.com/darkskyapp/tz-lookup" target="_blank">tzlookup</a>, by The Dark Sky, LLC, <a href="https://creativecommons.org/publicdomain/zero/1.0/" target="_blank">(CC0 1.0 Universal)</a><br /><a href="https://github.com/nwcell/ics.js/" target="_blank">ics.js</a>, © 2018 Travis Krause, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a></p><p>The design is based on<br /><a href="http://bootswatch.com" target="_blank">bootswatch v3.3.7</a>, © 2012-2017 Thomas Park, <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a>.</center><script async defer src="https://buttons.github.io/buttons.js"></script>'
right : $("#about-modal").html()
})
.appendTo('#modals')
.attr('id', 'aboutSLC')
@ -38,34 +39,10 @@ SL.Calendar = (function() {
.find('.col-sm-4').closest('.row')
.find('.col-sm-8').attr('class', 'col-sm-12').closest('.row')
.find('.col-sm-4').remove();
}
/**
* loadPreset loads precalculated menubar, modals and hour grid
*/
function loadPreset() {
if ( $("body").attr("use") == "offline" ) {
$('#caption .stoke').html("loading preset...please wait.");
$.get("presets/filtermenu.html").done(function(html) {
$("#filterList").empty();
$("#filterList").append(html);
});
$.get("presets/modals.html").done(function(html) {
$("#modals").empty();
$("#modals").append(html);
});
$.get("presets/grid.html").done(function(html) {
$("#grid").empty();
$("#grid").append(html);
$('#caption .stoke').empty();
$('#moduleSelect input:checkbox').prop('checked', true);
$('.planetaryhour').on('click', SL.Calendar.hourInfo);
});
$.getJSON("presets/ephemeris.json", function(json) {
Hours.moments = json.query;
});
if ( $('#calendar').data('isotope') ) $('#calendar').isotope('destroy');
}
if ( $("body").attr("use") == "offline" ) {
$('<button/>').attr('role', 'button').attr('target', '_blank').attr('onClick', 'SL.App.reset();').html('Reset App').addClass('btn btn-default pull-left').prependTo('#aboutSLC .modal-footer');
$('#3rdparty').append('<p>The desktop application relies on<br /><a href="http://chromium.org" target="_blank">Google Chromium</a>, © 2015 The Chromium Authors <a href="https://chromium.googlesource.com/chromium/src/+/master/LICENSE" target="_blank">(BSD)</a><br /><a href="http://nwjs.io" target="_blank">node.js</a>, © Node.js Foundation, © Joyent, Inc. <a href="https://github.com/nodejs/node/blob/master/LICENSE" target="_blank">(C)</a><br /><a href="http://nwjs.io" target="_blank">NW.js</a>, © 2015-2019 NW.js community, Intel Corp, The Chromium Authors <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="https://github.com/kripken/emscripten" target="_blank">emscripten</a>, © 2010-2014 Emscripten authors <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="https://github.com/automation-stack/node-machine-id" target="_blank">node-machine-id</a>, © 2016 Aleksandr Komlev <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /><a href="https://github.com/dsheiko/nw-autoupdater" target="_blank">nw-autoupdater</a>, © 2018 Dmitry Sheiko <a href="https://opensource.org/licenses/MIT" target="_blank">(MIT)</a><br /></p>');
}
}
/**
@ -222,7 +199,14 @@ SL.Calendar = (function() {
}
}
function load(moments) {
Hours.moments = moments;
}
function maker() {
if ( $("body").attr("use") == "offline" ) {
SL.App.place.set($('#search').val());
}
if ( Hours.moments.length > 0 ) {
$('#caption .stoke').html('generating planetary hours...please wait');
for (var i = 0, len = Hours.moments.length; i < len; i++) {
@ -235,6 +219,7 @@ SL.Calendar = (function() {
return {
make: make,
moments : moments,
load : load
}
}());
@ -277,12 +262,14 @@ SL.Calendar = (function() {
$('#moment_'+j).addClass('night-hour');
}
if ( j == all-1 ) {
var fname = $('#search').val().split(' ').join('_')+'_'+new moment.unix(Hours.moments[0].ts).utc().format('DDMMMYYYY')+'-'+new moment.unix(Hours.moments[0].ts).utc().add($('#days').val(), 'days').format('DDMMMYYYY');
if ( $('#search').val() != '' && $('#fileInput').val() == '') {
$('<button/>').attr('role', 'button').attr('target', '_blank').attr('id', 'download').html('Download File').addClass('btn btn-default pull-left').prependTo('#settings .modal-footer');
$('#download').on('click', function() {
SL.Calendar.download(Hours.moments, fname);
});
if ( $("body").attr("use") == "online" ) {
var fname = $('#search').val().split(' ').join('_')+'_'+new moment.unix(Hours.moments[0].ts).utc().format('DDMMMYYYY')+'-'+new moment.unix(Hours.moments[0].ts).utc().add($('#days').val(), 'days').format('DDMMMYYYY');
if ( $('#search').val() != '' && $('#fileInput').val() == '') {
$('<button/>').attr('role', 'button').attr('target', '_blank').attr('id', 'download').html('Download File').addClass('btn btn-default pull-left').prependTo('#settings .modal-footer');
$('#download').on('click', function() {
SL.Calendar.download(Hours.moments, fname);
});
}
}
SL.Calendar.resetFileInput();
$('.planetaryhour').on('click', SL.Calendar.hourInfo);
@ -552,9 +539,6 @@ SL.Calendar = (function() {
extend(m, eval('module_'+m));
});
$('[data-toggle="tooltip"]').tooltip();
loadPreset();
if ( $("body").attr("use") == "offline" )
$("#filterreset").closest('li').before('<li><p class="navbar-btn"><a class="btn btn-default" id="preset" onClick="SL.Calendar.preset()" href="#"><span class="glyphicon glyphicon-open"></span> Load Preset</a></p></li>');
}
/**
@ -661,14 +645,14 @@ SL.Calendar = (function() {
about : about,
getGeoCode : getGeoCode,
reset : resetWindow,
preset : loadPreset,
modules : Module.load,
comboFilter : Filter.comboFilter,
hourInfo : Hour.info,
make : Hours.make,
moments : Hours.moments,
load : Hours.load,
resetFileInput : resetFileInput,
download : download,
download : download
}
}());

View file

@ -643,735 +643,735 @@ var module_aspects = {
[
{
"id": 1,
"action": "Moon Mercury",
"action": "Moon &#9740; Mercury",
"tags": "moon conjunction mercury"
}
],
[
{
"id": 2,
"action": "Moon Venus",
"action": "Moon &#9740; Venus",
"tags": "moon conjunction venus"
}
],
[
{
"id": 3,
"action": "Moon Sun",
"action": "Moon &#9740; Sun",
"tags": "moon conjunction sun"
}
],
[
{
"id": 4,
"action": "Moon Mars",
"action": "Moon &#9740; Mars",
"tags": "moon conjunction mars"
}
],
[
{
"id": 5,
"action": "Moon Jupiter",
"action": "Moon &#9740; Jupiter",
"tags": "moon conjunction jupiter"
}
],
[
{
"id": 6,
"action": "Moon Saturn",
"action": "Moon &#9740; Saturn",
"tags": "moon conjunction saturn"
}
],
[
{
"id": 7,
"action": "Mercury Venus",
"action": "Mercury &#9740; Venus",
"tags": "mercury conjunction venus"
}
],
[
{
"id": 8,
"action": "Mercury Sun",
"action": "Mercury &#9740; Sun",
"tags": "mercury conjunction sun"
}
],
[
{
"id": 9,
"action": "Mercury Mars",
"action": "Mercury &#9740; Mars",
"tags": "mercury conjunction mars"
}
],
[
{
"id": 10,
"action": "Mercury Jupiter",
"action": "Mercury &#9740; Jupiter",
"tags": "mercury conjunction jupiter"
}
],
[
{
"id": 11,
"action": "Mercury Saturn",
"action": "Mercury &#9740; Saturn",
"tags": "mercury conjunction saturn"
}
],
[
{
"id": 12,
"action": "Venus Sun",
"action": "Venus &#9740; Sun",
"tags": "venus conjunction sun"
}
],
[
{
"id": 13,
"action": "Venus Mars",
"action": "Venus &#9740; Mars",
"tags": "venus conjunction mars"
}
],
[
{
"id": 14,
"action": "Venus Jupiter",
"action": "Venus &#9740; Jupiter",
"tags": "venus conjunction jupiter"
}
],
[
{
"id": 15,
"action": "Venus Saturn",
"action": "Venus &#9740; Saturn",
"tags": "venus conjunction saturn"
}
],
[
{
"id": 16,
"action": "Sun Mars",
"action": "Sun &#9740; Mars",
"tags": "sun conjunction mars"
}
],
[
{
"id": 17,
"action": "Sun Jupiter",
"action": "Sun &#9740; Jupiter",
"tags": "sun conjunction jupiter"
}
],
[
{
"id": 18,
"action": "Sun Saturn",
"action": "Sun &#9740; Saturn",
"tags": "sun conjunction saturn"
}
],
[
{
"id": 19,
"action": "Mars Jupiter",
"action": "Mars &#9740; Jupiter",
"tags": "mars conjunction jupiter"
}
],
[
{
"id": 20,
"action": "Mars Saturn",
"action": "Mars &#9740; Saturn",
"tags": "mars conjunction saturn"
}
],
[
{
"id": 21,
"action": "Jupiter Saturn",
"action": "Jupiter &#9740; Saturn",
"tags": "jupiter conjunction saturn"
}
],
[
{
"id": 22,
"action": "Moon Mercury",
"action": "Moon &#9914; Mercury",
"tags": "moon sextile mercury"
}
],
[
{
"id": 23,
"action": "Moon Venus",
"action": "Moon &#9914; Venus",
"tags": "moon sextile venus"
}
],
[
{
"id": 24,
"action": "Moon Sun",
"action": "Moon &#9914; Sun",
"tags": "moon sextile sun"
}
],
[
{
"id": 25,
"action": "Moon Mars",
"action": "Moon &#9914; Mars",
"tags": "moon sextile mars"
}
],
[
{
"id": 26,
"action": "Moon Jupiter",
"action": "Moon &#9914; Jupiter",
"tags": "moon sextile jupiter"
}
],
[
{
"id": 27,
"action": "Moon Saturn",
"action": "Moon &#9914; Saturn",
"tags": "moon sextile saturn"
}
],
[
{
"id": 28,
"action": "Mercury Venus",
"action": "Mercury &#9914; Venus",
"tags": "mercury sextile venus"
}
],
[
{
"id": 29,
"action": "Mercury Sun",
"action": "Mercury &#9914; Sun",
"tags": "mercury sextile sun"
}
],
[
{
"id": 30,
"action": "Mercury Mars",
"action": "Mercury &#9914; Mars",
"tags": "mercury sextile mars"
}
],
[
{
"id": 31,
"action": "Mercury Jupiter",
"action": "Mercury &#9914; Jupiter",
"tags": "mercury sextile jupiter"
}
],
[
{
"id": 32,
"action": "Mercury Saturn",
"action": "Mercury &#9914; Saturn",
"tags": "mercury sextile saturn"
}
],
[
{
"id": 33,
"action": "Venus Sun",
"action": "Venus &#9914; Sun",
"tags": "venus sextile sun"
}
],
[
{
"id": 34,
"action": "Venus Mars",
"action": "Venus &#9914; Mars",
"tags": "venus sextile mars"
}
],
[
{
"id": 35,
"action": "Venus Jupiter",
"action": "Venus &#9914; Jupiter",
"tags": "venus sextile jupiter"
}
],
[
{
"id": 36,
"action": "Venus Saturn",
"action": "Venus &#9914; Saturn",
"tags": "venus sextile saturn"
}
],
[
{
"id": 37,
"action": "Sun Mars",
"action": "Sun &#9914; Mars",
"tags": "sun sextile mars"
}
],
[
{
"id": 38,
"action": "Sun Jupiter",
"action": "Sun &#9914; Jupiter",
"tags": "sun sextile jupiter"
}
],
[
{
"id": 39,
"action": "Sun Saturn",
"action": "Sun &#9914; Saturn",
"tags": "sun sextile saturn"
}
],
[
{
"id": 40,
"action": "Mars Jupiter",
"action": "Mars &#9914; Jupiter",
"tags": "mars sextile jupiter"
}
],
[
{
"id": 41,
"action": "Mars Saturn",
"action": "Mars &#9914; Saturn",
"tags": "mars sextile saturn"
}
],
[
{
"id": 42,
"action": "Jupiter Saturn",
"action": "Jupiter &#9914; Saturn",
"tags": "jupiter sextile saturn"
}
],
[
{
"id": 43,
"action": "Moon Mercury",
"action": "Moon &#9633; Mercury",
"tags": "moon square mercury"
}
],
[
{
"id": 44,
"action": "Moon Venus",
"action": "Moon &#9633; Venus",
"tags": "moon square venus"
}
],
[
{
"id": 45,
"action": "Moon Sun",
"action": "Moon &#9633; Sun",
"tags": "moon square sun"
}
],
[
{
"id": 46,
"action": "Moon Mars",
"action": "Moon &#9633; Mars",
"tags": "moon square mars"
}
],
[
{
"id": 47,
"action": "Moon Jupiter",
"action": "Moon &#9633; Jupiter",
"tags": "moon square jupiter"
}
],
[
{
"id": 48,
"action": "Moon Saturn",
"action": "Moon &#9633; Saturn",
"tags": "moon square saturn"
}
],
[
{
"id": 49,
"action": "Mercury Venus",
"action": "Mercury &#9633; Venus",
"tags": "mercury square venus"
}
],
[
{
"id": 50,
"action": "Mercury Sun",
"action": "Mercury &#9633; Sun",
"tags": "mercury square sun"
}
],
[
{
"id": 51,
"action": "Mercury Mars",
"action": "Mercury &#9633; Mars",
"tags": "mercury square mars"
}
],
[
{
"id": 52,
"action": "Mercury Jupiter",
"action": "Mercury &#9633; Jupiter",
"tags": "mercury square jupiter"
}
],
[
{
"id": 53,
"action": "Mercury Saturn",
"action": "Mercury &#9633; Saturn",
"tags": "mercury square saturn"
}
],
[
{
"id": 54,
"action": "Venus Sun",
"action": "Venus &#9633; Sun",
"tags": "venus square sun"
}
],
[
{
"id": 55,
"action": "Venus Mars",
"action": "Venus &#9633; Mars",
"tags": "venus square mars"
}
],
[
{
"id": 56,
"action": "Venus Jupiter",
"action": "Venus &#9633; Jupiter",
"tags": "venus square jupiter"
}
],
[
{
"id": 57,
"action": "Venus Saturn",
"action": "Venus &#9633; Saturn",
"tags": "venus square saturn"
}
],
[
{
"id": 58,
"action": "Sun Mars",
"action": "Sun &#9633; Mars",
"tags": "sun square mars"
}
],
[
{
"id": 59,
"action": "Sun Jupiter",
"action": "Sun &#9633; Jupiter",
"tags": "sun square jupiter"
}
],
[
{
"id": 60,
"action": "Sun Saturn",
"action": "Sun &#9633; Saturn",
"tags": "sun square saturn"
}
],
[
{
"id": 61,
"action": "Mars Jupiter",
"action": "Mars &#9633; Jupiter",
"tags": "mars square jupiter"
}
],
[
{
"id": 62,
"action": "Mars Saturn",
"action": "Mars &#9633; Saturn",
"tags": "mars square saturn"
}
],
[
{
"id": 63,
"action": "Jupiter Saturn",
"action": "Jupiter &#9633; Saturn",
"tags": "jupiter square saturn"
}
],
[
{
"id": 64,
"action": "Moon Mercury",
"action": "Moon &#9651; Mercury",
"tags": "moon trine mercury"
}
],
[
{
"id": 65,
"action": "Moon Venus",
"action": "Moon &#9651; Venus",
"tags": "moon trine venus"
}
],
[
{
"id": 66,
"action": "Moon Sun",
"action": "Moon &#9651; Sun",
"tags": "moon trine sun"
}
],
[
{
"id": 67,
"action": "Moon Mars",
"action": "Moon &#9651; Mars",
"tags": "moon trine mars"
}
],
[
{
"id": 68,
"action": "Moon Jupiter",
"action": "Moon &#9651; Jupiter",
"tags": "moon trine jupiter"
}
],
[
{
"id": 69,
"action": "Moon Saturn",
"action": "Moon &#9651; Saturn",
"tags": "moon trine saturn"
}
],
[
{
"id": 70,
"action": "Mercury Venus",
"action": "Mercury &#9651; Venus",
"tags": "mercury trine venus"
}
],
[
{
"id": 71,
"action": "Mercury Sun",
"action": "Mercury &#9651; Sun",
"tags": "mercury trine sun"
}
],
[
{
"id": 72,
"action": "Mercury Mars",
"action": "Mercury &#9651; Mars",
"tags": "mercury trine mars"
}
],
[
{
"id": 73,
"action": "Mercury Jupiter",
"action": "Mercury &#9651; Jupiter",
"tags": "mercury trine jupiter"
}
],
[
{
"id": 74,
"action": "Mercury Saturn",
"action": "Mercury &#9651; Saturn",
"tags": "mercury trine saturn"
}
],
[
{
"id": 75,
"action": "Venus Sun",
"action": "Venus &#9651; Sun",
"tags": "venus trine sun"
}
],
[
{
"id": 76,
"action": "Venus Mars",
"action": "Venus &#9651; Mars",
"tags": "venus trine mars"
}
],
[
{
"id": 77,
"action": "Venus Jupiter",
"action": "Venus &#9651; Jupiter",
"tags": "venus trine jupiter"
}
],
[
{
"id": 78,
"action": "Venus Saturn",
"action": "Venus &#9651; Saturn",
"tags": "venus trine saturn"
}
],
[
{
"id": 79,
"action": "Sun Mars",
"action": "Sun &#9651; Mars",
"tags": "sun trine mars"
}
],
[
{
"id": 80,
"action": "Sun Jupiter",
"action": "Sun &#9651; Jupiter",
"tags": "sun trine jupiter"
}
],
[
{
"id": 81,
"action": "Sun Saturn",
"action": "Sun &#9651; Saturn",
"tags": "sun trine saturn"
}
],
[
{
"id": 82,
"action": "Mars Jupiter",
"action": "Mars &#9651; Jupiter",
"tags": "mars trine jupiter"
}
],
[
{
"id": 83,
"action": "Mars Saturn",
"action": "Mars &#9651; Saturn",
"tags": "mars trine saturn"
}
],
[
{
"id": 84,
"action": "Jupiter Saturn",
"action": "Jupiter &#9651; Saturn",
"tags": "jupiter trine saturn"
}
],
[
{
"id": 85,
"action": "Moon Mercury",
"action": "Moon &#9741; Mercury",
"tags": "moon opposition mercury"
}
],
[
{
"id": 86,
"action": "Moon Venus",
"action": "Moon &#9741; Venus",
"tags": "moon opposition venus"
}
],
[
{
"id": 87,
"action": "Moon Sun",
"action": "Moon &#9741; Sun",
"tags": "moon opposition sun"
}
],
[
{
"id": 88,
"action": "Moon Mars",
"action": "Moon &#9741; Mars",
"tags": "moon opposition mars"
}
],
[
{
"id": 89,
"action": "Moon Jupiter",
"action": "Moon &#9741; Jupiter",
"tags": "moon opposition jupiter"
}
],
[
{
"id": 90,
"action": "Moon Saturn",
"action": "Moon &#9741; Saturn",
"tags": "moon opposition saturn"
}
],
[
{
"id": 91,
"action": "Mercury Venus",
"action": "Mercury &#9741; Venus",
"tags": "mercury opposition venus"
}
],
[
{
"id": 92,
"action": "Mercury Sun",
"action": "Mercury &#9741; Sun",
"tags": "mercury opposition sun"
}
],
[
{
"id": 93,
"action": "Mercury Mars",
"action": "Mercury &#9741; Mars",
"tags": "mercury opposition mars"
}
],
[
{
"id": 94,
"action": "Mercury Jupiter",
"action": "Mercury &#9741; Jupiter",
"tags": "mercury opposition jupiter"
}
],
[
{
"id": 95,
"action": "Mercury Saturn",
"action": "Mercury &#9741; Saturn",
"tags": "mercury opposition saturn"
}
],
[
{
"id": 96,
"action": "Venus Sun",
"action": "Venus &#9741; Sun",
"tags": "venus opposition sun"
}
],
[
{
"id": 97,
"action": "Venus Mars",
"action": "Venus &#9741; Mars",
"tags": "venus opposition mars"
}
],
[
{
"id": 98,
"action": "Venus Jupiter",
"action": "Venus &#9741; Jupiter",
"tags": "venus opposition jupiter"
}
],
[
{
"id": 99,
"action": "Venus Saturn",
"action": "Venus &#9741; Saturn",
"tags": "venus opposition saturn"
}
],
[
{
"id": 100,
"action": "Sun Mars",
"action": "Sun &#9741; Mars",
"tags": "sun opposition mars"
}
],
[
{
"id": 101,
"action": "Sun Jupiter",
"action": "Sun &#9741; Jupiter",
"tags": "sun opposition jupiter"
}
],
[
{
"id": 102,
"action": "Sun Saturn",
"action": "Sun &#9741; Saturn",
"tags": "sun opposition saturn"
}
],
[
{
"id": 103,
"action": "Mars Jupiter",
"action": "Mars &#9741; Jupiter",
"tags": "mars opposition jupiter"
}
],
[
{
"id": 104,
"action": "Mars Saturn",
"action": "Mars &#9741; Saturn",
"tags": "mars opposition saturn"
}
],
[
{
"id": 105,
"action": "Jupiter Saturn",
"action": "Jupiter &#9741; Saturn",
"tags": "jupiter opposition saturn"
}
]

View file

@ -27,7 +27,7 @@ SWEOBJ = swedate.o swehouse.o swejpl.o swemmoon.o swemplan.o swepcalc.o sweph.o\
swepdate.o swephlib.o swecl.o swehel.o
pmom: pmom.o libswe.a
$(CC) $(OP) -o pmom.js pmom.o -s WASM=1 -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -L. -lswe -lm -ldl
$(CC) $(OP) -o pmom.js pmom.o -s WASM=1 -s "BINARYEN_TRAP_MODE='clamp'" -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' -L. -lswe -lm -ldl
install:
mv pmom.js ../../js/; mv pmom.wasm ../../js/; mv pmom.wast ../../js/

View file

@ -23,7 +23,7 @@
/**
* converts Julian Day to UNIX epoch
*/
unsigned long jul_to_epoch(double jd)
long jul_to_epoch(double jd)
{
struct tm ts;
int32 year, month, day, hour, minute, second;
@ -48,13 +48,13 @@ unsigned long jul_to_epoch(double jd)
ts.tm_isdst = -1;
epoch = timegm(&ts);
return (unsigned long) epoch;
return (long) epoch;
}
/**
* converts year, month, day, hour, minute, second to UNIX epoch
*/
unsigned long time_to_epoch(int32 year, int32 month, int32 day, int32 hour, int32 minute, int32 second)
long time_to_epoch(int32 year, int32 month, int32 day, int32 hour, int32 minute, int32 second)
{
struct tm ts;
time_t epoch;
@ -69,13 +69,13 @@ unsigned long time_to_epoch(int32 year, int32 month, int32 day, int32 hour, int3
ts.tm_isdst = -1;
epoch = timegm(&ts);
return (unsigned long) epoch;
return (long) epoch;
}
/**
* converts UNIX epoch to JD
*/
double epoch_to_jul(unsigned long ts)
double epoch_to_jul(long ts)
{
time_t timestamp;
struct tm *tmp;
@ -102,7 +102,7 @@ double epoch_to_jul(unsigned long ts)
/**
* calculates planetary ephemeris data for a moment and loads it into arrays
*/
int * planetary_moment(double lat, double lon, unsigned long unixtime, double *lunar, double *planets) {
int * planetary_moment(double lat, double lon, long unixtime, double *lunar, double *planets) {
// double lunar[0] = lunar day
// double lunar[1] = lunar phase angle
@ -117,7 +117,7 @@ int * planetary_moment(double lat, double lon, unsigned long unixtime, double *l
double latitude = 0.0;
double longitude = 0.0;
unsigned long epoch = 0;
long epoch = 0;
struct tm *tmp;
time_t timestamp = 0;
int32 year, month, day, hour, minute, second, iflag, iflgret;
@ -200,9 +200,9 @@ int * planetary_moment(double lat, double lon, unsigned long unixtime, double *l
/**
* calculates sunrise and sunset times to determine planetary day and hour
*/
int * solar_moment(double lat, double lon, unsigned long unixtime, unsigned long *solar) {
int * solar_moment(double lat, double lon, long unixtime, long *solar) {
unsigned long epoch = 0;
long epoch = 0;
struct tm *tmp;
time_t timestamp = 0;
int32 year, month, day, hour, minute, second, iflag, pday = 0;
@ -237,7 +237,6 @@ int * solar_moment(double lat, double lon, unsigned long unixtime, unsigned long
// calculate sunrise and sunset of the day and the days before and after tomorrow
ipl = SE_SUN;
rsmi = SE_CALC_RISE;
swe_rise_trans(tjd-1, ipl, starname, iflag, rsmi, geopos, datm[0], datm[1], &sunyesterday[0], serr);
swe_rise_trans(tjd, ipl, starname, iflag, rsmi, geopos, datm[0], datm[1], &suntoday[0], serr);
swe_rise_trans(tjd+1, ipl, starname, iflag, rsmi, geopos, datm[0], datm[1], &suntomorrow[0], serr);
rsmi = SE_CALC_SET;
@ -247,6 +246,7 @@ int * solar_moment(double lat, double lon, unsigned long unixtime, unsigned long
hourlength[0] = (jul_to_epoch(suntoday[0]) - jul_to_epoch(sunyesterday[1])) / 12; // length of night hours yesterday
hourlength[1] = (jul_to_epoch(suntoday[1]) - jul_to_epoch(suntoday[0])) / 12; // length of day hours today
if ( hourlength[1] < 0 ) hourlength[1] = (jul_to_epoch(suntomorrow[1]) - jul_to_epoch(suntoday[0])) / 12;
hourlength[2] = (jul_to_epoch(suntomorrow[0]) - jul_to_epoch(suntoday[1])) / 12; // length of night hours today
// calculate planetary hour
@ -267,12 +267,12 @@ int * solar_moment(double lat, double lon, unsigned long unixtime, unsigned long
*/
const char * pmom(int days, long epoch, double latitude, double longitude, int buflen) // days, timestamp, latitude, longitude
{
unsigned long queryday;
long queryday;
struct tm *tmp;
time_t timestamp = 0;
int32 year, month, day, hour, minute, second, j, h, m, interval, start, hm;
double hours;
unsigned long solar[9] = {0};
long solar[9] = {0};
double lunar[3] = {0.0}, planet[16] = {0.0};
char* Buffer = malloc(buflen);
int length = 0;
@ -317,6 +317,8 @@ const char * pmom(int days, long epoch, double latitude, double longitude, int b
hm, (int) lunar[0], lunar[1], lunar[2], solar[7], solar[1], solar[2]-1, solar[2], solar[3]-1, h, hm, hm+interval-1, solar[5], solar[6], planet[0], planet[7], planet[1], planet[8], planet[2], planet[9], planet[3], planet[10], planet[4], planet[11], planet[5], planet[12], planet[6], planet[13], planet[14], planet[15]
);
//length += snprintf(Buffer+length, buflen-length, "%d setyes %d risetod %d settod %d risetom %d nhly %d dhlt %d nhlt %d pday %d\n", hm, solar[0], solar[1], solar[2], solar[3], solar[4], solar[5], solar[6], solar[7]);
if(j == days && h == 23) length += snprintf(Buffer+length, buflen-length, "");
else length += snprintf(Buffer+length, buflen-length, ", ");
@ -334,7 +336,7 @@ int main(int argc,char* argv[]) // days, timestamp, latitude, longitude
{
double latitude = 0.0;
double longitude = 0.0;
unsigned long epoch = 0;
long epoch = 0;
time_t timestamp = 0;
int32 days = 1, buflen;