$(document).ready(function(){ var k = Karma({ audio: [{'name':'correct','file':'correct.ogg'}, {'name':'incorrect','file':'incorrect.ogg'} ]}); k.ready(function(){ var i,j,flag; var TOTAL_QUES = 6; var TOTAL_LEVEL = 3; var currentDragObject; var randPositions = []; var arrangedAns = []; var sectionNum; //store the three levels values 0,1,2 var currentAlphaNum; //store the current questions num var checked; //store the current checked value var num; var currentAnsArray = []; //store the current array set of alphabets var flag_checked; //status flag for one time correct alpahbetical order var imgCounter; // six alphabets given to be ordered 6 steps needed to complete the picture 3 levels too complex var alphabets = new Array('aeroplane','apple','ant','arrow','audio','axe', 'eagle','ear','east','egg','elephant','engine', 'fan','fall','fat','first','fog','fun', 'egg','goat','ladder','leaf','net','tiger', 'crocodile','deer','elephant','lion','rhinosorous','tiger', 'bus','flag','glass','nose','pencil','table', 'bag','ball','banana','bat','bed','bone', 'cat','camera','class','color','country','cream', 'cat','cow','dog','donkey','hen','rabbit', 'dam','dark','den','dog','drink','duck', 'glass','nail','picture','radio','star','watch', 'bus','flag','glass','nose','pencil','table', 'magic','man','many','master','miracle','mouse', 'pan','pencil','pig','pot','practice','pumpkin', 'salte','school','short','smile','snake','stick', 'axe','mountain','plate','umbrella','volley-ball','x-ray', 'television','temple','toggle','trap','trust','turn', 'bottle','fish','house','pan','tree','window' ); var imageDisplay = new Array('ele0','ele1','ele2','ele3','ele4','ele5','house0','house1','house2','house3','house4','house5', 'ship0','ship1','ship2','ship3','ship4','ship5'); var scoreboard = $('#score_box').scoreboard({'layout':'horizontal', 'winningScore': alphabets.length}); var genRandPosition=function (){ randPositions[0] = k.rand(0,TOTAL_QUES-1); for(i=1; i2){ alphaCloudId = 2; } var alphaCurId = alphaId + (currentAlphaNum*TOTAL_QUES); $('#alphaCloud'+alphaCloudId).append('
'+alphabets[alphaCurId]+'
'); var dragObjCss = { 'position':'relative','float': 'left','cursor': 'move', 'width':'100px','height':'30px','padding-left': '20px', 'font':'20px/25px bold Arial,Verdana,Geneva,Helvetica' }; $('.dragObjects').css(dragObjCss); $('#alphaArrange').append('
'); var dropObjCss = { 'width':'222px','height': '33px','margin': '0.65em 0.5em' }; $('.dropObjects').css(dropObjCss); num++; }; function drag_drop(){ $('.dragObjects').draggable({ containment: '#content'}); $('.dragObjects').bind('dragstart', function(event, ui) { currentDragObject = event.target.id; var currentMonth = parseInt(currentDragObject.substring(4)); }); $(".dropObjects").droppable({ tolerence: 'intersect' ,hoverClass: 'drophover' }); $('.dropObjects').bind('drop', function(event, ui) { var currentDropObject = event.target.id; var droppedWord = parseInt(currentDropObject.substring(4)); arrangedAns[droppedWord] = $('#'+currentDragObject).text(); }); } var display_control = function(){ if(checked === 1){ $('#disImg'+imgCounter).show(); imgCounter++; next_alphabets(); } }; var delay_correctShow = function(){ document.delayForm.delayval.value = 1; $('#checkAnswer').hide(); if(currentAlphaNum%6 === 0 && currentAlphaNum != 0){ //next level $('#section').html(''); $('#linkNext').show(); } else{ display_control(); } }; var check_alphabets_order = function(){ var correct = 0; for(i=0; i'); scoreboard.scoreboard('incTotal'); } else{ k.audio.incorrect.play(); $('#checkAnswer').html(''); checked = 0; flag_checked = 1; } t=setTimeout(function(){delay_correctShow();},1000); }; var display_game_over = function(){ $('#section').hide(); $('#gameOver').show(); $('#gameOver').html(''); $('#gameOver').append('GAME OVER
Congratulations!!!'); }; var next_alphabets = function(){ if(currentAlphaNum === alphabets.length){ //show all display_game_over(); } else{ $('#section').html('').append('
'); $('#section').append('
'); $('#section').append('
Rearrange the above words in alphabetical order.
'); $('#section').append('
'); genRandPosition(); num = 0; flag_checked = 0; for(i = 0; i< TOTAL_QUES ; i++){ assignAlphabets(randPositions[i]); } for(i = 0;i'); $('#disImg'+i).hide(); } next_alphabets(); } $('#linkNext').hide(); $('#linkCheck').click(function(){ check_alphabets_order(); }); $('#linkNext').click(function(){ $('#linkNext').hide(); sectionNum += 1; game_start(); }); $('#linkStart').click(function(){ sectionNum = 0; currentAlphaNum = 0; game_start(); }); $('#linkPlayAgain').click(function(){ scoreboard.scoreboard('reset'); currentAlphaNum = sectionNum*currentAlphaNum; game_start(); }); }); //end of k.ready }); //end of document.ready