2021-12-11 19:32:22 +01:00
|
|
|
"use strict";
|
|
|
|
|
2021-11-24 13:24:03 +01:00
|
|
|
if (!$) {
|
2021-12-11 19:32:22 +01:00
|
|
|
// $ = django.jQuery;
|
|
|
|
const $ = django.jQuery;
|
2021-11-24 13:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$(function(){
|
|
|
|
|
2021-12-11 19:32:22 +01:00
|
|
|
$('#id_is_competitive').prop("checked", true);
|
|
|
|
|
|
|
|
$('#id_long_label').keyup(function(){
|
|
|
|
$('#id_short_label').val($('#id_long_label').val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id_rotation_type').keyup(function(){
|
|
|
|
var rotation_type = parseInt($('#id_rotation_type').children(':selected').val());
|
|
|
|
if(rotation_type == 0) {
|
|
|
|
$('#id_rotation').val('0');
|
|
|
|
$('#id_position').val('/');
|
|
|
|
$('id_twist').focus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id_rotation, #id_twist').keyup(function(){
|
|
|
|
setDifficulty();
|
|
|
|
setLevel();
|
|
|
|
setNotation();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id_position').change(function(){
|
|
|
|
setDifficulty();
|
|
|
|
setLevel();
|
|
|
|
setNotation();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id_rotation_type').change(function(){
|
|
|
|
setNotation();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#difficulty').change(function(){
|
|
|
|
setLevel();
|
2021-11-24 13:24:03 +01:00
|
|
|
});
|
|
|
|
|
2021-12-11 19:32:22 +01:00
|
|
|
$('#id_level').keyup(function(){
|
|
|
|
$('#id_rank').val($('#id_level').val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id_notation').keyup(function(){
|
|
|
|
$('#id_simplyNotation').val($('#id_notation').val());
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#id_age_boy').keyup(function(){
|
|
|
|
$('#id_age_girl').val($('#id_age_boy').val());
|
|
|
|
});
|
|
|
|
|
|
|
|
const setDifficulty = function()
|
|
|
|
{
|
|
|
|
var sum = 0;
|
|
|
|
if(typeof($('#id_rotation').val()) !== "undefined" && $('#id_rotation').val() != "") {
|
|
|
|
// calcul de base
|
|
|
|
var nb_rotation = parseInt($('#id_rotation').val());
|
|
|
|
sum = nb_rotation;
|
|
|
|
|
|
|
|
// calcul des boni
|
|
|
|
sum += Math.floor(nb_rotation/4); /* Bonus pour les saltos simple */
|
|
|
|
sum += Math.floor(nb_rotation/12); /* Bonus pour un triple */
|
|
|
|
sum += Math.floor(nb_rotation/16); /* Bonus pour un quadruple */
|
|
|
|
|
|
|
|
/* pour les simples SANS vrille ou les multiples */
|
|
|
|
if ((nb_rotation != 4) && ((typeof($('#id_twist').val()) !== "undefined") || ($('#id_twist').val() != '') || (parseInt($('#id_twist').val()) != 0)))
|
|
|
|
/* Bonus de position */
|
|
|
|
if($('#id_position').val() == '/' || $('#id_position').val() == '<' || $('#id_position').val() == 'L')
|
|
|
|
sum += Math.floor(nb_rotation/4);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(typeof($('#id_twist').val()) !== "undefined" && $('#id_twist').val() != '')
|
|
|
|
sum += parseInt($('#id_twist').val());
|
|
|
|
|
|
|
|
$('#id_difficulty').val((sum/10).toFixed(1));
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const setLevel = function()
|
|
|
|
{
|
|
|
|
var difficulty = 0;
|
|
|
|
|
|
|
|
if(typeof($('#id_difficulty').val()) !== "undefined" && $('#id_difficulty').val() != '') {
|
|
|
|
difficulty = (parseFloat($('#id_difficulty').val())) * 10;
|
|
|
|
|
|
|
|
if($('#id_position').val() == '/')
|
|
|
|
difficulty += 1;
|
|
|
|
|
|
|
|
$('#id_level').val(difficulty);
|
|
|
|
$('#id_rank').val(difficulty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const setNotation = function()
|
|
|
|
{
|
|
|
|
var rotation_type = parseInt($('#id_rotation_type').children(':selected').val());
|
|
|
|
var nb_rotation = parseInt($('#id_rotation').val());
|
|
|
|
var nb_twist = parseInt($('#id_twist').val());
|
|
|
|
var txt = '';
|
|
|
|
|
|
|
|
if((rotation_type.length != 0) && (rotation_type != 0) && (nb_rotation != 0) && !isNaN(nb_rotation)) {
|
|
|
|
if(rotation_type == 1)
|
|
|
|
txt += '.' + nb_rotation;
|
|
|
|
else
|
|
|
|
txt += nb_rotation + '.';
|
|
|
|
|
|
|
|
txt += ' ';
|
|
|
|
|
|
|
|
if(nb_twist != 0) {
|
|
|
|
var size = Math.ceil(nb_rotation/4);
|
|
|
|
alert(size);
|
|
|
|
var temp = new Array(size);
|
|
|
|
var digit = Math.floor(nb_twist/size);
|
|
|
|
var rest = (size - (nb_twist % size)) - 1;
|
|
|
|
|
|
|
|
for(var i = 0; i < size; i++)
|
|
|
|
if(i > rest)
|
|
|
|
temp[i] = digit + 1;
|
|
|
|
else
|
|
|
|
temp[i] = (digit == 0) ? '-' : digit;
|
|
|
|
|
|
|
|
txt += temp.join("");
|
|
|
|
} else
|
|
|
|
for(var i = 1; i <= Math.ceil(nb_rotation/4); i++)
|
|
|
|
txt += '-';
|
|
|
|
|
|
|
|
if($('#id_position option:selected').val() != 0)
|
|
|
|
txt += ' ' + $('#id_position option:selected').val();
|
|
|
|
|
|
|
|
$('#id_notation').val(txt);
|
|
|
|
$('#id_simplified_notation').val(txt);
|
|
|
|
} else {
|
|
|
|
$('#id_notation').val('-');
|
|
|
|
$('#id_simplified_notation').val('-');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// $('#position, #arrivalid').change(function(){
|
|
|
|
// var position = $('#position option:selected').val();
|
|
|
|
|
|
|
|
// // Création du nom long
|
|
|
|
// // var txt = $('#figureid option:selected').attr('longLabel');
|
|
|
|
// var txt = $('#savedLongLabel').val();
|
|
|
|
// if((position.length != 0) && (position != "NULL"))
|
|
|
|
// txt += ' '+$('#position option:selected').attr('data-longLabel');
|
|
|
|
|
|
|
|
// // $('#arrivalid').children(':selected') // plus rapide
|
|
|
|
// if($('#arrivalid option:selected').attr('data-shortLabel') != "Debout")
|
|
|
|
// txt += ', '+$('#arrivalid option:selected').attr('data-longLabel');
|
|
|
|
|
|
|
|
// $('#longLabel').val(txt);
|
|
|
|
|
|
|
|
|
|
|
|
// // Création du nom court
|
|
|
|
// // txt = $('#figureid option:selected').attr('shortLabel');
|
|
|
|
// txt = $('#savedShortLabel').val();
|
|
|
|
// if((position.length != 0) && (position != "NULL"))
|
|
|
|
// txt += ' '+$('#position option:selected').attr('data-shortLabel');
|
|
|
|
|
|
|
|
// if($('#arrivalid option:selected').attr('data-shortLabel') != "Debout")
|
|
|
|
// txt += ', '+$('#arrivalid option:selected').attr('data-shortLabel');
|
|
|
|
|
|
|
|
// $('#shortLabel').val(txt);
|
|
|
|
|
|
|
|
// setNotation();
|
|
|
|
// setDifficulty();
|
|
|
|
// setLevel();
|
|
|
|
// });
|
|
|
|
|
|
|
|
// $('#arrivalid').change(function(){
|
|
|
|
// if($('#arrivalid option:selected').attr('competition') == 0)
|
|
|
|
// $('#divCompetition').addClass("hide");
|
|
|
|
// else
|
|
|
|
// $('#divCompetition').removeClass("hide");
|
|
|
|
// });
|
|
|
|
|
2021-11-24 13:24:03 +01:00
|
|
|
});
|