Added found object data in findby per feature request by Lustan

This commit is contained in:
Rob L 2016-08-24 11:48:33 -04:00
parent abd78b0269
commit b7f2bbcae9
3 changed files with 54 additions and 5 deletions

View File

@ -7,10 +7,21 @@ $(document).ready(function() {
});
// Reset view
$('.reset-container').click(function(){ reset_view(); });
$('.reset-container').click(function(){ reset_view();});
$('#submitfindbyname').click(function() {
var selected = $('#findbyselect option:selected').text();
zoomfocus(selected);
var object = findObjectInfo(selected);
zoomfocus(selected);
// Populate information area about target
console.log(object)
var objdata = "<b>Name: </b>" + object.name + "<br />";
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)
});
$('#route_output').change(function() {
var stop=$('#route_output :selected').parent().attr('label');

View File

@ -192,14 +192,14 @@ function animate() {
function render () {
//requestAnimationFrame( render );
var objectlist = Object.keys(listobjects("stations"));
objectlist.forEach (function(station) { var obj = scene.getObjectByName(escapeHTML(station + "_label")); obj.lookAt(camera.position) }) ;
objectlist = Object.keys(listobjects("planets"));
objectlist.forEach (function(planet) { var obj = scene.getObjectByName(escapeHTML(planet + "_label")); obj.lookAt(camera.position) }) ;
objectlist = Object.keys(listobjects("borders"));
objectlist.forEach (function(border) { var obj = scene.getObjectByName(border + "_label"); if (obj != undefined) { obj.lookAt(camera.position)} }) ;
renderer.render( scene, camera );
}
@ -371,7 +371,7 @@ function calcBestRoute(pointa,pointb) {
} // End gate work...
// Calculate wormhole route
// Qon does this by quadrant. Frey does this by brute force. The following may be really scary.
jsonWormhole.forEach(function(wh) { distance_wb[wh.enda.location] = calcDist(pointb,wh.enda.location); distance_wb[wh.endb.location] = calcDist(pointb,wh.endb.location); });
@ -449,3 +449,35 @@ function predictDestination(loc,heading,frame) {
function boundingSphereGrab(name){
return scene.getObjectByName(name)
}
function findObjectInfo(name) {
var object = {};
var types = ["stations","planets","borders"];
types.forEach(function(type) {
for (var key in jsonEmpire) {
area=jsonEmpire[key];
for (var key2 in area[type]) {
if(escapeHTML(area[type][key2].name) == name) {
object = area[type][key2];
object.parent = jsonEmpire[key];
switch(type) {
case 'planets':
object.type = "Planet";
break;
case 'borders':
object.type = "Territory";
break;
case 'stations':
object.type = "Starbase/Base/Station";
break;
default:
object.type = "Currently Unknown"
}
}
}
}});
return object;
}

View File

@ -128,8 +128,14 @@
</select> <br />
<input type="checkbox" name="objtype" id="cbp" value="planets" checked><label for="cbp"> Planets</label> <input type="checkbox" name="objtype" id="cbs" value="stations" > <label for="cbs">Stations</label>
<button id="submitfindbyname" class="btn">Find</button>
</span>
<span class="toolsep"></span>
<span>
<label>Target Data</label>
<p id="findbydata"> </p>
</span>
</div>
<div class="wvg-tools" id="Plan">
<span class="tool-header"> Route Planner </span>