Commit ccd2345e authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Allow degree input in j2000 tracker.

parent cfbcc0fb
......@@ -320,9 +320,14 @@ function j2000(element_name) {
this.button_track.onclick = function()
{
var ra = j2000_this.ra_validate(j2000_this.txt_ra_sp.value_get());
var el = j2000_this.el_validate(j2000_this.txt_dec_sp.value_get());
console.log("ra: "+ra+" el: "+el);
j2000_this.command.send(
j2000_this.txt_ra_sp.value_get() + " " +
j2000_this.txt_dec_sp.value_get() + " " +
ra + " " +
el + " " +
"enabled=1");
}
......@@ -358,6 +363,66 @@ function j2000(element_name) {
}
this.status.open();
this.ra_validate = function(ra) {
var hms = false;
var i;
for (i = 0; i < ra.length; i++) {
if (ra[i] == 'h' || ra[i] == 'm')
hms = true;
}
if (!hms) {
if (ra + 0 < 0)
ra = ra * 1 + 360;
ra /= 15;
var h = ra|0;
ra -= h;
ra *= 60;
var m = ra|0;
ra -= m;
ra *= 60;
var s = ra;
s = "" + s;
s = s.substring(0,5);
ra = h + "h" + m + "m" + s;
}
return ra;
}
this.el_validate = function(el) {
var dms = false;
var i;
for (i = 0; i < el.length; i++) {
if (el[i] == 'd' || el[i] == 'm')
dms = true;
}
if (!dms) {
var neg = "";
var d = el|0;
el -= d;
el *= 60;
var m = el|0;
el -=m;
if (m < 0)
m = -m;
el *= 60;
var s = el;
if (s < 0)
s = -s;
s = "" + s;
s = s.substring(0,5);
el = d + "d" + m + "m" + s;
}
return el;
}
}
} /* j2000_loaded */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment