Показать сообщение отдельно
  #2 (permalink)  
Старый 23.01.2012, 16:00
Новичок на форуме
Отправить личное сообщение для МаксимУс Посмотреть профиль Найти все сообщения от МаксимУс
 
Регистрация: 23.01.2012
Сообщений: 2

Блин забыл собственно код кинуть....



var Question = new Array();
var FirstAnswer = new Array();
var SecondAnswer = new Array();
var CheckFirstAnswer = new Array();
var Conclusion = new Array();

Question[0] = 'First Question';
Question[1] = 'Second Question';
Question[2] = 'Third Question';
Question[3] = 'Forth Question';
Question[4] = 'Fifth Question';
Question[5] = 'Sixth Question';

FirstAnswer[0] = '1 - First Answer';
FirstAnswer[1] = '2 - First Answer';
FirstAnswer[2] = '3 - First Answer';
FirstAnswer[3] = '4 - First Answer';
FirstAnswer[4] = '5 - First Answer';
FirstAnswer[5] = '6 - First Answer';

SecondAnswer[0] = '1 - Second Answer';
SecondAnswer[1] = '2 - Second Answer';
SecondAnswer[2] = '3 - Second Answer';
SecondAnswer[3] = '4 - Second Answer';
SecondAnswer[4] = '5 - Second Answer';
SecondAnswer[5] = '6 - Second Answer';

CheckFirstAnswer[0]=1; //First
CheckFirstAnswer[1]=0; // Second
CheckFirstAnswer[2]=0; // Second
CheckFirstAnswer[3]=1; // First
CheckFirstAnswer[4]=1; // First
CheckFirstAnswer[5]=0; // Second

Conclusion[0] = 'First Conclusion';
Conclusion[1] = 'Second Conclusion';
Conclusion[2] = 'Third Conclusion';
Conclusion[3] = 'Forth Conclusion';
Conclusion[4] = 'Fifth Conclusion';
Conclusion[5] = 'Sixth Conclusion';


///////////////////////////////////////////////


$(document).ready(function() {
$("#img2").hide();

});


// question number
var currentQ = -1;

function showNewQuestion(el) {
currentQ++; // increment question number
$('.messagepop').html( Question[currentQ] + '<br />' +
'<a href="#" class="first">' + FirstAnswer[currentQ] + '</a><br />' +
'<a href="#" class="second">' + SecondAnswer[currentQ] + '</a><br />' +
'<a href="#" class="close">close</a>' );
}

///////////////////////////////////////////////

function validate(answer) {
var firstIsTrue = CheckFirstAnswer[currentQ];

// correct answer (new question)
if ( firstIsTrue && answer == 1
|| !firstIsTrue && answer == 2 ) {
$("#img2").show();
showNewQuestion();
}

// incorrect answer (conclusion)
else {
$('.messagepop').html(Conclusion[currentQ]);
}
}

///////////////////////////////////////////////

$(function () {

$("#container_div").live('click', function (event) {

// which element was clicked
var el = $(event.target);

// first answer was clicked
if (el.hasClass("first")) {
validate(1);
}

// second answer was clicked
else if (el.hasClass("second")) {
validate(2);
}

// questions opener was clicked
else if (el.attr("id") == "questions") {
el.addClass("selected").parent()
.append('<div class="messagepop pop" />');
showNewQuestion();
$(".pop").slideFadeToggle();
}

// popup close was clicked
else if (el.hasClass("close")) {
$(".pop").slideFadeToggle();
$("#questions").removeClass("selected");
}
});
});

///////////////////////////////////////////////

//animate
$.fn.slideFadeToggle = function (easing, callback) {
return this.animate({
opacity: 'toggle',
height: 'toggle'
}, "fast", easing, callback);
};

///////////////////////////////////////////////
Ответить с цитированием