forked from mivion/ephemeris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathload.js
120 lines (106 loc) · 2.73 KB
/
load.js
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
$ns.load = function () {
var textAreas = document.body.getElementsByTagName ('textarea');
var selects = document.body.getElementsByTagName ('select');
var classes, ids, value;
var i, j, key;
var date = {
year: 1986,
month: 1,
day: 1,
hours: 16,
minutes: 47,
seconds: 0
};
//$processor.test ();
// fill input
if (textAreas) {
for (i = 0; i < textAreas.length; i ++) {
ids = textAreas [i].getAttribute ('id');
try {
eval ('' + ids + ' = "' + textAreas [i].value + '"');
} catch (exception) {
}
}
}
if ($const.date) {
var tokens = $const.date.split (' ');
tokens [0] = tokens [0].split ('.');
tokens [1] = tokens [1].split (':');
date = {
day: parseFloat (tokens [0][0]),
month: parseFloat (tokens [0][1]),
year: parseFloat (tokens [0][2]),
hours: parseFloat (tokens [1][0]),
minutes: parseFloat (tokens [1][1]),
seconds: parseFloat (tokens [1][2])
};
$const.date = date;
}
// fill input bodies
if (selects) {
for (i = 0; i < selects.length; i ++) {
classes = selects [i].getAttribute ('class');
ids = selects [i].getAttribute ('id');
if (classes) {
try {
var selector = eval ('(' + classes + ')');
if (selects [i].innerHTML) {
eval (ids + ' = ' + classes + '.' + selects [i].value);
} else {
var selections = [];
for (key in selector) {
if (selector.hasOwnProperty (key) && selector [key].key == key && key != 'earth') {
selections.push ('<option label=' + key + '>' + key + '</option>');
}
}
selects [i].innerHTML = selections;
}
} catch (exception) {
}
}
}
}
$processor.init ();
$processor.calc (date, $const.body);
var info = document.getElementById ('info');
if (info) {
info.innerHTML =
'julian = ' + date.julian + ', ' +
'delta = ' + date.delta + '<br/>' +
'terrstrial = ' + date.terrestrial + '<br/>' +
'universal = ' + date.universal + ' - ' + (
date.universalDate.day + '.' +
date.universalDate.month + '.' +
date.universalDate.year + ' ' +
date.universalDate.hours + ':' +
date.universalDate.minutes + ':' +
date.universalDate.seconds + '.' +
date.universalDate.milliseconds
) + '' +
''
;
}
var ephemeris = document.getElementById ('ephemeris');
if (ephemeris) {
ephemeris.innerHTML =
'<td>earth</td>' +
''
;
}
// fill output
if (textAreas) {
for (i = 0; i < textAreas.length; i ++) {
classes = (textAreas [i].getAttribute ('class') || '').split (' ');
for (j = 0; j < classes.length; j ++) {
try {
value = eval ('(' + classes [j] + ')');
if (value || value === 0) {
textAreas [i].value = value.join ? value.join ('\n') : value;
break;
}
} catch (exception) {
}
}
}
}
};