Тест на этой странице
http://mezhdunami.primaxdigital.ru/infection-test/
Вот весь код
$("document").ready(function(){
//reload
$("#refresh").click(function () {
step1 = "";
step2 = "";
step3 = "";
step4 = "";
step5 = "";
$("#name1").text('');
$("#name2").text('');
$("#name3").text('');
$("#name4").text('');
$("#name5").text('');
$(":radio[name='step1']:checked").removeAttr("checked");
$(":radio[name='step2']:checked").removeAttr("checked");
$(":radio[name='step3']:checked").removeAttr("checked");
$(":radio[name='step4']:checked").removeAttr("checked");
$(":radio[name='step5']:checked").removeAttr("checked");
$(".step-box1").animate(
{
opacity: "show",
height: "show"
},
500);
$(".result").animate(
{
opacity: "hide",
height: "hide"
},
500);
});
$("#go_test").click(function () {
$(".p_test").animate(
{
opacity: "hide",
height: "hide"
},
0);
$("#test_v").animate(
{
opacity: "show",
height: "show"
},
500);
$(".step-box1").animate(
{
opacity: "show",
height: "show"
},
500);
});
var m1 = [[1],[1,2],[1],[1],[1]];
var m2 = [[2],[1, 4],[4],[1, 2, 3],[2, 3, 4]];
var m3 = [[1, 2],[1, 3],[1, 3, 5],[3, 4],[1]];
var m4 = [[2],[4, 5],[2],[3],[2, 3, 4]];
function fn(a, b) {
return a.every(function(a, i) {
return a.some(function(a) {
return a == b[i]
})
})
};
$(":radio[name='step1']").change(function() {
step1 = $(":radio[name='step1']:checked").val();
$("#name1").text($(":radio[name='step1']:checked").next().text());
});
$(":radio[name='step2']").change(function() {
step2 = $(":radio[name='step2']:checked").val();
$("#name2").text($(":radio[name='step2']:checked").next().text());
});
$(":radio[name='step3']").change(function() {
step3 = $(":radio[name='step3']:checked").val();
$("#name3").text($(":radio[name='step3']:checked").next().text());
});
$(":radio[name='step4']").change(function() {
step4 = $(":radio[name='step4']:checked").val();
$("#name4").text($(":radio[name='step4']:checked").next().text());
});
$(":radio[name='step5']").change(function() {
step5 = $(":radio[name='step5']:checked").val();
$("#name5").text($(":radio[name='step5']:checked").next().text());
});
//step 1
$("#nextbutton1").click(function () {
if (step1 != "" ) {
$(".step-box1").animate(
{
opacity: "hide",
height: "hide"
},
500);
$(".step-box2").animate(
{
opacity: "show",
height: "show"
},
500);
}
});
//step 2
$("#nextbutton2").click(function () {
if (step2 != "" ) {
$(".step-box2").animate(
{
opacity: "hide",
height: "hide"
},
500);
$(".step-box3").animate(
{
opacity: "show",
height: "show"
},
500);
}
});
//step 3
$("#nextbutton3").click(function () {
if (step3 != "" ) {
$(".step-box3").animate(
{
opacity: "hide",
height: "hide"
},
500);
$(".step-box4").animate(
{
opacity: "show",
height: "show"
},
500);
}
});
//step 4
$("#nextbutton4").click(function () {
if (step4 != "" ) {
$(".step-box4").animate(
{
opacity: "hide",
height: "hide"
},
500);
$(".step-box5").animate(
{
opacity: "show",
height: "show"
},
500);
}
});
//result
$("#resultbutton").click(function () {
if (step5 != "" ) {
$(".step-box5").animate(
{
opacity: "hide",
height: "hide"
},
500);
$(".result").animate(
{
opacity: "show",
height: "show"
},
500);
$(".result").text();
step_array = new Array(step1,step2,step3,step4,step5);
if (fn(m1,step_array) == true) {
$(".result1").css('display', 'block');
}
else if (fn(m2,step_array) == true) {
$(".result2").css('display', 'block');
}
else if (fn(m3,step_array) == true) {
$(".result3").css('display', 'block');
}
else if (fn(m4,step_array) == true) {
$(".result4").css('display', 'block');
}
else if (fn(m5,step_array) == true) {
$(".result5").css('display', 'block');
}
else { alert('x2'); }
}
});
});