Don't regenerate all fields if we just need the one - find by select

This commit is contained in:
Rob L 2016-07-25 12:52:06 -04:00
parent e9b0b7b55a
commit 2bc5c8b990
2 changed files with 27 additions and 22 deletions

View File

@ -26,7 +26,8 @@ $(document).ready(function() {
drawline(grabPositionByName($('#pointa option:selected').text()),grabPositionByName($('#pointb option:selected').text())); drawline(grabPositionByName($('#pointa option:selected').text()),grabPositionByName($('#pointb option:selected').text()));
} }
}); });
$('#cbs').click(function() {populateFBSelect(); });
$('#cbp').click(function() {populateFBSelect(); });
$("#pointa").focus(function() { $("#pointa").focus(function() {
lastInputBox = "pointa"; lastInputBox = "pointa";
// console.log('Updating last touched box to : ' + lastInputBox) // console.log('Updating last touched box to : ' + lastInputBox)
@ -44,6 +45,27 @@ $(document).ready(function() {
function populateUserFields() { function populateUserFields() {
// Populate findby box
populateFBSelect();
// Populate pointa and pointb dropdowns
var types = ['planets','stations'];
option = "";
for (var type in types){
var keys = Object.keys(listobjects(types[type]));
var captype = types[type];
captype = captype.capitalize()
option += '<option value="">==== ' + captype + ' ====</option>';
keys.sort().forEach(function(element, index, array){
option += '<option value="'+ escapeHTML(element) + '">' + escapeHTML(element) + '</option>';
});
}
$('#pointa').html(option);
$('#pointb').html(option);
}
function populateFBSelect() {
//Populate find by select dropdown //Populate find by select dropdown
var types = []; var types = [];
var checkboxes = document.getElementsByName("objtype"); var checkboxes = document.getElementsByName("objtype");
@ -64,23 +86,6 @@ function populateUserFields() {
$('#findbyselect').html(option); $('#findbyselect').html(option);
// Populate pointa and pointb dropdowns
var types = ['planets','stations'];
option = "";
for (var type in types){
var keys = Object.keys(listobjects(types[type]));
var captype = types[type];
captype = captype.capitalize()
option += '<option value="">==== ' + captype + ' ====</option>';
keys.sort().forEach(function(element, index, array){
option += '<option value="'+ escapeHTML(element) + '">' + escapeHTML(element) + '</option>';
});
}
$('#pointa').html(option);
$('#pointb').html(option);
} }
function openTab(evt,tabName) { function openTab(evt,tabName) {

View File

@ -123,7 +123,7 @@
<select id="findbyselect"> <select id="findbyselect">
<option value=''></option> <option value=''></option>
</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" onclick="populateUserFields();"> <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>