diff options
author | Bryan Berry <bryan@olenepal.org> | 2010-01-22 02:33:44 (GMT) |
---|---|---|
committer | Bryan Berry <bryan@olenepal.org> | 2010-01-22 02:33:44 (GMT) |
commit | 1d0f300017f07feed140f91d9e2ff6aab0bbd4de (patch) | |
tree | 6399d1c4210421d3035a010c826ae437b9ea8e90 | |
parent | d27cf2525350e8570d9413334eb1a2e26a2503d0 (diff) |
feedback plugin basically works
36 files changed, 445 insertions, 9 deletions
diff --git a/css/epaath_images/correct200x178.png b/css/epaath_images/correct200x178.png Binary files differnew file mode 100755 index 0000000..a203da6 --- /dev/null +++ b/css/epaath_images/correct200x178.png diff --git a/css/epaath_images/wrong.png b/css/epaath_images/incorrect.png Binary files differindex edfe9c5..edfe9c5 100755 --- a/css/epaath_images/wrong.png +++ b/css/epaath_images/incorrect.png diff --git a/css/epaath_images/incorrect200x178.png b/css/epaath_images/incorrect200x178.png Binary files differnew file mode 100755 index 0000000..f988c6a --- /dev/null +++ b/css/epaath_images/incorrect200x178.png diff --git a/css/karma.css b/css/karma.css index 50fb293..d187653 100755 --- a/css/karma.css +++ b/css/karma.css @@ -4,6 +4,7 @@ @import url(./ui.dialog.css); @import url(./ui.scoreboard.css); @import url(./ui.resizable.css); +@import url(./ui.feedback.css); /* special hack for the curren karma-loader notification */ @media screen { diff --git a/css/ui.feedback.css b/css/ui.feedback.css new file mode 100755 index 0000000..7d74c5f --- /dev/null +++ b/css/ui.feedback.css @@ -0,0 +1,16 @@ +.ui-feedback div{ + width: 200px; + height: 178px; + position: absolute; + background-repeat: no-repeat; +} + +.ui-feedback .ui-feedback-correct{ + display:none; + background-image: url(./epaath_images/correct200x178.png); +} + +.ui-feedback .ui-feedback-incorrect{ + display:none; + background-image: url(./epaath_images/incorrect200x178.png); +}
\ No newline at end of file diff --git a/css/ui.feedback.css~ b/css/ui.feedback.css~ new file mode 100755 index 0000000..73a5680 --- /dev/null +++ b/css/ui.feedback.css~ @@ -0,0 +1,6 @@ +.ui-feedback div:first{ + +} +.ui-feedback div:last{ + +}
\ No newline at end of file diff --git a/css/ui.resizable.css b/css/ui.resizable.css index 44efeb2..44efeb2 100644..100755 --- a/css/ui.resizable.css +++ b/css/ui.resizable.css diff --git a/docs/symbols/$.html b/docs/symbols/$.html index fa154c5..fa154c5 100644..100755 --- a/docs/symbols/$.html +++ b/docs/symbols/$.html diff --git a/docs/symbols/$.ui.html b/docs/symbols/$.ui.html index f7cfe10..f7cfe10 100644..100755 --- a/docs/symbols/$.ui.html +++ b/docs/symbols/$.ui.html diff --git a/docs/symbols/$.ui.scoreboard.defaults.html b/docs/symbols/$.ui.scoreboard.defaults.html index 9727ae8..9727ae8 100644..100755 --- a/docs/symbols/$.ui.scoreboard.defaults.html +++ b/docs/symbols/$.ui.scoreboard.defaults.html diff --git a/docs/symbols/$.ui.scoreboard.html b/docs/symbols/$.ui.scoreboard.html index d76893c..d76893c 100644..100755 --- a/docs/symbols/$.ui.scoreboard.html +++ b/docs/symbols/$.ui.scoreboard.html diff --git a/docs/symbols/src/js_ui.scoreboard.js.html b/docs/symbols/src/js_ui.scoreboard.js.html index 5807b6a..5807b6a 100644..100755 --- a/docs/symbols/src/js_ui.scoreboard.js.html +++ b/docs/symbols/src/js_ui.scoreboard.js.html diff --git a/examples/2_Maths_countingSheep/assets/image/bg.png b/examples/2_Maths_countingSheep/assets/image/bg.png Binary files differindex 6602635..6602635 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/bg.png +++ b/examples/2_Maths_countingSheep/assets/image/bg.png diff --git a/examples/2_Maths_countingSheep/assets/image/help.png b/examples/2_Maths_countingSheep/assets/image/help.png Binary files differindex f2f4f33..f2f4f33 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/help.png +++ b/examples/2_Maths_countingSheep/assets/image/help.png diff --git a/examples/2_Maths_countingSheep/assets/image/help_text.png b/examples/2_Maths_countingSheep/assets/image/help_text.png Binary files differindex 72083b1..72083b1 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/help_text.png +++ b/examples/2_Maths_countingSheep/assets/image/help_text.png diff --git a/examples/2_Maths_countingSheep/assets/image/icon.png b/examples/2_Maths_countingSheep/assets/image/icon.png Binary files differindex 740a558..740a558 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/icon.png +++ b/examples/2_Maths_countingSheep/assets/image/icon.png diff --git a/examples/2_Maths_countingSheep/assets/image/rubbish.png b/examples/2_Maths_countingSheep/assets/image/rubbish.png Binary files differindex 040dbfa..040dbfa 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/rubbish.png +++ b/examples/2_Maths_countingSheep/assets/image/rubbish.png diff --git a/examples/2_Maths_countingSheep/assets/image/rubbish_open.png b/examples/2_Maths_countingSheep/assets/image/rubbish_open.png Binary files differindex f611aea..f611aea 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/rubbish_open.png +++ b/examples/2_Maths_countingSheep/assets/image/rubbish_open.png diff --git a/examples/2_Maths_countingSheep/assets/image/shadow.png b/examples/2_Maths_countingSheep/assets/image/shadow.png Binary files differindex b351d43..b351d43 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/shadow.png +++ b/examples/2_Maths_countingSheep/assets/image/shadow.png diff --git a/examples/2_Maths_countingSheep/assets/image/sheep1.png b/examples/2_Maths_countingSheep/assets/image/sheep1.png Binary files differindex 9b1aa97..9b1aa97 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/sheep1.png +++ b/examples/2_Maths_countingSheep/assets/image/sheep1.png diff --git a/examples/2_Maths_countingSheep/assets/image/sheep2.png b/examples/2_Maths_countingSheep/assets/image/sheep2.png Binary files differindex 7e738bd..7e738bd 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/sheep2.png +++ b/examples/2_Maths_countingSheep/assets/image/sheep2.png diff --git a/examples/2_Maths_countingSheep/assets/image/sheep3.png b/examples/2_Maths_countingSheep/assets/image/sheep3.png Binary files differindex 4290d9d..4290d9d 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/sheep3.png +++ b/examples/2_Maths_countingSheep/assets/image/sheep3.png diff --git a/examples/2_Maths_countingSheep/assets/image/title.png b/examples/2_Maths_countingSheep/assets/image/title.png Binary files differindex 90446ed..90446ed 100644..100755 --- a/examples/2_Maths_countingSheep/assets/image/title.png +++ b/examples/2_Maths_countingSheep/assets/image/title.png diff --git a/examples/2_Maths_countingSheep/css/karma.css b/examples/2_Maths_countingSheep/css/karma.css index bce5ee2..bce5ee2 100644..100755 --- a/examples/2_Maths_countingSheep/css/karma.css +++ b/examples/2_Maths_countingSheep/css/karma.css diff --git a/examples/2_Maths_countingSheep/css/lesson.css b/examples/2_Maths_countingSheep/css/lesson.css index a997677..a997677 100644..100755 --- a/examples/2_Maths_countingSheep/css/lesson.css +++ b/examples/2_Maths_countingSheep/css/lesson.css diff --git a/examples/2_Maths_countingSheep/index.html b/examples/2_Maths_countingSheep/index.html index ccea70d..ccea70d 100644..100755 --- a/examples/2_Maths_countingSheep/index.html +++ b/examples/2_Maths_countingSheep/index.html diff --git a/examples/2_Maths_countingSheep/js/lesson.js b/examples/2_Maths_countingSheep/js/lesson.js index 0b3a58a..0b3a58a 100644..100755 --- a/examples/2_Maths_countingSheep/js/lesson.js +++ b/examples/2_Maths_countingSheep/js/lesson.js diff --git a/examples/2_Maths_countingSheep/js/ui.draggable.js b/examples/2_Maths_countingSheep/js/ui.draggable.js index 0402f0e..0402f0e 100644..100755 --- a/examples/2_Maths_countingSheep/js/ui.draggable.js +++ b/examples/2_Maths_countingSheep/js/ui.draggable.js diff --git a/examples/2_Maths_countingSheep/js/ui.droppable.js b/examples/2_Maths_countingSheep/js/ui.droppable.js index 8e7be33..8e7be33 100644..100755 --- a/examples/2_Maths_countingSheep/js/ui.droppable.js +++ b/examples/2_Maths_countingSheep/js/ui.droppable.js diff --git a/examples/English_Animal_Identification/index.html b/examples/English_Animal_Identification/index.html index 5ca983b..bdb8bac 100755 --- a/examples/English_Animal_Identification/index.html +++ b/examples/English_Animal_Identification/index.html @@ -13,6 +13,7 @@ <script type="text/javascript" src="../../js/ui.draggable.js"></script>
<script type="text/javascript" src="../../js/ui.dialog.js"></script>
<script type="text/javascript" src="../../js/ui.scoreboard.js"></script>
+ <script type="text/javascript" src="../../js/ui.feedback.js"></script>
<script type="text/javascript" src="../../js/karma.js"></script>
<script type="text/javascript" src="js/lesson.js"></script>
</head>
@@ -44,6 +45,7 @@ <div id="kHeaderHelp" title="Help Me!">foobar</div>
</div>
+ <div id="feedback"></div>
<div id="gameArea">
<div id="questionBox">What is this?</div>
diff --git a/examples/English_Animal_Identification/js/lesson.js b/examples/English_Animal_Identification/js/lesson.js index 65ad4a6..4d12839 100755 --- a/examples/English_Animal_Identification/js/lesson.js +++ b/examples/English_Animal_Identification/js/lesson.js @@ -26,6 +26,8 @@ $(document).ready( position:[ 650, 50], modal:'true',autoOpen:false }); + var $feedback = $('#feedback').feedback(); + $('#kHeaderHelpBtn').click(function(){ $help.dialog('open');}); var scoreboard = $('#scoreArea').scoreboard({'winningScore': 6}); @@ -43,17 +45,16 @@ $(document).ready( function checkDisplay(){ //Displays the correct and incorrect info if(wrong_selected == 1){ - $('.checkedOption').show(); - document.getElementById("check").src = - "assets/image/incorrect.png"; - k.audio.incorrect.play(); - $('.checkedOption').fadeOut(1000); + $('.checkedOption').show(); + $feedback.feedback('incorrect'); + $('.checkedOption').fadeOut(1000); } else{ - $('.checkedOption').hide(); - document.getElementById("check").src = "assets/image/correct.png"; - k.audio.correct.play(); - $('.checkedOption').fadeOut(2000); + $('.checkedOption').hide(); + //document.getElementById("check").src = "assets/image/correct.png"; + // k.audio.correct.play(); + $feedback.feedback('correct'); + $('.checkedOption').fadeOut(2000); //needs timer for holding on for abt a sec } } diff --git a/js/ui.dialog.js b/js/ui.dialog.js index fdd5b26..fdd5b26 100644..100755 --- a/js/ui.dialog.js +++ b/js/ui.dialog.js diff --git a/js/ui.draggable.js b/js/ui.draggable.js index 0402f0e..0402f0e 100644..100755 --- a/js/ui.draggable.js +++ b/js/ui.draggable.js diff --git a/js/ui.feedback.js b/js/ui.feedback.js new file mode 100755 index 0000000..2d60518 --- /dev/null +++ b/js/ui.feedback.js @@ -0,0 +1,78 @@ +/** +* @fileOverview a scoreboard widget +* @author Bryan Berry <bryan@olenepal.org> +* uses MIT License +*/ + + + +(function($){ + + // This is a dummy function, just here as placeholder to + // to make the jsdoc tool happy + /** @name $.ui.scoreboard + * @namespace Scoreboard widget + */ + $.ui.feedback = function(){}; + + $.widget('ui.feedback', + /** @lends $.ui.feedback.prototype */ + { + correct: function(){ + this.$correct.css('display','block').fadeOut(3000); + if (Karma && Karma.audio && Karma.audio.correct){ + Karma.audio.correct.play(); + } + + }, + incorrect: function(){ + this.$incorrect.css('display','block').fadeOut(3000); + if (Karma && Karma.audio && Karma.audio.incorrect){ + Karma.audio.incorrect.play(); + } + + }, + _init : function(){ + var self = this; + + this.element + .addClass('ui-feedback') + .css({position:'absolute', + top: '40%', left: '40%'}); + + this.$correct = $('<div></div>') + .addClass('ui-feedback-correct') + .appendTo(this.element); + + this.$incorrect = $('<div></div>') + .addClass('ui-feedback-incorrect') + .appendTo(this.element); + + $('body') + .bind('feedbackCorrect', function(){ + self.correct(); + }) + .bind('feedbackIncorrect', function(){ + self.incorrect(); + }); + + }, + /** Removes the scoreboard widget and all related data from the DOM */ + destroy : function(){ + this.element.remove(); + $.widget.prototype.destroy.apply(this, arguments); + } + + + }); + + $.ui.scoreboard.getter = []; + + /** Default settings for the scoreboard widget + * @namespace Default settings for the scoreboard widget + * @extends $.ui.scoreboard + */ + $.ui.feedback.defaults = { + }; + + })(jQuery);
\ No newline at end of file diff --git a/js/ui.feedback.js~ b/js/ui.feedback.js~ new file mode 100755 index 0000000..9704c20 --- /dev/null +++ b/js/ui.feedback.js~ @@ -0,0 +1,332 @@ +/** +* @fileOverview a scoreboard widget +* @author Bryan Berry <bryan@olenepal.org> +* uses MIT License +*/ + + + +(function($){ + + // This is a dummy function, just here as placeholder to + // to make the jsdoc tool happy + /** @name $.ui.scoreboard + * @namespace Scoreboard widget + */ + $.ui.scoreboard = function(){}; + + $.widget('ui.scoreboard', + /** @lends $.ui.scoreboard.prototype */ + { + /** Gets the current score + * @returns {Number} current score + */ + getScore : function(){ + return this._getData('score'); + }, + /** Sets the current score + * @param {Number} newScore new score + */ + setScore : function(newScore){ + this._setData('score', parseInt(newScore)); + this._refresh(); + }, + /** Gets the current total + * @returns {Number} current total + */ + getTotal : function(){ + return this._getData('total'); + }, + /** Sets the current total + * @param {Number} newTotal new score + */ + setTotal : function(newTotal){ + this._setData('total', parseInt(newTotal)); + this._refresh(); + }, + /** + * Restarts the scoreboard and triggers the "scoreboardRestart" event + */ + restart : function(){ + this.element.trigger('scoreboardRestart'); + this._setData('score', this._getData('initialScore')); + this._setData('total', this._getData('initialTotal')); + this._refresh(); + }, + /** Increments the score by 1 or by the supplied numeric argument + * @param {Number} [val] increment value + */ + inc : function(val){ + var incVal = parseInt(val) || 1; + this._setData('score', this._getData('score') + incVal); + this._refresh(); + if(this._getData('winScore') === this._getData('score')){ + this.element.trigger('scoreboardWinGame'); + } + }, + /** Increments the total by 1 or by the supplied numeric argument + * @param {Number} [val] increment value + */ + incTotal : function(val){ + var incVal = parseInt(val) || 1; + this._setData('total', this._getData('total') + incVal); + this._refresh(); + }, + /** Decrements the score by 1 or by the supplied numeric argument + * @param {Number} [val] decrement value + */ + dec : function(val){ + var decVal = parseInt(val) || 1; + this._setData('score', this._getData('score') - decVal); + this._refresh(); + }, + /** Decrements the total by 1 or by the supplied numeric argument + * @param {Number} [val] decrement value + */ + decTotal : function(val){ + var decVal = parseInt(val) || 1; + this._setData('total', this._getData('total') - decVal); + this._refresh(); + }, + _ : function(val){ + var self = this; + var convertNumLocale = function(num){ + //48 is the base for western numerals + var convertDigit = function(digit){ + + var numBase = 48; + var prefix = "u00"; + + if (self._getData('locale') === "ne"){ + prefix = "u0"; + numBase = 2406; + } + + return '\\' + prefix + + (numBase + parseInt(digit)).toString(16); + }; + + var charArray = num.toString().split("").map(convertDigit); + return eval('"' + charArray.join('') + '"'); + }; + + var convertStringLocale = function (str){ + if (self._getData('locale') === "ne"){ + switch(str){ + case "Score": + return "अङ्क"; + case "Total": + return "जम्मा"; + case "Restart": + return "फेरी खेलौ"; + case "Pause": + return "खेल रोकौ"; + case "Start": + return "सुरु गरौ"; + default: + return "string not translated"; + } + } + return "String really not translated"; + }; + + + + if (typeof val === "number"){ + return convertNumLocale(val); + } + + if (this._getData('locale') !== "en"){ + return convertStringLocale(val); + }else { + return val; + } + + + }, + _init : function(){ + + var divDisplay = "inline"; + var score = this.options.score; + var total = this.options.total; + var layoutId = "h"; + var self = this; + + var options = $.extend({}, $.ui.scoreboard.defaults, this.options); + + this._setData('initialScore', parseInt(options.score)); + this._setData('initialTotal', parseInt(options.total)); + this._setData('score', parseInt(options.score)); + this._setData('total', parseInt(options.total)); + this._setData('winScore', parseInt(options.winningScore)); + this._setData('locale', options.locale); + + if(this.options.layout === "vertical"){ + layoutId = "v"; + } + + this.element.addClass('ui-scoreboard-container-' + layoutId + + ' ui-widget ui-widget-content ui-corner-all'); + + var $parent = $('<div>') + .attr('id', 'uiScoreboard') + .addClass('ui-scoreboard-spacing-' + layoutId); + + this._scoreText = $("<div><span>" + this._("Score") + "</span></div>") + .addClass('ui-scoreboard-spacing-'+ layoutId + + ' ui-corner-all ui-scoreboard-text') + .appendTo($parent); + + this._score = $("<div><span>" + this._(score) + "</span></div>") + .addClass('ui-scoreboard-spacing-' + layoutId + + ' ui-scoreboard-text ui-scoreboard-number-' + layoutId) + .appendTo($parent) + .find('span:first'); + + + $("<div><span>" + this._("Total") + "</span></div>") + .addClass('ui-scoreboard-spacing-' + layoutId + + ' ui-corner-all ' + + 'ui-scoreboard-text') + .appendTo($parent); + + this._total = $("<div><span>" + this._(total) + "</span></div>") + .addClass('ui-scoreboard-spacing-' + layoutId + + ' ui-scoreboard-text ui-scoreboard-number-' + layoutId) + .appendTo($parent) + .find('span:first'); + + + var $templateBtn = $('<button></button>') + .addClass('ui-scoreboard-spacing-' + layoutId + + ' ui-scoreboard-button ' + + 'ui-corner-all ui-state-default') + .append( + $('<span></span>') + .addClass('ui-icon ' + + 'ui-scoreboard-icon') + ) + .append( + $('<span></span>') + .addClass('centered') + ); + + if(options.restartButton){ + var $restartBtn = $templateBtn.clone() + .find('span:first') + .addClass('ui-icon-arrowrefresh-1-w') + .end() + .find('span:last') + .text(this._('Restart')) + .end() + .click(function(){ self.restart();}) + .appendTo($parent); + } + + + if(options.pauseButton){ + + var $pauseBtn = $templateBtn.clone() + .find('span:first') // + .removeClass('ui-icon-arrowrefresh-1-w') + .addClass('ui-icon-pause') + .end() + .find('span:last') + .text(this._('Pause')) + .end() + .click(function(){ + self.element.trigger('scoreboardPause'); + }) + .appendTo($parent); + } + + if(options.startButton){ + var $startBtn = $templateBtn.clone() + .find('span:first') + //.removeClass('ui-icon-arrowrefresh-1-w') + .addClass('ui-icon-arrowreturnthick-1-s') + .end() + .find('span:last') + .text(this._('Start')) + .end() + .click(function(){ + self.element.trigger('scoreboardStart'); + }) + .appendTo($parent); + } + + + $parent.find('button').hover( + function(){ + $(this).addClass("ui-state-hover"); + }, + function(){ + $(this).removeClass("ui-state-hover"); + }); + + this.element.append($parent); + + }, + _refresh : function(){ + this._score.text(this._(this._getData('score'))); + this._total.text(this._(this._getData('total'))); + }, + /** Removes the scoreboard widget and all related data from the DOM */ + destroy : function(){ + this.element.remove(); + $.widget.prototype.destroy.apply(this, arguments); + } + + + }); + + $.ui.scoreboard.getter = ['getScore', 'getTotal', '_convertNumLocale']; + + /** Default settings for the scoreboard widget + * @namespace Default settings for the scoreboard widget + * @extends $.ui.scoreboard + */ + $.ui.scoreboard.defaults = { + /** Initial score + * @type Number + * @default 0 + */ + score: 0, + /** Initial total + * @type Number + * @default 0 + */ + total: 0, + /** Initial layout, valid options are "horizontal" and "vertical" + * @type String + * @default "horizontal" + */ + layout: "horizontal", + /** The score that will win the game + * @type Number + * @default 0 + */ + winningScore: 0, + /** Default locale, valid options are "en" and "ne" + * @type String + * @default "en" + */ + locale: "en", + /** Display the Start Button + * @type boolean + * @default false + */ + startButton: false, + /** Display the Retart Button + * @type boolean + * @default true + */ + restartButton: true, + /** Display the Pause Button + * @type boolean + * @default false + */ + pauseButton: false + }; + + })(jQuery);
\ No newline at end of file diff --git a/js/ui.resizable.js b/js/ui.resizable.js index 6172d6c..6172d6c 100644..100755 --- a/js/ui.resizable.js +++ b/js/ui.resizable.js |