diff options
author | Felipe Lopez Toledo <zer.subzero@gmail.com> | 2009-09-10 01:48:19 (GMT) |
---|---|---|
committer | Felipe Lopez Toledo <zer.subzero@gmail.com> | 2009-09-10 01:48:19 (GMT) |
commit | 0f300b3d8e86bf49075a4eca86dbfbd5b74fd8c7 (patch) | |
tree | 0afda333418ec04c34e1b8c904988309e72dddd4 | |
parent | 93ab8fd4b414d36bda6b27b7e4abde7cca08b715 (diff) |
feature added: https://bugs.launchpad.net/bugs/426117
-rwxr-xr-x | examples/adding_up_to_10/js/lesson_multiple.js | 8 | ||||
-rwxr-xr-x | js/jquery.karma.js | 27 |
2 files changed, 22 insertions, 13 deletions
diff --git a/examples/adding_up_to_10/js/lesson_multiple.js b/examples/adding_up_to_10/js/lesson_multiple.js index a58169e..b128938 100755 --- a/examples/adding_up_to_10/js/lesson_multiple.js +++ b/examples/adding_up_to_10/js/lesson_multiple.js @@ -2,8 +2,8 @@ $(document).ready(function(){ var k = $.karma ({container: "#karma-main"}); k.init({ images: [ - {id: "ball", file: "ball.png", localized : false }, - {id: "balloon", file: "balloon.png", localized : false }, + {id: "ball", file: "ball37.png", localized : false }, + {id: "balloon", file: "balloo.png", localized : false }, {id: "banana", file: "banana.png", localized : false }, {id: "chilli", file: "chilli.png", localized : false }, {id: "fish" , file: "fish.png", localized : false }, @@ -39,10 +39,10 @@ k.main(function() { "click", function(){surfaces["inline2"].clear();} ); - + /* surfaces["inline1"].ctx.fillStyle = "#00f"; surfaces["inline1"].ctx.fillRect(0, 0, 150, 150); surfaces["card1"].ctx.fillStyle = "#000"; - surfaces["card1"].ctx.fillRect(0, 0, 150, 150); + surfaces["card1"].ctx.fillRect(0, 0, 150, 150);*/ }); });
\ No newline at end of file diff --git a/js/jquery.karma.js b/js/jquery.karma.js index bd2aead..d7407ef 100755 --- a/js/jquery.karma.js +++ b/js/jquery.karma.js @@ -421,6 +421,10 @@ Karma.prototype.main = function ( cb ) { loading ...<div id=\"karma-loader\" class=\"status\"></div></div>'); var statusDiv = $("#karma-loader .status"); + var statusUpdate = function ( current, error, total) { + statusDiv.html(current + "/" + total + (error > 0 ? " [ "+error+" ]":'')); + } + var that = this; var categories = ["images", "sounds", "videos" ]; var counters = { "loaded":0, "error": 0 }; @@ -431,24 +435,32 @@ Karma.prototype.main = function ( cb ) { Karma.prototype.surface.call( that, config ); }); } + statusUpdate( 0, 0, totalItems); //get the total items for ( var i=0; i < categories.length; i++ ) { if ( valid ( this.pendingToLoad[ categories[ i ] ] ) ) { totalItems += this.pendingToLoad[ categories[ i ] ].length; } } - statusDiv.html("0/"+totalItems); + /** callback to check if all the items were loaded or got an error when loading **/ + var errors=[]; var checkAllLoaded = function ( ev ) { if ( ev.type === "load") counters.loaded += 1; - else counters.error += 1; - statusDiv.html( counters.loaded + counters.error + "/" + totalItems); + else { + errors.push( ev.target.src ); + counters.error += 1; + } + statusUpdate( counters.loaded, counters.error, totalItems); if ( counters.loaded + counters.error === totalItems ) { - $("#karma-loader:hiden:first").fadeOut( - "slow",function(){ $(this).remove();}); + if ( counters.error > 0 ){ + throw ( "Images not found: " + errors ); + } + $("#karma-loader:hiden:first").fadeOut("slow",function(){ + $(this).remove();}); if ( cb ) cb(); } } @@ -642,14 +654,11 @@ var KSurface = Class( }else { this.canvas = document.getElementById( options.canvas ); if ( !this.canvas ){ - throw new Error ("The canvas id doesn't exist"); + throw new Error ("The canvas id doesn't exist"); } this.width = this.canvas.width; this.height = this.canvas.height; - - if (!this.id){ this.id = this.canvas.id; - } } if ( this.canvas.getContext ) { this.ctx = this.canvas.getContext("2d"); |