Resolved conflict in form.js

This commit is contained in:
gaazzopa 2020-12-09 18:32:53 +01:00
parent b2b8938b9f
commit 230424edfc
2 changed files with 15 additions and 47 deletions

View file

@ -1,7 +1,7 @@
/* -------HTML structure------- */
function getChildElement(elem) {
// Get the element named in the given element's data-enables attribute.
return $("#" + elem.data("enables"));
return $(elem.data("enables"));
}
function insertErrorFor(referenceNode, text) {
@ -259,46 +259,14 @@ function show_disclaimer() {
}
}
$(".has_radio").on('click', function(event){
click_radio(this.id);
$("[data-has-radio]").on('click', function(event){
$($(this).data("has-radio")).click();
});
$(".has_radio").on('change', function(event){
click_radio(this.id);
$("[data-has-radio]").on('change', function(event){
$($(this).data("has-radio")).click();
});
function click_radio(id) {
switch (id) {
case "room_volume":
$("#room_type_volume").click();
break;
case "floor_area":
case "ceiling_height":
$("#room_type_dimensions").click();
break;
case "air_supply":
$("#air_type_supply").click();
break;
case "air_changes":
$("#air_type_changes").click();
break;
case "window_width":
$("#window_hinged").click();
break;
case "hepa_amount":
$("#hepa_yes").click();
break;
case "single_event_date":
$("#event_type_single").click();
break;
case "recurrent_event_month":
$("#event_type_recurrent").click();
break;
default:
break;
}
}
/* -------Form validation------- */
function validate_form(form) {
var submit = true;

View file

@ -46,12 +46,12 @@
</div><br>
<input type="radio" id="room_type_volume" name="volume_type" value="room_volume" onclick="require_fields(this)" tabindex="-1" required>
<label for="room_type_volume">Room volume:</label> &nbsp;&nbsp;
<input type="number" step="any" id="room_volume" class="non_zero has_radio" name="room_volume" placeholder="Room volume (m³)" min="0"><br>
<input type="number" step="any" id="room_volume" class="non_zero" name="room_volume" placeholder="Room volume (m³)" min="0" data-has-radio="#room_type_volume"><br>
<input type="radio" id="room_type_dimensions" name="volume_type" value="room_dimensions" onclick="require_fields(this)" tabindex="-1" required>
<label for="room_type_dimensions">Floor area:</label> &nbsp;&nbsp;
<input type="number" step="any" id="floor_area" class="non_zero has_radio" name="floor_area" placeholder="Room floor area (m²)" min="0"><br>
<input type="number" step="any" id="floor_area" class="non_zero" name="floor_area" placeholder="Room floor area (m²)" min="0" data-has-radio="#room_type_dimensions"><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <label for="room_type_dimensions">Ceiling height:</label> &nbsp;&nbsp;
<input type="number" step="any" id="ceiling_height" class="non_zero has_radio" name="ceiling_height" placeholder="Room ceiling height (m²)" min="0" ><br>
<input type="number" step="any" id="ceiling_height" class="non_zero" name="ceiling_height" placeholder="Room ceiling height (m²)" min="0" data-has-radio="#room_type_dimensions"><br>
<hr width="80%">
<!-- Ventilation Options -->
@ -62,18 +62,18 @@
Ventilation type:
<input type="radio" id="no_ventilation" name="ventilation_type" value="no-ventilation" checked>
<label for="no_ventilation">No ventilation</label>&nbsp;&nbsp;
<input type="radio" id="mechanical" name="ventilation_type" value="mechanical" data-enables="DIVmechanical_ventilation">
<input type="radio" id="mechanical" name="ventilation_type" value="mechanical" data-enables="#DIVmechanical_ventilation">
<label for="mechanical">Mechanical</label>&nbsp;&nbsp;
<input type="radio" id="natural" name="ventilation_type" value="natural" data-enables="DIVnatural_ventilation">
<input type="radio" id="natural" name="ventilation_type" value="natural" data-enables="#DIVnatural_ventilation">
<label for="natural">Natural</label><br>
<div id="DIVmechanical_ventilation" style="display:none">
<input type="radio" id="air_type_supply" name="mechanical_ventilation_type" value="air_supply" onclick="require_fields(this)" tabindex="-1">
<label for="air_type_supply">Air supply flow rate</label> &nbsp;&nbsp;
<input type="number" step="any" id="air_supply" class="non_zero has_radio" name="air_supply" min="0" placeholder="(m³ / hour)"><br>
<input type="number" step="any" id="air_supply" class="non_zero" name="air_supply" min="0" placeholder="(m³ / hour)" data-has-radio="#air_type_supply"><br>
<input type="radio" id="air_type_changes" name="mechanical_ventilation_type" value="air_changes" onclick="require_fields(this)" tabindex="-1">
<label for="air_type_changes">Air changes per hour</label> &nbsp;&nbsp;
<input type="number" step="any" id="air_changes" class="non_zero has_radio" name="air_changes" min="0" placeholder="(h⁻¹) only fresh air"><br>
<input type="number" step="any" id="air_changes" class="non_zero" name="air_changes" min="0" placeholder="(h⁻¹) only fresh air" data-has-radio="#air_type_changes"><br>
</div>
<div id="DIVnatural_ventilation" style="display:none">
@ -98,7 +98,7 @@
<label for="hepa_no">No</label>&nbsp;&nbsp;
<input type="radio" id="hepa_yes" name="hepa_option" value=1 onclick="require_fields(this)">
<label for="hepa_yes">Yes</label>&nbsp;&nbsp;
<input type="number" step="any" id="hepa_amount" class="non_zero has_radio disabled" name="hepa_amount" placeholder="(m³ / hour)" min="0">
<input type="number" step="any" id="hepa_amount" class="non_zero disabled" name="hepa_amount" placeholder="(m³ / hour)" min="0" data-has-radio="#hepa_yes">
<hr width="80%">
<b>Face masks:</b>
@ -154,10 +154,10 @@
<input type="radio" id="event_type_single" name="event_type" value="single_event" onclick="require_fields(this)" tabindex="-1" required>
<label for="event_type_single">Single event</label> &nbsp;&nbsp;
<label for="event_type_single">Date: </label>
<input type="text" id="single_event_date" class="datepicker has_radio" name="single_event_date" placeholder="dd/mm/yyyy"><br>
<input type="text" id="single_event_date" class="datepicker" name="single_event_date" placeholder="dd/mm/yyyy" data-has-radio="#event_type_single"><br>
<input type="radio" id="event_type_recurrent" name="event_type" value="recurrent_event" onclick="require_fields(this)" tabindex="-1" required>
<label for="event_type_recurrent">Recurrent usage</label>
<select id="recurrent_event_month" name="recurrent_event_month" class="has_radio" >
<select id="recurrent_event_month" name="recurrent_event_month" data-has-radio="#event_type_recurrent">
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>