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

@ -10,7 +10,18 @@ $(document).ready(function() {
$('.reset-container').click(function(){ reset_view();}); $('.reset-container').click(function(){ reset_view();});
$('#submitfindbyname').click(function() { $('#submitfindbyname').click(function() {
var selected = $('#findbyselect option:selected').text(); var selected = $('#findbyselect option:selected').text();
var object = findObjectInfo(selected);
zoomfocus(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() { $('#route_output').change(function() {
var stop=$('#route_output :selected').parent().attr('label'); var stop=$('#route_output :selected').parent().attr('label');

View File

@ -449,3 +449,35 @@ function predictDestination(loc,heading,frame) {
function boundingSphereGrab(name){ function boundingSphereGrab(name){
return scene.getObjectByName(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 /> </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> <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> <button id="submitfindbyname" class="btn">Find</button>
</span> </span>
<span class="toolsep"></span> <span class="toolsep"></span>
<span>
<label>Target Data</label>
<p id="findbydata"> </p>
</span>
</div> </div>
<div class="wvg-tools" id="Plan"> <div class="wvg-tools" id="Plan">
<span class="tool-header"> Route Planner </span> <span class="tool-header"> Route Planner </span>