I built a form that checks for filled or empty input values, and then it adds progress to the circle. As it stands, I'm getting a call stack error due to the amount of calls that the functions receive. The library that I'm using for the circle-progress bar is called JQuery-Circle-Progress. How can I re-write my function(s) to avoid getting a callstack error while checking for input values?
I tried to combine the functions that check for empty and nil strings, but they stopped working after I made the changes, and the error is still occurring. The answers that are posted on stackoverflow for similar questions, didn't address the fact that I am working with many inputs with different ids. I cannot use the array method, since all of the ids are for unique attributes. Otherwise, I would iterate over one array of inputs and easily pickup the changes in value. In the documentation for this jquery-library, I don't see how you can add progress to the progress circle without redrawing it.
let test_form_progress_value = 0;
$('.test-progress.circle-2').circleProgress({
animation: {duration: 2000},
fill: {color: '#fdba04'},
value: 0.0,
size: 150,
startAngle: -Math.PI / 2,
animationStartValue: 0,
stepValue: test_form_progress_value
}).on('circle-animation-progress', function (event, progress) {
$('#test_form_id').bind('blur', function () {
$('.test-progress.circle-2').circleProgress({value: test_form_progress_value += 0.001});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
});
$('#test_form_id').bind('blur', function () {
if ($('#test_form_id').val() == '') {
$('.test-progress.circle-2').circleProgress({value: test_form_progress_value -= 0.001});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
}
});
$('#test_form_username').bind('blur', function () {
$('.test-progress.circle-2').circleProgress({value: test_form_progress_value += 0.001});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
});
$('#test_form_username').bind('blur', function () {
if ($('#test_form_username').val() == '') {
$('.test-progress.circle-2').circleProgress({value: test_form_progress_value -= 0.001});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
}
});
$('#test_form_password').bind('blur', function () {
$('.test-progress.circle-2').circleProgress({value: test_form_progress_value += 0.001});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
});
$('#test_form_password').bind('blur', function () {
if ($('#test_form_password').val() == '') {
$('.test-progress.circle-2').circleProgress({value: test_form_progress_value -= 0.001});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
}
});
$('#test_form_movie_review').bind('blur', function () {
$('.test-progress.circle-2').circleProgress({value: test_form_progress_value += 0.001});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
});
$('#test_form_movie_name').bind('blur', function () {
if ($('#test_form_movie_name').val() == '') {
$('.test-progress.circle-2').circleProgress({value: test_form_progress_value -= 0.001});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
}
});
$(this).find('strong').html(Math.ceil((test_form_progress_value * 83)) + '<i>%</i>');
});
$('.test-progress.circle-2').circleProgress({
fill: {color: '#fdba04'},
value: 0.0,
size: 150,
startAngle: -Math.PI / 2,
animationStartValue: 0,
stepValue: test_form_progress_value
}).on('circle-animation-end', function (event) {
if ($('.test-progress.circle-2').circleProgress('value') === 0) {
$('.test-progress.circle-2').circleProgress({value: 0});
$('.test-progress.circle-2').circleProgress('redraw');
$('.test-progress.circle-2').circleProgress();
$('.test-progress.circle-2').circleProgress({size: 150});
}
});
Expected results: I should see the progression bar moving without any Maximum call stack size exceeded errors.
Actual results: The progression bar moves, but fails midway, due to the callstack error.