Update JS script
This commit is contained in:
parent
6b43ed7bc1
commit
1fe9e31066
|
@ -14,7 +14,7 @@
|
|||
{% csrf_token %}
|
||||
<div class="form-group row ">
|
||||
<label for="id_gymnast" class="col-4 col-sm-3 col-md-4 col-lg-4 col-xl-3 col-form-label">Gymnast <span class="text-danger"><b>*</b></span></label>
|
||||
<div class="col-8 col-sm-9 col-md-8 col-lg-8 col-lg-8 col-xl-9 {% if form.gymnast.errors %}has-danger{% endif %}">
|
||||
<div class="col-8 col-sm-9 col-md-8 col-lg-8 col-lg-8 col-xl-6 {% if form.gymnast.errors %}has-danger{% endif %}">
|
||||
{% if request.user|has_group:"trainer" %}
|
||||
{{ form.gymnast }}
|
||||
{{ form.gymnast_related }}
|
||||
|
@ -38,7 +38,7 @@
|
|||
</div>
|
||||
<div class="form-group row ">
|
||||
<label for="id_event" class="col-4 col-sm-3 col-md-4 col-lg-4 col-xl-3 col-form-label">Event</label>
|
||||
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-9 {% if form.date.errors %}has-danger{% endif %}">
|
||||
<div class="col-8 col-sm-8 col-md-8 col-lg-8 col-xl-6 {% if form.date.errors %}has-danger{% endif %}">
|
||||
{{ form.event }}
|
||||
{{ form.event_related }}
|
||||
{% if form.eventt.errors %}
|
||||
|
@ -122,78 +122,79 @@
|
|||
{% endblock %}
|
||||
|
||||
{% block footerscript %}
|
||||
<script type="text/javascript" >
|
||||
$().ready(function(){
|
||||
$("#note_info").hide();
|
||||
$("#span_info_required").hide();
|
||||
<script type="text/javascript" >
|
||||
$().ready(function(){
|
||||
$("#note_info").hide();
|
||||
$("#span_info_required").hide();
|
||||
|
||||
function are_informations_too_short()
|
||||
{
|
||||
if($('#id_informations').val().length < 10)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
function are_informations_too_short()
|
||||
{
|
||||
if($('#id_informations').val().length < 10)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
|
||||
function check_form_values()
|
||||
{
|
||||
var test = is_value_lower($('#id_mindstate').val());
|
||||
test = test || is_value_lower($('#id_sleep').val());
|
||||
test = test || is_value_upper($('#id_stress').val());
|
||||
test = test || is_value_upper($('#id_fatigue').val());
|
||||
test = test || is_value_upper($('#id_muscle_soreness').val());
|
||||
return test
|
||||
}
|
||||
|
||||
function is_value_lower(value)
|
||||
{
|
||||
if(value <= 5)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
};
|
||||
|
||||
function is_value_upper(value)
|
||||
{
|
||||
if(value >= 5)
|
||||
return true
|
||||
else
|
||||
return false
|
||||
};
|
||||
|
||||
$('#id_mindstate, #id_sleep, #id_stress, #id_fatigue, #id_muscle_soreness').on('change', function(){
|
||||
test = check_form_values();
|
||||
|
||||
if(test) {
|
||||
$("#note_info").show();
|
||||
$("#span_info_required").show();
|
||||
} else {
|
||||
$("#note_info").hide();
|
||||
$("#span_info_required").hide();
|
||||
function check_form_values()
|
||||
{
|
||||
var test = is_value_lower($('#id_mindstate').val());
|
||||
test = test || is_value_lower($('#id_sleep').val());
|
||||
test = test || is_value_upper($('#id_stress').val());
|
||||
test = test || is_value_upper($('#id_fatigue').val());
|
||||
test = test || is_value_upper($('#id_muscle_soreness').val());
|
||||
return test
|
||||
}
|
||||
|
||||
function is_value_lower(value)
|
||||
{
|
||||
if(value != '')
|
||||
if(value <= 5)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
|
||||
function is_value_upper(value)
|
||||
{
|
||||
if(value != '')
|
||||
if(value >= 5)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
};
|
||||
|
||||
$('#id_mindstate, #id_sleep, #id_stress, #id_fatigue, #id_muscle_soreness').on('keyup', function(){
|
||||
test = check_form_values();
|
||||
|
||||
if(test) {
|
||||
$("#note_info").show();
|
||||
$("#span_info_required").show();
|
||||
} else {
|
||||
$("#note_info").hide();
|
||||
$("#span_info_required").hide();
|
||||
}
|
||||
});
|
||||
|
||||
$('#id_informations').on('keyup', function(){
|
||||
test = check_form_values();
|
||||
test = test && are_informations_too_short()
|
||||
|
||||
if(test)
|
||||
$("#note_info").show();
|
||||
else
|
||||
$("#note_info").hide();
|
||||
});
|
||||
|
||||
const csrf_token = "{{ csrf_token|escapejs }}";
|
||||
const event_lookup = "{% url 'event_lookup' %}";
|
||||
const gymnast_lookup = "{% url 'gymnast_lookup' %}";
|
||||
});
|
||||
|
||||
$('#id_informations').on("keyup", function(){
|
||||
test = check_form_values();
|
||||
|
||||
test = test && are_informations_too_short()
|
||||
|
||||
if(test)
|
||||
$("#note_info").show();
|
||||
else
|
||||
$("#note_info").hide();
|
||||
});
|
||||
|
||||
const csrf_token = "{{ csrf_token|escapejs }}";
|
||||
const gymnast_lookup = "{% url 'gymnast_lookup' %}";
|
||||
const event_lookup = "{% url 'event_lookup' %}";
|
||||
});
|
||||
</script>
|
||||
{% if request.session.template == 0 %}
|
||||
<script src="{% static "js/template_users/gymnast_autocomplete_black.js" %}"></script>
|
||||
<script src="{% static "js/template_users/event_autocomplete_black.js" %}"></script>
|
||||
{% else %}
|
||||
<script src="{% static "js/template_users/gymnast_autocomplete.js" %}"></script>
|
||||
<script src="{% static "js/template_users/event_autocomplete.js" %}"></script>
|
||||
{% endif %}
|
||||
</script>
|
||||
{% if request.session.template == 0 %}
|
||||
<script src="{% static "js/template_users/gymnast_autocomplete_black.js" %}"></script>
|
||||
<script src="{% static "js/template_users/event_autocomplete_black.js" %}"></script>
|
||||
{% else %}
|
||||
<script src="{% static "js/template_users/gymnast_autocomplete.js" %}"></script>
|
||||
<script src="{% static "js/template_users/event_autocomplete.js" %}"></script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
Loading…
Reference in New Issue