[Sugar-devel] [Karma] questions about jquery.karma.js

Bryan Berry bryan at olenepal.org
Fri Nov 6 08:05:57 EST 2009

On Thu, 2009-11-05 at 22:43 +0100, Felipe López Toledo wrote:
> interesting, +1 to use test-driven
> I think it will consume more time, but it will make easier the
> introduction to new developers

I haven't made that much progress yet but u can see the start here:


and all the tests here:

So far I have only stubbed out the tests and code for the helper

>         Reading through jquery.karma.js, I have some questions:
>         --- the init function ---
>         You have an init function that receives the assets to be
>         loaded as an
>         argument but actually loading them happens in the first part
>         of the if
>         statement of karma.main . To me it would make more sense to
>         just pass
>         the assets as an argument to karma.main({ /* assets object
>         */}) and not
>         the function call back as currently.
>         Ideally I would like the use of Karma in lesson.js to be as
>         simple as
>         var k = Karma({ images: [ .....], sounds : [...], surfaces :
>         [....]}) 
> then it will be necessary to define the i18n options first
> var k = Karma({ i18n: []...., images: [ .....], sounds : [...],
> surfaces : [....]}) 


I think the property locale : "en"  will be sufficient

> other way what images/sounds are we suppose to load?
>         // the rest of the code for a lesson
>         I don't understand the if statement in karma.main. It seems to
>         me that
>         the callback to main function would never be called. That the
>         first if
>         clause will always be true and karma.main() won't be called a
>         second
>         time.
> I'm checking if there is something to load ( pendingToLoad ), if yes
> then I load all the stuff 
> other way the else statement will be executed 
> http://git.sugarlabs.org/projects/karma/repos/mainline/blobs/master/js/jquery.karma.js#line489
> anyway the callback function will be executed (if it's defined)

I don't see how that works. It seems to me that if there is anything
pendingToLoad it is loaded, and the callback isn't called.

> +1
> we won't have *any* dependencies, anyway we're using specific parts
> (helpers) of jquery (example: $.each )

and we don't need $.each because the browsers support
Array.prototype.forEach . Also, I implemented $.extend as objectPlus


> interesting, let me read (more) about in order to give you good
> arguments to discuss it
>         -- KButton ----
>         What is the purpose of KButton?
> there is no way to create buttons or clickeable elements inside a
> canvas,
> as for example, svg has its clickeable property (or something called
> like that)
> KButton is a "fast way" to create clickeable canvas sub-regions, this
> feature can be replaced by multiple canvas

But do we still need it? should i leave it in?
> what about this weekend? 

That works for me. How about Sunday before 11 am EST?

Bryan W. Berry
Senior Engineer
OLE Nepal, http://www.olenepal.org

More information about the Sugar-devel mailing list