-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex-axios.html
130 lines (108 loc) · 5.44 KB
/
index-axios.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,
initial-scale=1.0" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"
integrity="sha512-VZ6m0F78+yo3sbu48gElK4irv2dzPoep8oo9LEjxviigcnnnNvnTOJRSrIhuFk68FMLOpiNz+T77nNY89rnWDg=="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.13.0/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.0/jquery-ui.js"></script>
<script>
$(function () {
$('#datepicker').datepicker({
dateFormat: 'D M dd yy',
onSelect: function (datetext) {
var d = new Date(); // for now
datetext = datetext + " " + d.getHours() + ": " + d.getMinutes() + ": " + d
.getSeconds();
$('#datepicker').val(datetext);
},
});
});
</script>
<title>Astronomical Coordinates in the Solar System</title>
</head>
<body>
<h3 style="color: green; font-size: 25px;">
API based on the Astronomy Bundle Package
</h3>
<p>Enter the Time Of Interest, for which you want to compute coordinates.</p>
<form>
<input type="text" name="date" id="datepicker" required>
<button type="submit">Submit</button>
</form>
<script type="text/javascript">
window.addEventListener("load", () => {
const form = document.querySelector("form");
form.addEventListener("submit", (e) => {
e.preventDefault();
let data = new FormData(form);
axios({
method: "post",
url: "/",
data: data,
})
.then((res) => {
document.getElementById("textArea1").innerHTML = res.data.earth.lon;
document.getElementById("textArea2").innerHTML = res.data.earth.lat;
document.getElementById("textArea3").innerHTML = res.data.earth.radiusVector;
document.getElementById("textArea4").innerHTML = res.data.mars.lon;
document.getElementById("textArea5").innerHTML = res.data.mars.lat;
document.getElementById("textArea6").innerHTML = res.data.mars.radiusVector;
document.getElementById("textArea1g").innerHTML = res.data.venusg.lon;
document.getElementById("textArea2g").innerHTML = res.data.venusg.lat;
document.getElementById("textArea3g").innerHTML = res.data.venusg.radiusVector;
document.getElementById("textArea4g").innerHTML = res.data.marsg.lon;
document.getElementById("textArea5g").innerHTML = res.data.marsg.lat;
document.getElementById("textArea6g").innerHTML = res.data.marsg.radiusVector;
document.getElementById("textArea6d").innerHTML = res.data.marsd;
document.getElementById("textArea4m").innerHTML = res.data.moong.lon;
document.getElementById("textArea5m").innerHTML = res.data.moong.lat;
document.getElementById("textArea6m").innerHTML = res.data.moong.radiusVector;
document.getElementById("textArea6md").innerHTML = res.data.moon_d;
document.getElementById("textArea6mif").innerHTML = res.data.moon_IF;
})
.catch((err) => {
throw err;
});
});
});
</script>
<br>
<br>
<h2>Heliocentric coordinates of Earth</h2>
<p> longitude: <span id="textArea1"></span>°</p>
<p> latitude: <span id="textArea2"></span>°</p>
<p> distance (astronomical units): <span id="textArea3"></span></p>
<h2>Heliocentric coordinates of Mars</h2>
<p> longitude: <span id="textArea4"></span>°</p>
<p> latitude: <span id="textArea5"></span>°</p>
<p> distance (astronomical units): <span id="textArea6"></span></p>
<h2>Geocentric coordinates of Venus</h2>
<p> longitude: <span id="textArea1g"></span>°</p>
<p> latitude: <span id="textArea2g"></span>°</p>
<p> distance (astronomical units): <span id="textArea3g"></span></p>
<h2>Geocentric coordinates of Mars</h2>
<p> longitude: <span id="textArea4g"></span>°</p>
<p> latitude: <span id="textArea5g"></span>°</p>
<p> distance (astronomical units): <span id="textArea6g"></span></p>
<p> distance in km: <span id="textArea6d"></span></p>
<h2>Geocentric coordinates of the Moon</h2>
<p> longitude: <span id="textArea4m"></span>°</p>
<p> latitude: <span id="textArea5m"></span>°</p>
<p> distance (astronomical units): <span id="textArea6m"></span></p>
<p> distance in km: <span id="textArea6md"></span></p>
<p> Illuminated fraction: <span id="textArea6mif"></span></p>
<h2>Prefer a link to the data in JSON format ?
<br>
<a href="/JSON/"> == Get it here ! ==</href></a> </h2>
<br>
<p>
<h6><a href="https://github.com/andrmoel/astronomy-bundle-js"> Astronomy Bundle on Github</href></a></h6>
</p>
</body>
</html>