From aeb50aa30708c04cd816172753ea4972815b207c Mon Sep 17 00:00:00 2001 From: Bryan Berry Date: Wed, 17 Feb 2010 11:01:27 +0000 Subject: make lesson generic --- (limited to 'js') diff --git a/js/jquery.i18n.js b/js/jquery.i18n.js index ac2193d..db142c4 100644 --- a/js/jquery.i18n.js +++ b/js/jquery.i18n.js @@ -37,7 +37,7 @@ locale = locale || $.i18n.lang; - if (!this.i18n[locale] || !this.i18n[locale].numBase ){ + if (!this.i18n[locale] || !this.i18n[locale].numeralBase ){ return num; } diff --git a/js/lesson.js b/js/lesson.js index 4d60c7d..dd7adea 100755 --- a/js/lesson.js +++ b/js/lesson.js @@ -1,45 +1,48 @@ $(document).ready( function(){ + + //preloads assets into karma 'collections' var k = Karma({ audio: [{'name':'correct','file':'correct.ogg'}, {'name':'incorrect','file':'incorrect.ogg'} ]}); + //this command will scale down the lesson if the user's browser window + //is smaller than 950px X 600px k.scaleWindow(); - $.i18n.setLocale('ne'); - + + //sets locale, otherwise defaults to English + $.i18n.setLocale('en'); + k.ready( function(){ + //put your main lesson code inside this callback - var flag, i ,j; - var object_counter = 1; - var imgNameRand = []; - var optPosition = []; - var optOtherPos = []; - var imageObject = []; - var imgNames = ["Bear", "Cow", "Elephant", "Horse", "Tiger", "Goat"]; - var correctPosition; - var selectedOption; - var score = 0; - var wrong_selected = 0; //wrong option selected so don't score up - var pos; - var t; - var current_image; - - var $help = $('#kHelpText').dialog({ - position:[ "right", "top"], modal:'true',autoOpen:false - }); - - var $feedback = $('#feedback').feedback(); - - $('#kHeaderHelpBtn').click(function(){ $help.dialog('open');}); + //This attaches the Karma Header widget to the div w/ the id #kHeader + //and initializes it w/ values + $('#kHeader').kHeader({'title': 'My First Karma Lesson', + lessonPlan: true, teachersNote: true}); - $('#kHeader').kHeader({'title': 'English Animal Identification', - lessonPlan: true, teachersNote: true}); + //set up the footer and initialize it with a winning score var kFooter = $('#kFooter').kFooter({'winningScore': 6}); + + //Set up feedback widget, this shows the user a correct or incorrect + //icon and sound when triggered programmatically + var $feedback = $('#feedback').feedback(); + + /* Here are examples of using the feedback widget + + $feedback.feedback('correct'); + $feedback.feedback('incorrect'); + $feedback.feedback('win'); + $feedback.feedback('lose'); + + */ + + //here are examples of binding behavior to events kFooter.bind('kFooterWinGame', function(){ $('.optImg').hide(); @@ -61,131 +64,8 @@ $(document).ready( } ); - - load_images(); //load the image numbers for random display - game(); //let the game begin - - - function checkDisplay(){ //Displays the correct and incorrect info - if(wrong_selected == 1){ - $feedback.feedback('incorrect'); - } - else if (object_counter === 7 ){ - $feedback.feedback('win'); - } else{ - $feedback.feedback('correct'); - } - } - - $("#anchorPlayAgain").click(function(){ - $('#gameOver').hide(); - $('.optImg').show(); - $('.imageBox').show(); - load_images(); - score = 0; - object_counter = 1; - wrong_selected = 0; - //display_score(); - kFooter.kFooter('reset'); - game(); - - }); - $("#anchorOpt0").click(function(){ - selected_Option_Process('0'); - }); - $("#anchorOpt1").click(function(){ - selected_Option_Process('1'); - }); - $("#anchorOpt2").click(function(){ - selected_Option_Process('2'); - }); - $("#anchorOpt3").click(function(){ - selected_Option_Process('3'); - }); - - - function load_images(){ - imageObject = k.shuffle([1, 2, 3, 4, 5, 6]); - } - - function selected_Option_Process(selectedOption){ - - if(selectedOption == correctPosition){ - object_counter++; - wrong_selected = 0; - score++; - kFooter.kFooter('inc'); - kFooter.kFooter('incTotal'); - checkDisplay(); - game(); - } - else { - wrong_selected = 1; - kFooter.kFooter('incTotal'); - checkDisplay(); - } - } - function game(){ - - wrong_selected = 0; - current_image = object_counter%6; - document.getElementById("imgObject").src = "assets/image/" + - imageObject[current_image] + ".png"; - - //find correct answer and apply it to the position - var currentImage = imageObject[current_image]; - imgNameRand[0] = currentImage; - //generate choices - - for(i=1; i<4; i++){ - do{ - flag = 0; - imgNameRand[i] = k.rand(1, 6); - for(j=0; j