Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/jquery.i18n.js2
-rwxr-xr-xjs/lesson.js178
-rwxr-xr-xjs/ui.kFooter.js12
3 files changed, 39 insertions, 153 deletions
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<i; j++){
- if(imgNameRand[i]===imgNameRand[j]){
- flag++;
- }
- }
- }while(flag != 0 ); //end of do while loop
- }
-
-
- correctPosition = k.rand(0, 3);
-
- optOtherPos[0] = correctPosition;
-
- for(i=1; i<4; i++){
- do{
- flag = 0;
- optOtherPos[i] = k.rand(0, 3);
- for(j=0; j<i; j++){ //chek repeat within optOtherPos array
- if(optOtherPos[i] === optOtherPos[j]){
- flag++;
- }
- }
-
- }while(flag != 0);
-
- }
-
- for(i=0; i<4; i++){
- pos = optOtherPos[i];
- optPosition[pos] = imgNameRand[i];
- //optPosition[pos] = imgNames[i];
- }
-
-
- //random positions are stored in optOtherPos array. Great
-
-
- for(i=0; i<4; i++){
- document.getElementById("option"+i+"").src = "assets/image/image_name/"+optPosition[i]+".png";
- }
-
-
- } //no change
}); //end of games
}); //end of DOM \ No newline at end of file
diff --git a/js/ui.kFooter.js b/js/ui.kFooter.js
index 02d7937..d25f6bd 100755
--- a/js/ui.kFooter.js
+++ b/js/ui.kFooter.js
@@ -157,11 +157,17 @@
stopTimer : function(){
this._setData('timerRunning', false);
},
- _ : function(val, loc){
- return $.i18n.call($.ui.kFooter, val, loc);
+ _ : function(val, loc){
+ if($.i18n){
+ return $.i18n.call($.ui.kFooter, val, loc);
+ }
+ return val;
},
_n : function(val, loc){
- return $._n(val, loc);
+ if ($.i18n){
+ return $._n(val, loc);
+ }
+ return val;
},
_init : function(){