[Station Locations] Added Chile States plus cleaned up the js functions

This commit is contained in:
Peter Goodhall 2024-05-23 14:52:41 +01:00
parent de7a82cc3f
commit cefabec877
2 changed files with 52 additions and 200 deletions

View File

@ -427,6 +427,29 @@
<small id="StateHelp" class="form-text text-muted"><?php echo lang("station_location_state_hint"); ?></small>
</div>
<div class="mb-3" id="chile_state">
<label for="stateInput"><?php echo lang("station_location_state"); ?></label>
<select class="form-select" name="station_state" id="StateHelp" aria-describedby="stationCntyInputHelp">
<option value=""></option>
<option value="II" <?php if($my_station_profile->state == "II") { echo "selected"; } ?>>Antofagasta</option>
<option value="III" <?php if($my_station_profile->state == "III") { echo "selected"; } ?>>Atacama</option>
<option value="I" <?php if($my_station_profile->state == "I") { echo "selected"; } ?>>Tarapacá</option>
<option value="XV" <?php if($my_station_profile->state == "XV") { echo "selected"; } ?>>Arica y Parinacota</option>
<option value="IV" <?php if($my_station_profile->state == "IV") { echo "selected"; } ?>>Coquimbo</option>
<option value="V" <?php if($my_station_profile->state == "V") { echo "selected"; } ?>>Valparaíso</option>
<option value="RM" <?php if($my_station_profile->state == "RM") { echo "selected"; } ?>>Región Metropolitana de Santiago</option>
<option value="VI" <?php if($my_station_profile->state == "VI") { echo "selected"; } ?>>Libertador General Bernardo O'Higgins</option>
<option value="VII" <?php if($my_station_profile->state == "VII") { echo "selected"; } ?>>Maule</option>
<option value="VIII" <?php if($my_station_profile->state == "VIII") { echo "selected"; } ?>>Bío-Bío</option>
<option value="IX" <?php if($my_station_profile->state == "IX") { echo "selected"; } ?>>La Araucanía</option>
<option value="XIV" <?php if($my_station_profile->state == "XIV") { echo "selected"; } ?>>Los Ríos</option>
<option value="X" <?php if($my_station_profile->state == "X") { echo "selected"; } ?>>Los Lagos</option>
<option value="XI" <?php if($my_station_profile->state == "XI") { echo "selected"; } ?>>Aisén del General Carlos Ibáñez del Campo</option>
<option value="XII" <?php if($my_station_profile->state == "XII") { echo "selected"; } ?>>Magallanes</option>
</select>
<small id="StateHelp" class="form-text text-muted"><?php echo lang("station_location_state_hint"); ?></small>
</div>
<!-- US County -->
<div class="mb-3">

View File

@ -9,211 +9,40 @@ $(document).ready( function () {
}
});
$("#canada_state").hide();
$("#aland_state").hide();
$("#asiatic_russia_state").hide();
$("#belarus_state").hide();
$("#mexico_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
var stateMap = {
'1': 'canada_state',
'5': 'aland_state',
'15': 'asiatic_russia_state',
'27': 'belarus_state',
'50': 'mexico_state',
'54': 'eu_russia_state',
'100': 'argentina_state',
'108': 'brazil_state',
'112': 'chile_state'
};
// Hide all states initially
$("#canada_state, #aland_state, #asiatic_russia_state, #belarus_state, #mexico_state, #eu_russia_state, #argentina_state, #brazil_state, #chile_state, #us_state").hide();
var selectedDXCCID = $('#dxcc_select').find(":selected").val();
var stateToShow = stateMap[selectedDXCCID];
if(selectedDXCCID == '1'){
$("#canada_state").show();
$("#us_state").hide();
$("#asiatic_russia_state").hide();
$("#eu_russia_state").hide();
$("#belarus_state").hide();
$("#aland_state").hide();
$("#mexico_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
}
// Show Aland States if Aland is selected
if(selectedDXCCID == '5'){
$("#aland_state").show();
$("#canada_state").hide();
$("#us_state").hide();
$("#asiatic_russia_state").hide();
$("#eu_russia_state").hide();
$("#belarus_state").hide();
$("#mexico_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
}
// Show Asiatic Russia States if Asiatic Russia is selected
if(selectedDXCCID == '15'){
$("#asiatic_russia_state").show();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#belarus_state").hide();
$("#mexico_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
}
// Show Belarus States if Belarus is selected
if(selectedDXCCID == '27'){
$("#belarus_state").show();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#mexico_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
}
// Show Mexico States if Mexico is selected
if(selectedDXCCID == '50'){
$("#mexico_state").show();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
}
// Show EU Russia States if EU Russia is selected
if(selectedDXCCID == '54'){
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").show();
$("#argentina_state").hide();
$("#brazil_state").hide();
}
// Show Argentina States if Argentina is selected
if(selectedDXCCID == '100'){
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").show();
$("#brazil_state").hide();
}
// Show Brazil States if Brazil is selected
if(selectedDXCCID == '108'){
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").show();
if (stateToShow) {
// Show the selected state
$("#" + stateToShow).show();
} else {
// If no state matches the selected value, show 'us_state' by default
$("#us_state").show();
}
$('#dxcc_select').change(function(){
if($(this).val() == '1'){
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").show();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
} else if($(this).val() == '5') {
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").show();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
} else if($(this).val() == '15') {
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").show();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
} else if($(this).val() == '27') {
$("#mexico_state").hide();
$("#belarus_state").show();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
} else if($(this).val() == '50') {
$("#mexico_state").show();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
} else if($(this).val() == '54') {
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").show();
$("#argentina_state").hide();
$("#brazil_state").hide();
} else if($(this).val() == '100') {
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").show();
$("#brazil_state").hide();
} else if($(this).val() == '108') {
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").hide();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").show();
} else {
$("#mexico_state").hide();
$("#belarus_state").hide();
$("#asiatic_russia_state").hide();
$("#aland_state").hide();
$("#canada_state").hide();
$("#us_state").show();
$("#eu_russia_state").hide();
$("#argentina_state").hide();
$("#brazil_state").hide();
}
var selectedValue = $(this).val();
var stateToShow = stateMap[selectedValue] || stateMap['default'];
// Hide all states
$("#mexico_state, #belarus_state, #asiatic_russia_state, #aland_state, #canada_state, #us_state, #eu_russia_state, #argentina_state, #brazil_state, #chile_state").hide();
// Show the selected state
$("#" + stateToShow).show();
});
} );