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
|
2016-08-24 15:48:33 +00:00
|
|
|
$('.reset-container').click(function(){ reset_view();});
|
2016-07-22 14:23:16 +00:00
|
|
|
$('#submitfindbyname').click(function() {
|
2016-07-12 19:52:58 +00:00
|
|
|
var selected = $('#findbyselect option:selected').text();
|
2016-08-24 15:48:33 +00:00
|
|
|
var object = findObjectInfo(selected);
|
|
|
|
zoomfocus(selected);
|
|
|
|
// Populate information area about target
|
|
|
|
console.log(object)
|
2017-06-14 13:46:14 +00:00
|
|
|
var objdata = "<b>Name: </b>" + object.name + "<br />";
|
2016-08-24 15:48:33 +00:00
|
|
|
objdata += "<br /><b>Location (Galactic Ref.)</b><br /><b>X</b>: " + object.x + "<br/><b>Y</b>: " + object.y + "<br /><b>Z</b>: " + object.z;
|
|
|
|
objdata += "<br /><br /><b>Classification</b><br />" + object.type;
|
|
|
|
objdata += "<br /><br /><b>Owning Faction</b><br />" + object.parent.name;
|
|
|
|
$('#findbydata').html(objdata)
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-12 19:52:58 +00:00
|
|
|
});
|
2016-07-27 19:43:30 +00:00
|
|
|
$('#route_output').change(function() {
|
|
|
|
var stop=$('#route_output :selected').parent().attr('label');
|
|
|
|
zoomfocus(stop);
|
|
|
|
});
|
2016-07-22 14:23:16 +00:00
|
|
|
$('#calctnd').click(function() {
|
2016-07-27 19:43:30 +00:00
|
|
|
|
2016-07-25 16:03:08 +00:00
|
|
|
removeEntity('arrow');
|
|
|
|
lastInputBox = null;
|
2016-07-29 14:01:32 +00:00
|
|
|
$('#route_output').html("No route calculated");
|
2016-08-02 17:22:16 +00:00
|
|
|
var speed = {'speed': $('#speed').val(), 'unit':$('#speedunit option:selected').val() };
|
2016-07-27 19:43:30 +00:00
|
|
|
populateRoutePlan( $('#pointa option:selected').text() , $('#pointb option:selected').text(),speed );
|
|
|
|
|
|
|
|
|
2016-07-22 14:23:16 +00:00
|
|
|
});
|
2016-07-25 16:52:06 +00:00
|
|
|
$('#cbs').click(function() {populateFBSelect(); });
|
|
|
|
$('#cbp').click(function() {populateFBSelect(); });
|
2016-07-22 14:23:16 +00:00
|
|
|
$("#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-22 19:22:16 +00:00
|
|
|
String.prototype.capitalize = function(lower) {
|
|
|
|
return (lower ? this.toLowerCase() : this).replace(/(?:^|\s)\S/g, function(a) { return a.toUpperCase(); });
|
|
|
|
};
|
2016-08-02 17:22:16 +00:00
|
|
|
$('.rpcoord').blur(function() {
|
|
|
|
if(!$(this).val()) { $(this).val( $(this).attr("id") ) }
|
|
|
|
|
|
|
|
});
|
|
|
|
$('.rpcoord').focus(function() {
|
|
|
|
if($(this).val() == $(this).attr("id")) { $(this).val("") }
|
|
|
|
});
|
|
|
|
$('#calcpredict').click(function() {
|
|
|
|
$('#intel_predicted').html("");
|
|
|
|
var predicted = predictDestination(new THREE.Vector3(Number($('#x').val()),Number($('#y').val()),Number($('#z').val())),new THREE.Vector2(Number($('#azmuth').val()),Number($('#inclination').val())),$('#intel_frame option:selected').val());
|
|
|
|
$('#intel_predicted').html(predicted);
|
|
|
|
});
|
2018-01-09 15:27:33 +00:00
|
|
|
$('#client-bar-control').click(function() {
|
|
|
|
$('#client-term-container').toggleClass("hidden");
|
|
|
|
$('#client-ico-down').toggleClass("hidden");
|
|
|
|
$('#client-ico-up').toggleClass("hidden");
|
|
|
|
});
|
|
|
|
$('#client-login').click(function() { reconnect();})
|
2018-01-12 03:52:29 +00:00
|
|
|
$(".vertical-resize").resizable({
|
|
|
|
handles: {
|
|
|
|
'n': '#client-term-resize'
|
|
|
|
},
|
|
|
|
alsoResize: "#client-term-output",
|
|
|
|
minWidth: "100%",
|
|
|
|
maxWidth: "100%",
|
|
|
|
stop: function(event, ui) {
|
|
|
|
$(this).css("width", '');
|
|
|
|
$('#client-term-output').css("width",'');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$(".client-term-container").resize(function() { width = $(this).width(); $("#client").css({'width' : '100%'}); $("#client-term-output").css({'margin-right' : '0px !important', 'padding-right' : '0 !important'}) })
|
2018-01-09 15:27:33 +00:00
|
|
|
startup();
|
|
|
|
|
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() {
|
2016-07-25 16:52:06 +00:00
|
|
|
// Populate findby box
|
|
|
|
populateFBSelect();
|
2016-07-22 14:23:16 +00:00
|
|
|
// Populate pointa and pointb dropdowns
|
|
|
|
var types = ['planets','stations'];
|
2016-07-22 19:22:16 +00:00
|
|
|
option = "";
|
2016-07-22 14:23:16 +00:00
|
|
|
for (var type in types){
|
2016-07-22 19:22:16 +00:00
|
|
|
var keys = Object.keys(listobjects(types[type]));
|
|
|
|
var captype = types[type];
|
|
|
|
captype = captype.capitalize()
|
2016-07-27 19:43:30 +00:00
|
|
|
option += '<optgroup label="'+ captype + '">';
|
2016-07-22 19:22:16 +00:00
|
|
|
keys.sort().forEach(function(element, index, array){
|
|
|
|
option += '<option value="'+ escapeHTML(element) + '">' + escapeHTML(element) + '</option>';
|
|
|
|
});
|
2016-07-27 19:43:30 +00:00
|
|
|
option += '</optgroup>';
|
2016-07-22 19:22:16 +00:00
|
|
|
|
2016-07-22 14:23:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$('#pointa').html(option);
|
|
|
|
$('#pointb').html(option);
|
|
|
|
|
2016-08-02 17:22:16 +00:00
|
|
|
// Populate list of borders for intel frame selection
|
|
|
|
option = $('#intel_frame').html();
|
|
|
|
var borderlist = listobjects("borders");
|
|
|
|
|
|
|
|
for (var border in borderlist) {
|
|
|
|
if(borderlist[border].radius > 10) {
|
|
|
|
option += '<option value="'+ escapeHTML(border) + '">' + escapeHTML(border) + '</option>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#intel_frame').html(option);
|
|
|
|
|
2016-07-25 16:52:06 +00:00
|
|
|
}
|
|
|
|
function populateFBSelect() {
|
|
|
|
//Populate find by select dropdown
|
|
|
|
var types = [];
|
|
|
|
var checkboxes = document.getElementsByName("objtype");
|
|
|
|
for (var type in checkboxes) {
|
|
|
|
if(checkboxes[type].checked) {
|
|
|
|
types[type] = checkboxes[type].value;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
var option = '';
|
|
|
|
for (var type in types) {
|
2016-07-27 19:43:30 +00:00
|
|
|
var captype = types[type];
|
|
|
|
captype = captype.capitalize()
|
|
|
|
option += '<optgroup label="'+ captype + '">';
|
2016-07-25 16:52:06 +00:00
|
|
|
var keys = Object.keys(listobjects(types[type]));
|
|
|
|
keys.sort().forEach(function(element, index, array){
|
|
|
|
option += '<option value="'+ escapeHTML(element) + '">' + escapeHTML(element) + '</option>';
|
|
|
|
});
|
2016-07-27 19:43:30 +00:00
|
|
|
option += '</optgroup>';
|
2016-07-25 16:52:06 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#findbyselect').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
|
|
|
|
}
|
2016-07-27 19:43:30 +00:00
|
|
|
|
|
|
|
function populateRoutePlan(pointa,pointb,speed) {
|
|
|
|
if ( pointa != pointb ) {
|
|
|
|
// Populate legacy (trip total) fields with route info
|
|
|
|
$('#cal_start').html( pointa );
|
|
|
|
$('#cal_end').html( pointb );
|
|
|
|
$('#cal_speed').html( speed.speed + " " + speed.unit );
|
|
|
|
var route = calcBestRoute(pointa,pointb);
|
|
|
|
var dist = route.distance;
|
|
|
|
var eta = calcETA(speed,dist);
|
|
|
|
$('#cal_eta').html( timeformat(eta) );
|
|
|
|
$('#cal_dist').html( dist.toFixed(2) + " PC");
|
|
|
|
|
|
|
|
// Populate the route plan select area
|
|
|
|
lastWaypoint = {'name': pointa, gate:false};
|
|
|
|
var routeplan;
|
|
|
|
route.stops.forEach(function(waypoint,index,self) {
|
|
|
|
routeplan += '<optgroup label="' + waypoint.name + '">';
|
|
|
|
if(typeof self[index+1] != 'undefined' ) {
|
|
|
|
if(waypoint.gate && self[index+1].gate) {routeplan += '<option>^---- Gate From</option>'; }
|
|
|
|
}
|
|
|
|
if(waypoint.gate && lastWaypoint.gate) {routeplan += '<option>^---- Gate Exit</option>'; }
|
|
|
|
|
|
|
|
if(!waypoint.gate || (!lastWaypoint.gate && waypoint.gate)) {
|
2016-08-19 19:59:16 +00:00
|
|
|
routeplan += '<option>Distance:' + waypoint.distance.toFixed(2) + '</option>'
|
|
|
|
routeplan += '<option>ETA: ' + timeformat(calcETA(speed,waypoint.distance)) + '</option>';
|
|
|
|
drawline(grabPositionByName(lastWaypoint.name.split('@')[lastWaypoint.name.split('@').length-1] ),grabPositionByName(waypoint.name.split('@')[waypoint.name.split('@').length-1] ));
|
2016-07-27 19:43:30 +00:00
|
|
|
}
|
|
|
|
lastWaypoint = waypoint;
|
|
|
|
});
|
|
|
|
$('#route_output').html(routeplan);
|
|
|
|
//drawline(grabPositionByName($('#pointa option:selected').text()),grabPositionByName($('#pointb option:selected').text()));
|
|
|
|
}
|
|
|
|
}
|