Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- -#inner2 starts with 'start' button
- -on click, randomly pick a question from array of question objects
- -each question object has a question and multiple answers
- -questions will 'fade' into existence
- -answers will swing left and right into #inner 2
- -answers will be highlighted on hover
- -if wrong, #inner2 changes to red and shakes -- also plays incorrect sound
- -if correct, #inner2 changes to green and does some sort of confirmation animation -- also plays correct sound
- -if question objects all have 'answered' property set to true, end game screen is shown
- -reset button which reloads page
- */
- var questionOne = {
- question: "What company invented the floppy disk?",
- actualAnswer: "IBM",
- answers: ["Apple","Microsoft","IBM"],
- answered: false
- };
- var questionTwo = {
- question: "What is the first domain name ever registered?",
- actualAnswer: "Symblolic.com",
- answers: ["WorldWideWeb.com","Symblolic.com","Me.com"],
- answered: false
- };
- var questionThree = {
- question: "Which company is the largest producer of software for PC?",
- actualAnswer: "Microsoft",
- answers: ["Google","Microsoft","Dell"],
- answered: false
- };
- var questionFour = {
- question: "What is CPU?",
- actualAnswer: "Central Processing Unit",
- answers: ["Central Programming Unit","Central Processing Unit","Central Placement Unit"],
- answered: false
- };
- var questionFive = {
- question: "What is RAM?",
- actualAnswer: "Random Access Memory",
- answers: ["Random Access Memory","Random Automatic Memory","Random Automated Memory"],
- answered: false
- };
- var questionSix = {
- question: "Has modern cell phone computing power surpassed that of the Apollo 11 Lunar Lander?",
- actualAnswer: "True",
- answers: ["True","False"],
- answered: false
- };
- var questionSeven = {
- question: "The first computer mouse was constructed in 1964 with what material?",
- actualAnswer: "Wood",
- answers: ["Metal","Rubber","Wood"],
- answered: false
- };
- var questionEight = {
- question: "Approximately how many domain names are registered every month? (2014)",
- actualAnswer: "1,000,000",
- answers: ["200,000","600,000","1,000,000"],
- answered: false
- };
- var questionNine = {
- question: "Approximately how many web pages are on the internet today? (2014)",
- actualAnswer: "20,000,000,000",
- answers: ["5,000,000,000","10,000,000,000","20,000,000,000"],
- answered: false
- };
- var questionTen = {
- question: "What does 'PCMR' mean?",
- actualAnswer: "PC Master Race",
- answers: ["PC Master Race","PC Master Race","PC Master Race"],
- answered: false
- };
- var questionHolder = [questionOne,questionTwo,questionThree,questionFour,questionFive,questionSix,questionSeven,questionEight,questionNine,questionTen];
- var randomQuestion = questionHolder[Math.floor((Math.random() * questionHolder.length) + 0)];
- //console.log(randomQuestion);
- var pickedQuestions = [];
- if(pickedQuestions.includes(randomQuestion)){
- randomQuestion = questionHolder[Math.floor((Math.random() * questionHolder.length) + 0)];
- }else{
- pickedQuestions.push(randomQuestion);
- //console.log(pickedQuestions);
- }
- function nextQuestion(){
- randomQuestion = questionHolder[Math.floor((Math.random() * questionHolder.length) + 0)];
- if(pickedQuestions.includes(randomQuestion)){
- randomQuestion = questionHolder[Math.floor((Math.random() * questionHolder.length) + 0)];
- }else{
- pickedQuestions.push(randomQuestion);
- //console.log(pickedQuestions);
- }
- }
- $('#start').on("click",function(){
- $('#inner').html("<p class='animated fadeInUp' style='font-family: Bungee;position: relative;top: 40px'>" + randomQuestion.question + "</p>");
- for(var i = 0; i < randomQuestion.answers.length; i++){
- $('#inner2').append("<div id='inner3' class='animated bounceInUp'>" + "<p id='inner3-sub'>" + randomQuestion.answers[i] + "</p>" + "</div>");
- }
- });
- $('#inner3').on("click",function(){
- var currentText = $(this).find("inner3-sub").text(),
- trimmedText = $.trim(currentText);
- if (trimmedText == randomQuestion.actualAnswer) {
- $('.container').css("background-color", "#0dd913");
- } else {
- $('.container').css("background-color", "#e7170d");
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement