$(document).ready(function () {
$('.copyrigt a').css('display', 'block');
$.post("/misc/view.php", {struct_id: "76381"});
var struct = "76381";
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_75955'));
// console.log('questions: ' + questions);
var answers = JSON.parse('[{"title":"\u042d\u0442\u043e\u0433\u043e \u0435\u0449\u0435 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e! \u0441\u0434\u0435\u043b\u0430\u044e \u0432\u0438\u0434, \u0447\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0435\u0433\u043e \u0438 \u043f\u0440\u043e\u0439\u0434\u0443 \u043c\u0438\u043c\u043e.","annot":"\u042d\u0442\u043e\u0433\u043e \u0435\u0449\u0435 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e! \u0441\u0434\u0435\u043b\u0430\u044e \u0432\u0438\u0434, \u0447\u0442\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b \u0435\u0433\u043e \u0438 \u043f\u0440\u043e\u0439\u0434\u0443 \u043c\u0438\u043c\u043e.","bodytext":"","img_src1":"","img_src2":"","dot_top":"1","dot_left":"75959","struct_id":"76383","copy_id":"","on_page2":"0","struct_name":"\u042d\u0442\u043e\u0433\u043e \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e","dir":"etogo-ne-khvatalo","num":"50","parent_id":"76381","parents":"","smark":"","date_end":"0000-00-00 00:00:00","date_format":"1466505266","date_change_format":"1466507262","date_start_format":"1466505179","id":"76383"},{"title":"\u041a\u0440\u0438\u043a\u043d\u0443: \u00ab\u0414\u0440\u0443\u0436\u0438\u0449\u0435! \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442!\u00bb, \u2013 \u0438 \u0431\u0440\u043e\u0448\u0443\u0441\u044c \u0433\u043e\u0440\u044f\u0447\u043e \u0435\u0433\u043e \u0442\u0438\u0441\u043a\u0430\u0442\u044c.","annot":"\u041a\u0440\u0438\u043a\u043d\u0443: \u00ab\u0414\u0440\u0443\u0436\u0438\u0449\u0435! \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043b\u0435\u0442!\u00bb, \u2013 \u0438 \u0431\u0440\u043e\u0448\u0443\u0441\u044c \u0433\u043e\u0440\u044f\u0447\u043e \u0435\u0433\u043e \u0442\u0438\u0441\u043a\u0430\u0442\u044c.","bodytext":"","img_src1":"","img_src2":"","dot_top":"1","dot_left":"75960","struct_id":"76384","copy_id":"","on_page2":"0","struct_name":"\u0414\u0440\u0443\u0436\u0438\u0449\u0435","dir":"druzhishche","num":"50","parent_id":"76381","parents":"","smark":"","date_end":"0000-00-00 00:00:00","date_format":"1466505307","date_change_format":"1466507289","date_start_format":"1466505272","id":"76384"},{"title":"\u041e\u0442\u043d\u0435\u0441\u0443\u0441\u044c \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0437\u043c\u0430, \u043d\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0440\u0438\u0433\u043b\u0430\u0441\u0438\u0442 \u0432\u044b\u043f\u0438\u0442\u044c \u0441\u0442\u0430\u043a\u0430\u043d\u0447\u0438\u043a-\u0434\u0440\u0443\u0433\u043e\u0439 \u2013 \u043f\u043e\u0439\u0434\u0443. \u042d\u0442\u043e \u0432\u0435\u0434\u044c \u0437\u0430 \u0435\u0433\u043e \u0441\u0447\u0435\u0442, \u0432\u0435\u0440\u043d\u043e?","annot":"\u041e\u0442\u043d\u0435\u0441\u0443\u0441\u044c \u0431\u0435\u0437 \u043e\u0441\u043e\u0431\u043e\u0433\u043e \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0437\u043c\u0430, \u043d\u043e \u0435\u0441\u043b\u0438 \u043e\u043d \u043f\u0440\u0438\u0433\u043b\u0430\u0441\u0438\u0442 \u0432\u044b\u043f\u0438\u0442\u044c \u0441\u0442\u0430\u043a\u0430\u043d\u0447\u0438\u043a-\u0434\u0440\u0443\u0433\u043e\u0439 \u2013 \u043f\u043e\u0439\u0434\u0443. \u042d\u0442\u043e \u0432\u0435\u0434\u044c \u0437\u0430 \u0435\u0433\u043e \u0441\u0447\u0435\u0442, \u0432\u0435\u0440\u043d\u043e?","bodytext":"","img_src1":"","img_src2":"","dot_top":"1","dot_left":"75957","struct_id":"76385","copy_id":"","on_page2":"0","struct_name":"\u041e\u0442\u043d\u0435\u0441\u0443\u0441\u044c \u0431\u0435\u0437 \u044d\u043d\u0442\u0443\u0437\u0438\u0430\u0437\u043c\u0430","dir":"otnesus-bez-entuziazma","num":"50","parent_id":"76381","parents":"","smark":"","date_end":"0000-00-00 00:00:00","date_format":"1466505345","date_change_format":"1466507281","date_start_format":"1466505317","id":"76385"},{"title":"\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044f \u0434\u0430\u0436\u0435 \u043d\u0435 \u0443\u0437\u043d\u0430\u044e \u0435\u0433\u043e \u2013 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0448\u043b\u043e, \u0432\u043e\u0434\u044b \u0443\u0442\u0435\u043a\u043b\u043e, \u043b\u0435\u0442 \u043f\u0440\u043e\u043b\u0435\u0442\u0435\u043b\u043e\u2026 \u041d\u0443, \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438.","annot":"\u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e \u044f \u0434\u0430\u0436\u0435 \u043d\u0435 \u0443\u0437\u043d\u0430\u044e \u0435\u0433\u043e \u2013 \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0448\u043b\u043e, \u0432\u043e\u0434\u044b \u0443\u0442\u0435\u043a\u043b\u043e, \u043b\u0435\u0442 \u043f\u0440\u043e\u043b\u0435\u0442\u0435\u043b\u043e\u2026 \u041d\u0443, \u0432\u044b \u043f\u043e\u043d\u044f\u043b\u0438.","bodytext":"","img_src1":"","img_src2":"","dot_top":"1","dot_left":"75958","struct_id":"76386","copy_id":"","on_page2":"0","struct_name":"\u041d\u0435 \u0443\u0437\u043d\u0430\u044e \u0435\u0433\u043e","dir":"ne-uznayu-ego","num":"50","parent_id":"76381","parents":"","smark":"","date_end":"0000-00-00 00:00:00","date_format":"1466505393","date_change_format":"1466507272","date_start_format":"1466505360","id":"76386"}]');
// console.log('answers: ' + answers);
var max_scores = getObjFromJSON(localStorage.getItem('max_scores_75955'));
// console.log('max_scores: ' + max_scores);
// console.log('results: ' + localStorage.getItem('results_75955'));
var results = getObjFromJSON(localStorage.getItem('results_75955'));
// console.log('results: ' + results);
var first_page_link = jQuery.parseJSON(localStorage.getItem('first_page_link_75955'));
var current_question = parseInt('7');
var count_questions = parseInt('11');
var sum = 0;
var show_correct = '0';
var right_answers = [];
var input_type = 'radio';
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('76381')) {
$("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('76381', this_sum);
}
$("input").attr('disabled', 'disabled');
if ($("#button a").attr('next') == 'go') {
showResult(localStorage.getItem('76381'));
}
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="radio"]:checked').val();
$(answers).each(function (index, answer) {
if (answer.struct_id == checked_input) {
localStorage.setItem('76381', answer.dot_left);
}
});
showResultCh();
//e.preventDefault();
}else{
var this_sum = getScore();
localStorage.setItem('76381', 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="radio"]: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);
}
}
});