Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/examples/6_Maths_matchingAnglesAndShapes/js/lesson.js
diff options
context:
space:
mode:
Diffstat (limited to 'examples/6_Maths_matchingAnglesAndShapes/js/lesson.js')
-rwxr-xr-xexamples/6_Maths_matchingAnglesAndShapes/js/lesson.js83
1 files changed, 77 insertions, 6 deletions
diff --git a/examples/6_Maths_matchingAnglesAndShapes/js/lesson.js b/examples/6_Maths_matchingAnglesAndShapes/js/lesson.js
index 2aff46c..5bff562 100755
--- a/examples/6_Maths_matchingAnglesAndShapes/js/lesson.js
+++ b/examples/6_Maths_matchingAnglesAndShapes/js/lesson.js
@@ -1,5 +1,49 @@
-$(document).ready(function() {
+/*
+Bugs (firefox 3.5.7):
+* sometimes mulitple cards are shown
+* the image of one of the angles is not showing properly
+* if you have a text without a hyphen it doesn't work (e.g. angulo
+recto iso angulo-recto)
+* the text for angulo-obtuso is not displaying properly
+* title in english: 'matching angles with shapes' should maybe be
+'matching angles and shapes'
+
+Questions:
+* how do we set locale? cfr beginning of $(document).ready()
+
+Peeves:
+* tabs for indenting
+* trailing whitespace everywhere
+
+*/
+// TBD: use jquery plugin instead, http://plugins.jquery.com/project/psprintf
+function format(format_string /*, args*/) {
+ var args = [].slice.call(arguments); // arguments is not a real array
+ args.shift();
+ var result = '';
+ for (var i = 0; i < format_string.length; i += 1) {
+ var c = format_string.charAt(i);
+ if (c == '%') {
+ i += 1; // Breaks on format_string ending with %
+ var c2 = format_string.charAt(i);
+ if (c2 == '%') {
+ result += '%'
+ } else if (c2 == 'd') {
+ result += args.shift();
+ } else {
+ alert('unsupported format character: ' + c2);
+ }
+ } else {
+ result += c;
+ }
+ }
+ return result;
+}
+
+
+$(document).ready(function() {
+ var _ = $._;
var i = 0, j = 0, flag = 0;
var s=0, m=0, h=0;
var clickedObjects = []; //array storing the clicks of the two succesive clicks
@@ -14,14 +58,14 @@ $(document).ready(function() {
var restart = 0; //not restarted
var clickCounter = 0;
var NUM_OBJECTS = 24; //total number of objects in the game
- var shapes_angles = new Array('Acute-Angle','Right-Angle','Obtuse-Angle','Triangle','Square','Rhombus','Rectangle','Parallelogram','Pentagon','Hexagon','Septagon','Octagon','Acute-Angle','Right-Angle','Obtuse-Angle','Triangle','Square','Rhombus','Rectangle','Parallelogram','Pentagon','Hexagon','Septagon','Octagon');
+ var shapes_angles = new Array('Acute-Angle','Right-Angle','Obtuse-Angle','Triangle','Square','Rhombus','Rectangle','Parallelogram','Pentagon','Hexagon','Septagon','Octagon',_('Acute-Angle'),_('Right-Angle'),_('Obtuse-Angle'),_('Triangle'),_('Square'),_('Rhombus'),_('Rectangle'),_('Parallelogram'),_('Pentagon'),_('Hexagon'),_('Septagon'),_('Octagon'));
//var section = $('#section');
var $content = $('#content');
var shapes; //store the current shape or angle name
Karma.scaleWindow();
- $('#kHeader').kHeader({title:"Maths: Matching Angles with Shapes"});
+ $('#kHeader').kHeader({title:_("Maths: Matching Angles with Shapes")});
var $kFooter = $('#kFooter').kFooter({scoreboard: false, startButton: true,
pauseButton: true, restartButton: true, timer: true});
@@ -52,15 +96,42 @@ $(document).ready(function() {
};
+ // example of ngettext usage
+ alert(function(clickCounter, h, m, s) {
+ return format($.i18n.ngettext('You have completed the game in <span class="specialText">%d</span> clicks within <span class="specialText">%d</span> hour,',
+ 'You have completed the game in <span class="specialText">%d</span> clicks within <span class="specialText">%d</span> hours,',
+ h),
+ clickCounter, h)
+ + format($.i18n.ngettext('<span class="specialText">%d</span> minute and ',
+ '<span class="specialText">%d</span> minutes and ',
+ m),
+ m)
+ + format ($.i18n.ngettext('<span class="specialText">%d</span> second.',
+ '<span class="specialText">%d</span> seconds.',
+ s),
+ s);
+ }(10, 2, 3, 1));
var check_game_over = function(){
if(numMatched === NUM_OBJECTS){ //show all
play = 0;
$('#content').html('');
$('#content').append('<div id="gameOver">GAME OVER<br/>Congratulations!!!</div>');
- $('#content').append('<div id="gameOverInfo">You have completed the game in <span class="specialText">'+clickCounter+
- '</span> clicks within <span class="specialText">'+h+'</span> hour <span class="specialText">'+m+
- '</span> minutes and <span class="specialText">'+s+'</span> seconds .</div>');
+ $('#content').append($(document.createElement('div'))
+ .attr({id: 'gameOverInfo'})
+ // clicks < 2 is impossible
+ .html(format($.i18n.ngettext('You have completed the game in <span class="specialText">%d</span> clicks within <span class="specialText">%d</span> hour,',
+ 'You have completed the game in <span class="specialText">%d</span> clicks within <span class="specialText">%d</span> hours,',
+ h),
+ clickCounter, h)
+ + format($.i18n.ngettext('<span class="specialText">%d</span> minute and ',
+ '<span class="specialText">%d</span> minutes and ',
+ m),
+ m)
+ + format ($.i18n.ngettext('<span class="specialText">%d</span> second.',
+ '<span class="specialText">%d</span> seconds.',
+ s),
+ s)));
}
};