2016-07-22 14:23:16 +00:00
|
|
|
var lastInputBox;
|
|
|
|
|
2016-07-12 19:52:58 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
// Controls menu hide/show
|
|
|
|
$('#hotdog').click(function(){
|
|
|
|
$('#controls').toggleClass("active");
|
2016-07-22 14:23:16 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Reset view
|
|
|
|
$('.reset-container').click(function(){ reset_view(); });
|
|
|
|
$('#submitfindbyname').click(function() {
|
2016-07-12 19:52:58 +00:00
|
|
|
var selected = $('#findbyselect option:selected').text();
|
|
|
|
zoomfocus(selected);
|
|
|
|
});
|
2016-07-22 14:23:16 +00:00
|
|
|
$('#calctnd').click(function() {
|
|
|
|
$('#cal_start').html( $('#pointa option:selected').text() );
|
|
|
|
$('#cal_end').html( $('#pointb option:selected').text() );
|
|
|
|
$('#cal_speed').html( $('#speed').val() +" " + $('#speedunit option:selected').val() );
|
|
|
|
var dist = calcDist( $('#pointa option:selected').text(), $('#pointb option:selected').text() );
|
|
|
|
var eta = calcETA({'speed': $('#speed').val(), 'unit': $('#speedunit option:selected').val()},dist)
|
|
|
|
$('#cal_eta').html( timeformat(eta) );
|
|
|
|
$('#cal_dist').html( dist.toFixed(2) + " PC");
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#pointa").focus(function() {
|
|
|
|
lastInputBox = "pointa";
|
|
|
|
// console.log('Updating last touched box to : ' + lastInputBox)
|
|
|
|
});
|
|
|
|
$("#pointb").focus(function() {
|
|
|
|
lastInputBox = "pointb";
|
|
|
|
// console.log('Updating last touched box to : ' + lastInputBox)
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-07-12 19:52:58 +00:00
|
|
|
});
|
|
|
|
|
2016-07-22 14:23:16 +00:00
|
|
|
|
2016-07-12 19:52:58 +00:00
|
|
|
function populateUserFields() {
|
|
|
|
//Populate find by select dropdown
|
2016-07-22 14:23:16 +00:00
|
|
|
var types = [];
|
|
|
|
var checkboxes = document.getElementsByName("objtype");
|
2016-07-12 19:52:58 +00:00
|
|
|
for (var type in checkboxes) {
|
2016-07-22 14:23:16 +00:00
|
|
|
if(checkboxes[type].checked) {
|
|
|
|
types[type] = checkboxes[type].value;
|
2016-07-12 19:52:58 +00:00
|
|
|
}
|
2016-07-22 14:23:16 +00:00
|
|
|
|
|
|
|
}
|
2016-07-12 19:52:58 +00:00
|
|
|
var option = '';
|
|
|
|
for (var type in types){
|
|
|
|
for ( var key in listobjects(types[type]) ){
|
|
|
|
option += '<option value="'+ escapeHTML(key) + '">' + escapeHTML(key) + '</option>';
|
|
|
|
}
|
|
|
|
}
|
2016-07-22 14:23:16 +00:00
|
|
|
|
2016-07-12 19:52:58 +00:00
|
|
|
$('#findbyselect').html(option);
|
2016-07-22 14:23:16 +00:00
|
|
|
|
|
|
|
// Populate pointa and pointb dropdowns
|
|
|
|
var types = ['planets','stations'];
|
|
|
|
for (var type in types){
|
|
|
|
for ( var key in listobjects(types[type]) ){
|
|
|
|
option += '<option value="'+ escapeHTML(key) + '">' + escapeHTML(key) + '</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#pointa').html(option);
|
|
|
|
$('#pointb').html(option);
|
|
|
|
|
2016-07-12 19:52:58 +00:00
|
|
|
}
|
2016-07-08 19:18:12 +00:00
|
|
|
|
|
|
|
function openTab(evt,tabName) {
|
|
|
|
var i, x, tablinks;
|
2016-07-12 19:52:58 +00:00
|
|
|
x = document.getElementsByClassName("wvg-tools");
|
2016-07-08 19:07:21 +00:00
|
|
|
for (i = 0; i < x.length; i++) {
|
2016-07-08 19:18:12 +00:00
|
|
|
x[i].style.display = "none";
|
2016-07-08 19:07:21 +00:00
|
|
|
}
|
2016-07-12 19:52:58 +00:00
|
|
|
tablinks = document.getElementsByClassName("wvg-tablink");
|
2016-07-08 19:18:12 +00:00
|
|
|
for (i = 0; i < x.length; i++) {
|
2016-07-12 19:52:58 +00:00
|
|
|
tablinks[i].className = tablinks[i].className.replace(" wvg-tab-active", "");
|
2016-07-08 19:18:12 +00:00
|
|
|
}
|
|
|
|
document.getElementById(tabName).style.display = "block";
|
2016-07-12 19:52:58 +00:00
|
|
|
evt.currentTarget.className += " wvg-tab-active";
|
2016-07-08 19:07:21 +00:00
|
|
|
}
|
2016-07-12 19:52:58 +00:00
|
|
|
|
2016-07-22 14:23:16 +00:00
|
|
|
function escapeHTML(text) {
|
2016-07-12 19:52:58 +00:00
|
|
|
var chr = { '"': '"', '&': '&', '<': '[', '>': ']' };
|
|
|
|
function abc(a)
|
|
|
|
{
|
|
|
|
return chr[a];
|
|
|
|
}
|
|
|
|
return text.replace(/[\"&<>]/g, abc);
|
2016-07-22 14:23:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function timeformat(secs) {
|
|
|
|
var s = new Decimal(secs);
|
|
|
|
var hours = new Decimal(secs / 3600);
|
|
|
|
var h = hours.floor(); //Get whole hours
|
|
|
|
s = s - (h * 3600);
|
|
|
|
var m = new Decimal(s / 60); //Get remaining minutes
|
|
|
|
m = m.floor();
|
|
|
|
s = s - (m * 60 );
|
|
|
|
s = Math.round(s,0)
|
2016-07-22 15:49:31 +00:00
|
|
|
// console.log("Hours :"+ h);
|
|
|
|
// console.log("Minutes :"+ m);
|
|
|
|
// console.log("Seconds :"+ s);
|
|
|
|
// console.log("Input :"+ secs);
|
2016-07-22 14:23:16 +00:00
|
|
|
return h+":"+(m < 10 ? '0'+m : m)+":"+(s < 10 ? '0'+s : s); //zero padding on minutes and seconds
|
|
|
|
}
|