new holder("holder_990x90_44",{ block:4244 });
$(document).ready(function () { $('.copyrigt a').css('display', 'block'); $.post("/misc/view.php", {struct_id: "77056"}); var struct = "77056"; if (struct == 47917) { $('p a').each(function () { var href = $(this).attr('href'); $(this).attr('href', "https://platfor.ma" + href) }); } if ($('.img-ilusion').length > 0) { var innerW = $(document).innerWidth(); var postWrp = parseInt($('.post-wrapper').css('padding-left')); var postWrpR = parseInt($('.post-wrapper').css('padding-right')); $('.img-ilusion').each(function () { setTimeout(400); var img_h = $(this).find("img").height(); if (img_h >= 199) { var imgWidth = $(this).find("img").width(); var res1 = imgWidth + postWrp + postWrpR; var res2 = (innerW - res1) / 2; $(this).width(innerW); $(this).css('margin-left', -(res2 + postWrp)); } /* $(this).find("img").load(function(){ var imgWidth = $(this).width(); var res1 = imgWidth + postWrp + postWrpR; var res2 = (innerW-res1)/2; $(this).parents('.img-ilusion').width(innerW); $(this).parents('.img-ilusion').css('margin-left',-(res2+postWrp)); });*/ }); } }); $(document).ready(function () { // console.log(1); var questions = getObjFromJSON(localStorage.getItem('questions_77053')); // console.log('questions: ' + questions); var answers = JSON.parse('[]'); // console.log('answers: ' + answers); var max_scores = getObjFromJSON(localStorage.getItem('max_scores_77053')); // console.log('max_scores: ' + max_scores); // console.log('results: ' + localStorage.getItem('results_77053')); var results = getObjFromJSON(localStorage.getItem('results_77053')); // console.log('results: ' + results); var first_page_link = jQuery.parseJSON(localStorage.getItem('first_page_link_77053')); var current_question = parseInt(''); var count_questions = parseInt(''); var sum = 0; var show_correct = '0'; var right_answers = []; var input_type = 'checkbox'; var img_button = ''; //console.log('sum: ' + sum); $.each(questions, function (index, question) { if (localStorage.getItem(question.struct_id) > 0) { sum = parseInt(localStorage.getItem(question.struct_id)) + parseInt(sum); } }); if (localStorage.getItem('77056')) { $("input").attr('disabled', 'disabled'); } // console.log(sum + 'sum'); //console.log(max_scores); $('#score span').first().append(sum); $('#score span').last().append(max_scores); $('#button a').attr('disabled', true); $('#button a').removeClass('bg_yellow'); $('#button a').addClass('bg_grey'); $(answers).each(function (index, answer) { var is_right = answer.dot_top; if (is_right == 1) { right_answers.push(answer.struct_id); } }); if (show_correct == 1) { showRightAnswer(); } else { hideRightAnswer(); } disableButton(); function showRightAnswer() { $('#button a').empty(); $('#button a').append('показати відповідь' + img_button); reverseClassButton(); $('#button a').on("click", function (event) { var disabled = $(this).attr("disabled"); if (disabled) { return false; } else { textInButtonNext(); if ($("input").attr('disabled') != 'disabled') { var this_sum = getScore(); localStorage.setItem('77056', this_sum); } $("input").attr('disabled', 'disabled'); if ($("#button a").attr('next') == 'go') { showResult(localStorage.getItem('77056')); } if ($("#button a").attr('next') != 'go') { event.preventDefault(); $(answers).each(function (index, answer) { var is_right = answer.dot_top; // if (is_right == 1) { var answer_html = $("div.data-id" + answer.struct_id).html(); // console.log(answer_html); // console.log('{ANSWER_TEXT_' + answer.struct_id + '}'); if (answer.sub_img) { if (input_type == 'radio') { $('.test__img').attr("src", answer.sub_img); } else { $('[for="' + answer.struct_id + '"] div').append(''); } } $('[for="' + answer.struct_id + '"] div').append(answer_html); // } }); $("#button a").attr('next', 'go'); } } }); } function hideRightAnswer() { textInButtonNext(); reverseClassButton(); $('#button a').on("click", function (e) { var disabled = $(this).attr("disabled"); if (disabled) { return false; } else { if($(this).attr('data-result')==1){ var checked_input = $('input[type="checkbox"]:checked').val(); $(answers).each(function (index, answer) { if (answer.struct_id == checked_input) { localStorage.setItem('77056', answer.dot_left); } }); showResultCh(); //e.preventDefault(); }else{ var this_sum = getScore(); localStorage.setItem('77056', this_sum); showResult(this_sum); } } }); } function showResultCh() { if (current_question == count_questions) { var data = []; var data_dir = []; $(results).each(function (index, result) { data[result.struct_id]=0; data_dir[result.struct_id]=result.dir; }); $(questions).each(function (index, result) { data[localStorage.getItem(result.struct_id)] = data[localStorage.getItem(result.struct_id)] + 1; }); var struct = [0,0]; data.forEach(function(el, i){ if (el > struct[1]) { struct[1] = el; struct[0] = i; } }); var link = first_page_link + data_dir[struct[0]] + '#legend'; $("#button a").attr("href", link); } } function showResult(this_sum) { if (current_question == count_questions) { sum = parseInt(sum) + parseInt(this_sum); $(results).each(function (index, result) { var result_from = parseInt(result.dot_top); var result_to = parseInt(result.dot_left); // alert(result_from + ' : ' + sum + ' : ' + result_to); if (sum <= result_to && result_from <= sum) { link = first_page_link + result.dir + '#legend'; $("#button a").attr("href", link); } }); } } function getScore() { var this_sum = 0; var checked_input = $('input[type="checkbox"]:checked').map(function () { return this.value; }).get(); $.each(right_answers, function (index, right_struct) { $('#' + right_struct + "").attr('name', '' + right_struct); $("#" + right_struct + "").attr('checked', 'checked'); $('[for="' + right_struct + '"]').addClass('green'); $.each(checked_input, function (index, struct_id) { if (struct_id != right_struct) { $('#' + struct_id + "").attr('name', '' + struct_id); $("#" + struct_id + "").attr('checked', 'checked'); $('[for="' + struct_id + '"]').addClass('red'); } else { $(answers).each(function (index, answer) { if (answer.struct_id == struct_id) { this_sum = parseInt(answer.dot_left) + parseInt(this_sum); } }); } }); }); return this_sum; } function disableButton() { $('#button a').on("click", function () { var disabled = $(this).attr("disabled"); if (disabled) { return false; } }); } function reverseClassButton() { $(answers).each(function (index, answer) { $("#" + answer.struct_id).click(function () { var checked = $("input:" + input_type + ":checked"); if (checked.length > 0) { $('#button a').attr('disabled', false); $('#button a').removeClass('bg_grey'); $('#button a').addClass('bg_yellow'); } else { $('#button a').attr('disabled', true); $('#button a').removeClass('bg_yellow'); $('#button a').addClass('bg_grey'); } }); }); } function textInButtonNext() { $('#button a').empty(); $('#button a').append('ВПЕРЕД' + img_button); if (current_question == count_questions) { $('#button a').empty(); $('#button a').append('переглянути результат' + img_button); } } });
Лодзь