<script>
$( document ).ready(function() {
let linkObj = {
'A': '/page-a',
'B': '/page-b',
'C': '/page-c',
'D': '/page-d',
'E': '/page-e',
};
$('.uc-main-test .t-input-group_rd').each(function(){
let rd = $(this);
rd.find('.t-radio:eq(0)').attr('data-symbol', 'A');
rd.find('.t-radio:eq(1)').attr('data-symbol', 'B');
rd.find('.t-radio:eq(2)').attr('data-symbol', 'C');
rd.find('.t-radio:eq(3)').attr('data-symbol', 'D');
rd.find('.t-radio:eq(4)').attr('data-symbol', 'E');
});
$('.uc-main-test').on('click', '.t835__btn_result' , function(){
$('.uc-main-test .t835__btn-wrapper').hide();
$('.uc-main-test .t-form__submit').hide();
$('.uc-main-test .t835__quiz-form-wrapper').addClass('loader');
let main = $('.uc-main-test');
let letterArr = [];
main.find('.t-radio:checked').each(function(){
let letter = $(this).attr('data-symbol');
letterArr.push(letter);
});
let counts = {}, max = 0, res;
for (let v in letterArr) {
counts[letterArr[v]] = (counts[letterArr[v]] || 0) + 1;
if (counts[letterArr[v]] > max) {
max = counts[letterArr[v]];
res = letterArr[v];
}
}
let results = [];
for (let k in counts){
if (counts[k] == max){
results.push(k);
}
};
setTimeout(function () {
window.location.href = linkObj[results[0]];
}, 2000);
});
});
</script>
<style>
.uc-main-test .t835__quiz-form-wrapper.loader {
background-image: url(https://static.tildacdn.com/tild3963-6130-4236-b331-313734363933/loading.gif);
background-size: 45px;
background-repeat: no-repeat;
background-position: center;
margin-top: 45px;
}
</style>