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()));
}
});
$('#cbs').click(function() {populateFBSelect(); });
$('#cbp').click(function() {populateFBSelect(); });
$("#pointa").focus(function() {
lastInputBox = "pointa";
// console.log('Updating last touched box to : ' + lastInputBox)
@ -44,26 +45,8 @@ $(document).ready(function() {
function populateUserFields() {
//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) {
var keys = Object.keys(listobjects(types[type]));
keys.sort().forEach(function(element, index, array){
option += '<option value="'+ escapeHTML(element) + '">' + escapeHTML(element) + '</option>';
});
}
$('#findbyselect').html(option);
// Populate findby box
populateFBSelect();
// Populate pointa and pointb dropdowns
var types = ['planets','stations'];
option = "";
@ -81,6 +64,28 @@ function populateUserFields() {
$('#pointa').html(option);
$('#pointb').html(option);
}
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) {
var keys = Object.keys(listobjects(types[type]));
keys.sort().forEach(function(element, index, array){
option += '<option value="'+ escapeHTML(element) + '">' + escapeHTML(element) + '</option>';
});
}
$('#findbyselect').html(option);
}
function openTab(evt,tabName) {

View File

@ -123,7 +123,7 @@
<select id="findbyselect">
<option value=''></option>
</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>
</span>
<span class="toolsep"></span>