From b022c87d8187fde2ee74f67c88399fc6c6b2051c Mon Sep 17 00:00:00 2001 From: Bryan Berry Date: Mon, 04 Jan 2010 13:36:17 +0000 Subject: moved math functions to Karma.* namespace. Fixed the lessons that used them to use proper references --- diff --git a/Jakefile b/Jakefile index 6c1496e..6c1496e 100644..100755 --- a/Jakefile +++ b/Jakefile diff --git a/assets/image/adding_up134x100.png b/assets/image/adding_up134x100.png index ba6e2db..ba6e2db 100644..100755 --- a/assets/image/adding_up134x100.png +++ b/assets/image/adding_up134x100.png Binary files differ diff --git a/assets/image/alphabet_identification136x100.png b/assets/image/alphabet_identification136x100.png index dc24cc0..dc24cc0 100644..100755 --- a/assets/image/alphabet_identification136x100.png +++ b/assets/image/alphabet_identification136x100.png Binary files differ diff --git a/assets/image/alphabet_puzzle136x100.png b/assets/image/alphabet_puzzle136x100.png index bba981b..bba981b 100644..100755 --- a/assets/image/alphabet_puzzle136x100.png +++ b/assets/image/alphabet_puzzle136x100.png Binary files differ diff --git a/assets/image/arrows136x100.png b/assets/image/arrows136x100.png index fb68d5e..fb68d5e 100644..100755 --- a/assets/image/arrows136x100.png +++ b/assets/image/arrows136x100.png Binary files differ diff --git a/assets/image/english_colors136x100.png b/assets/image/english_colors136x100.png index 1511fdd..1511fdd 100644..100755 --- a/assets/image/english_colors136x100.png +++ b/assets/image/english_colors136x100.png Binary files differ diff --git a/assets/image/english_matching136x100.png b/assets/image/english_matching136x100.png index f05564c..f05564c 100644..100755 --- a/assets/image/english_matching136x100.png +++ b/assets/image/english_matching136x100.png Binary files differ diff --git a/assets/image/karma-logo100x118.png b/assets/image/karma-logo100x118.png index f1acb08..f1acb08 100644..100755 --- a/assets/image/karma-logo100x118.png +++ b/assets/image/karma-logo100x118.png Binary files differ diff --git a/assets/image/karma-logo50x59.png b/assets/image/karma-logo50x59.png index 9259b37..9259b37 100644..100755 --- a/assets/image/karma-logo50x59.png +++ b/assets/image/karma-logo50x59.png Binary files differ diff --git a/assets/image/karma-logo80x94.png b/assets/image/karma-logo80x94.png index 4af81a0..4af81a0 100644..100755 --- a/assets/image/karma-logo80x94.png +++ b/assets/image/karma-logo80x94.png Binary files differ diff --git a/assets/image/karma-new-logo.png b/assets/image/karma-new-logo.png index bb984d6..bb984d6 100644..100755 --- a/assets/image/karma-new-logo.png +++ b/assets/image/karma-new-logo.png Binary files differ diff --git a/assets/image/kids_using_xos.jpg b/assets/image/kids_using_xos.jpg index 209c70e..209c70e 100644..100755 --- a/assets/image/kids_using_xos.jpg +++ b/assets/image/kids_using_xos.jpg Binary files differ diff --git a/assets/image/largest_number136x100.png b/assets/image/largest_number136x100.png index 238270b..238270b 100644..100755 --- a/assets/image/largest_number136x100.png +++ b/assets/image/largest_number136x100.png Binary files differ diff --git a/assets/image/money_identification136x100.png b/assets/image/money_identification136x100.png index fbc546c..fbc546c 100644..100755 --- a/assets/image/money_identification136x100.png +++ b/assets/image/money_identification136x100.png Binary files differ diff --git a/assets/image/mountains.png b/assets/image/mountains.png index 103513f..103513f 100644..100755 --- a/assets/image/mountains.png +++ b/assets/image/mountains.png Binary files differ diff --git a/assets/image/numeric_puzzle136x100.png b/assets/image/numeric_puzzle136x100.png index 9cb4484..9cb4484 100644..100755 --- a/assets/image/numeric_puzzle136x100.png +++ b/assets/image/numeric_puzzle136x100.png Binary files differ diff --git a/assets/image/quads136x100.png b/assets/image/quads136x100.png index 8647c60..8647c60 100644..100755 --- a/assets/image/quads136x100.png +++ b/assets/image/quads136x100.png Binary files differ diff --git a/assets/image/screenConozco136x100.png b/assets/image/screenConozco136x100.png index 19526e1..19526e1 100644..100755 --- a/assets/image/screenConozco136x100.png +++ b/assets/image/screenConozco136x100.png Binary files differ diff --git a/assets/image/screenConozco162x100.png b/assets/image/screenConozco162x100.png index aa2f6d5..aa2f6d5 100644..100755 --- a/assets/image/screenConozco162x100.png +++ b/assets/image/screenConozco162x100.png Binary files differ diff --git a/assets/image/teacher-and-kid200x267.jpg b/assets/image/teacher-and-kid200x267.jpg index 61bdb71..61bdb71 100644..100755 --- a/assets/image/teacher-and-kid200x267.jpg +++ b/assets/image/teacher-and-kid200x267.jpg Binary files differ diff --git a/assets/image/web-bg.png b/assets/image/web-bg.png index aede98f..aede98f 100644..100755 --- a/assets/image/web-bg.png +++ b/assets/image/web-bg.png Binary files differ diff --git a/assets/image/web-bg.svg b/assets/image/web-bg.svg index b625fb9..b625fb9 100644..100755 --- a/assets/image/web-bg.svg +++ b/assets/image/web-bg.svg diff --git a/bin/kbuild.js b/bin/kbuild.js index e1623cf..e1623cf 100644..100755 --- a/bin/kbuild.js +++ b/bin/kbuild.js diff --git a/css/intro.css b/css/intro.css index 6b8be70..6b8be70 100644..100755 --- a/css/intro.css +++ b/css/intro.css diff --git a/docs/files.html b/docs/files.html index 0e41efa..bc99bdf 100644..100755 --- a/docs/files.html +++ b/docs/files.html @@ -228,7 +228,7 @@ Contains karma library
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:15 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:07 GMT+0545 (NPT)
\ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 54f22ec..a379c90 100644..100755 --- a/docs/index.html +++ b/docs/index.html @@ -265,7 +265,7 @@ to Karma in the Karma() method
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:15 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:07 GMT+0545 (NPT)
\ No newline at end of file diff --git a/docs/symbols/Karma.html b/docs/symbols/Karma.html index 63a4dc6..082413c 100644..100755 --- a/docs/symbols/Karma.html +++ b/docs/symbols/Karma.html @@ -306,6 +306,24 @@ this library <static>   +
Karma.distance(Point, Point) +
+
Gets the Euclidian (ordinary) distance between 2 points.
+ + + + + <static>   + +
Karma.distance2(Point, Point) +
+
Gets the square of the Euclidian (ordinary) distance between 2 points.
+ + + + + <static>   +
Karma.objectPlus(target, source)
Extends properties of the target object with those of @@ -313,6 +331,24 @@ the source object
+ + <static>   + +
Karma.radians(angle) +
+
Converts a value from degrees to radians.
+ + + + + <static>   + +
Karma.rand(lower, upper) +
+
Returns a random number within the range provided
+ + + @@ -621,6 +657,167 @@ ninja1.weapon === "sword"
+ +
<static> + + {Number} + Karma.distance(Point, Point) + +
+
+ Gets the Euclidian (ordinary) distance between 2 points.
+Warning: It's slower than distance2 function + + +
+ + + +
+p0 = {x:0, y:1};
+p1 = {x:50, y:70};
+var d = distance2(p0, p1);
+ + + + +
+
Parameters:
+ +
+ {Object} Point + +
+
No. 0
+ +
+ {Number} Point0.x + +
+
+ +
+ {Number} Point0.y + +
+
+ +
+ {Object} Point + +
+
No. 1
+ +
+ {Number} Point1.x + +
+
+ +
+ {Number} Point1.y + +
+
+ +
+ + + + + +
+
Returns:
+ +
{Number} The Euclidian distance
+ +
+ + + + +
+ + +
<static> + + {Number} + Karma.distance2(Point, Point) + +
+
+ Gets the square of the Euclidian (ordinary) distance between 2 points. + + +
+ + + +
+p0 = {x:0, y:1};
+p1 = {x:50, y:70};
+var d = distance2(p0, p1);
+ + + + +
+
Parameters:
+ +
+ {Object} Point + +
+
No. 0
+ +
+ {Number} Point0.x + +
+
+ +
+ {Number} Point0.y + +
+
+ +
+ {Object} Point + +
+
No. 1
+ +
+ {Number} Point1.x + +
+
+ +
+ {Number} Point1.y + +
+
+ +
+ + + + + +
+
Returns:
+ +
{Number} The square of the Euclidian distance
+ +
+ + + + +
+
<static> @@ -669,6 +866,105 @@ the source object +
+ + +
<static> + + {Number} + Karma.radians(angle) + +
+
+ Converts a value from degrees to radians. + + +
+ + + + +
+
Parameters:
+ +
+ {Number} angle + +
+
The angle in degrees
+ +
+ + + + + +
+
Returns:
+ +
{Number} The angle in radians
+ +
+ + + + +
+ + +
<static> + + {Number} + Karma.rand(lower, upper) + +
+
+ Returns a random number within the range provided + + +
+ + + +
+var num = rand(0, 10);
+
+//num could be 0, 1, 2, 3 ... or 10
+ + + + +
+
Parameters:
+ +
+ {Number} lower + +
+
limit of the range, lowest number that can be returned
+ +
+ {Number} upper + +
+
limit of the range, highest number that can be returned
+ +
+ + + + + +
+
Returns:
+ +
{Number} number that is >= lower and <= upper
+ +
+ + + + @@ -683,7 +979,7 @@ the source object
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:12 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:04 GMT+0545 (NPT)
diff --git a/docs/symbols/Karma.kAudio.html b/docs/symbols/Karma.kAudio.html index 7744ef7..0ec3fed 100644..100755 --- a/docs/symbols/Karma.kAudio.html +++ b/docs/symbols/Karma.kAudio.html @@ -493,7 +493,7 @@ via the media property of kAudio. Read more about the properties of the
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:12 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:04 GMT+0545 (NPT)
diff --git a/docs/symbols/Karma.kCanvas.html b/docs/symbols/Karma.kCanvas.html index b8bc87a..87a9952 100644..100755 --- a/docs/symbols/Karma.kCanvas.html +++ b/docs/symbols/Karma.kCanvas.html @@ -3393,7 +3393,7 @@ alphabetic, ideographic, or bottom, then the value must be changed to the new va
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:15 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:07 GMT+0545 (NPT)
diff --git a/docs/symbols/Karma.kImage.html b/docs/symbols/Karma.kImage.html index 474dde8..b634793 100644..100755 --- a/docs/symbols/Karma.kImage.html +++ b/docs/symbols/Karma.kImage.html @@ -430,7 +430,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:15 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:07 GMT+0545 (NPT)
diff --git a/docs/symbols/Karma.kSvg.html b/docs/symbols/Karma.kSvg.html index 67a7995..5f47f1b 100644..100755 --- a/docs/symbols/Karma.kSvg.html +++ b/docs/symbols/Karma.kSvg.html @@ -715,7 +715,7 @@ $('#someId', Karma.karma.svg.someSvg.root).css(.. manipulate css attributes ...)
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:15 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:07 GMT+0545 (NPT)
diff --git a/docs/symbols/Karma.kVideo.html b/docs/symbols/Karma.kVideo.html index 839b48b..5b204df 100644..100755 --- a/docs/symbols/Karma.kVideo.html +++ b/docs/symbols/Karma.kVideo.html @@ -425,7 +425,7 @@ to Karma in the Karma() method
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:15 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:07 GMT+0545 (NPT)
diff --git a/docs/symbols/Karma.karma.html b/docs/symbols/Karma.karma.html index 972c281..96a34a4 100644..100755 --- a/docs/symbols/Karma.karma.html +++ b/docs/symbols/Karma.karma.html @@ -357,42 +357,6 @@ methods added to each reference
<static>   -
Karma.karma.distance(Point, Point) -
-
Gets the Euclidian (ordinary) distance between 2 points.
- - - - - <static>   - -
Karma.karma.distance2(Point, Point) -
-
Gets the square of the Euclidian (ordinary) distance between 2 points.
- - - - - <static>   - -
Karma.karma.radians(angle) -
-
Converts a value from degrees to radians.
- - - - - <static>   - -
Karma.karma.rand(lower, upper) -
-
Returns a random number within the range provided
- - - - - <static>   -
Karma.karma.ready(cb)
Waits until all assets loaded(ready), then calls callback cb
@@ -632,266 +596,6 @@ methods added to each reference Method Detail - -
<static> - - {Number} - Karma.karma.distance(Point, Point) - -
-
- Gets the Euclidian (ordinary) distance between 2 points.
-Warning: It's slower than distance2 function - - -
- - - -
-p0 = {x:0, y:1};
-p1 = {x:50, y:70};
-var d = distance2(p0, p1);
- - - - -
-
Parameters:
- -
- {Object} Point - -
-
No. 0
- -
- {Number} Point0.x - -
-
- -
- {Number} Point0.y - -
-
- -
- {Object} Point - -
-
No. 1
- -
- {Number} Point1.x - -
-
- -
- {Number} Point1.y - -
-
- -
- - - - - -
-
Returns:
- -
{Number} The Euclidian distance
- -
- - - - -
- - -
<static> - - {Number} - Karma.karma.distance2(Point, Point) - -
-
- Gets the square of the Euclidian (ordinary) distance between 2 points. - - -
- - - -
-p0 = {x:0, y:1};
-p1 = {x:50, y:70};
-var d = distance2(p0, p1);
- - - - -
-
Parameters:
- -
- {Object} Point - -
-
No. 0
- -
- {Number} Point0.x - -
-
- -
- {Number} Point0.y - -
-
- -
- {Object} Point - -
-
No. 1
- -
- {Number} Point1.x - -
-
- -
- {Number} Point1.y - -
-
- -
- - - - - -
-
Returns:
- -
{Number} The square of the Euclidian distance
- -
- - - - -
- - -
<static> - - {Number} - Karma.karma.radians(angle) - -
-
- Converts a value from degrees to radians. - - -
- - - - -
-
Parameters:
- -
- {Number} angle - -
-
The angle in degrees
- -
- - - - - -
-
Returns:
- -
{Number} The angle in radians
- -
- - - - -
- - -
<static> - - {Number} - Karma.karma.rand(lower, upper) - -
-
- Returns a random number within the range provided - - -
- - - -
-var num = rand(0, 10);
-
-//num could be 0, 1, 2, 3 ... or 10
- - - - -
-
Parameters:
- -
- {Number} lower - -
-
limit of the range, lowest number that can be returned
- -
- {Number} upper - -
-
limit of the range, highest number that can be returned
- -
- - - - - -
-
Returns:
- -
{Number} number that is >= lower and <= upper
- -
- - - - -
-
<static> @@ -967,7 +671,7 @@ Karma({ options }) function
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:12 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:04 GMT+0545 (NPT)
diff --git a/docs/symbols/_global_.html b/docs/symbols/_global_.html index 445b585..e52648a 100644..100755 --- a/docs/symbols/_global_.html +++ b/docs/symbols/_global_.html @@ -257,7 +257,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.3.2 on Sun Jan 03 2010 14:36:12 GMT+0545 (NPT) + Documentation generated by JsDoc Toolkit 2.3.2 on Mon Jan 04 2010 19:20:03 GMT+0545 (NPT)
diff --git a/docs/symbols/src/js_karma.js.html b/docs/symbols/src/js_karma.js.html index 992b641..9e3da46 100644..100755 --- a/docs/symbols/src/js_karma.js.html +++ b/docs/symbols/src/js_karma.js.html @@ -203,1456 +203,1470 @@ 196 } 197 }; 198 -199 -200 /** Stores global settings for the Karma library -201 * @class This object stores the global settings for the Karma library -202 */ -203 Karma.karma = { -204 /** This is the global locale as passed to Karma(), -205 * such as "en", "es_SP" -206 * @property {string} locale This is the global locale as passed to Karma() -207 * @default undefined -208 */ -209 locale : undefined, -210 /** Collection of images with special helper -211 * methods added to each reference -212 * @type object -213 * @default empty object -214 */ -215 image : {}, -216 /** Collection of audio files with special helper -217 * methods added to each reference -218 * @type object -219 * @default empty object -220 */ -221 audio : {}, -222 /** Collection of html 5 canvases with special helper -223 * methods added to each reference -224 * @type object -225 * @default empty object -226 */ -227 canvas : {}, -228 /** Collection of svgs with special helper -229 * methods added to each reference -230 * @type object -231 * @default empty object -232 */ -233 svg : {}, -234 /** Collection of videos with special helper -235 * methods added to each reference -236 * @type object -237 * @default empty object -238 */ -239 video : {}, -240 _localized : false, -241 _assetPath : "assets/", -242 _localePath : "", -243 _initialized : false, -244 _statusDiv: undefined, -245 _loaderDiv : undefined, -246 _counters : { total : 0, errors : 0, loaded : 0}, -247 -248 //This constructs the Karma.karma object per values provided by the user -249 _init: function(options) { -250 this._initialized = true; -251 -252 //set up message that show count of assets loaded -253 //and has an ordered list to append error messages to -254 var _statusDiv = this._statusDiv = document.createElement('div'); -255 this._loaderDiv = this._loaderDiv = document.createElement('div'); -256 var errorList = document.createElement('ol'); -257 -258 _statusDiv.setAttribute('id', 'karma-status'); -259 _statusDiv.setAttribute('style', 'position:absolute;'); -260 _statusDiv.innerHTML = 'Karma is loading ...'; -261 this._loaderDiv.setAttribute('id', 'karma-loader'); -262 this._loaderDiv.setAttribute('class', 'status'); -263 errorList.setAttribute('id', 'errorList'); -264 -265 _statusDiv.appendChild(this._loaderDiv); -266 this._statusDiv.appendChild(errorList); -267 document.body.appendChild(_statusDiv); -268 -269 //regular expression that matches the name of aprivate property -270 // the karma object -271 var regexPrivate = new RegExp('^_.*'); -272 -273 for ( var option in options ) { -274 if (options.hasOwnProperty(option)){ -275 if (option === "image" || option === "audio" || option === -276 "svg" || option === "video" || option === "canvas"){ -277 -278 if(!(options[option] instanceof Array)){ -279 throw new Error("" + option + " must be an array"); -280 } else if (options[option].length === 0){ -281 continue; -282 } -283 } else if (regexPrivate.test(option)){ -284 //don't overwrite a private property of karma object -285 continue; -286 } -287 -288 switch (option){ -289 case "locale": -290 -291 if (this._isValidLocale(options[option])){ -292 this.locale = this._normalizeLocale(options[option]); -293 this._localized = true; -294 this._localePath = Karma._computeLocalePath(this.locale); -295 } else { -296 throw new Error("locale provided to karma._init() is invalid"); -297 } -298 -299 break; -300 case "image": -301 options[option]._type = 'image'; -302 Karma._makeCollection(options[option], 'image'); -303 break; -304 case "audio": -305 options[option]._type = 'audio'; -306 Karma._makeCollection(options[option], 'audio'); -307 break; -308 case "video": -309 options[option]._type = 'video'; -310 Karma._makeCollection(options[option], 'video'); -311 break; -312 case "svg": -313 options[option]._type = 'svg'; -314 Karma._makeCollection(options[option], 'svg'); -315 break; -316 case "canvas": -317 options[option]._type = 'canvas'; -318 Karma._makeCollection(options[option], 'canvas'); -319 break; -320 } -321 } -322 } +199 Karma.shuffle = function (choices) { +200 for(var i=0;i<choices.length;i++) { +201 var num = Karma.rand(0,choices.length-1); +202 var temp = choices[i]; +203 choices[i]=choices[num]; +204 choices[num]=temp; +205 } +206 }; +207 +208 // Below are geometry and math helper methods +209 +210 /** +211 * Converts a value from degrees to radians. +212 * @param {Number} angle The angle in degrees +213 * @returns {Number} The angle in radians +214 */ +215 Karma.radians = function( angle ){ +216 return ( angle / 180 ) * Math.PI; +217 }; +218 +219 /** +220 * Gets the square of the Euclidian (ordinary) distance between 2 points. +221 * @param {Object} Point No. 0 +222 * @param {Number} Point0.x +223 * @param {Number} Point0.y +224 * @param {Object} Point No. 1 +225 * @param {Number} Point1.x +226 * @param {Number} Point1.y +227 * @returns {Number} The square of the Euclidian distance +228 * @example +229 * +230 * p0 = {x:0, y:1}; +231 * p1 = {x:50, y:70}; +232 * var d = distance2(p0, p1); +233 * +234 */ +235 Karma.distance2 = function ( p0, p1 ) { +236 return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y); +237 }; +238 +239 /** +240 * Gets the Euclidian (ordinary) distance between 2 points.<br> +241 * <b>Warning:</b> It's slower than distance2 function +242 * @param {Object} Point No. 0 +243 * @param {Number} Point0.x +244 * @param {Number} Point0.y +245 * @param {Object} Point No. 1 +246 * @param {Number} Point1.x +247 * @param {Number} Point1.y +248 * @returns {Number} The Euclidian distance +249 * @example +250 * +251 * p0 = {x:0, y:1}; +252 * p1 = {x:50, y:70}; +253 * var d = distance2(p0, p1); +254 * +255 */ +256 Karma.distance = function ( p0, p1 ) { +257 return Math.sqrt( this.distance2( p0, p1 ) ); +258 }; +259 +260 /** Returns a random number within the range provided +261 * @param {Number} lower limit of the range, lowest number that can be returned +262 * @param {Number} upper limit of the range, highest number that can be returned +263 * @returns {Number} number that is >= lower and <= upper +264 * @example +265 * +266 * var num = rand(0, 10); +267 * +268 * //num could be 0, 1, 2, 3 ... or 10 +269 * +270 */ +271 Karma.rand = function ( lower, upper ){ +272 return Math.round( Math.random() * (upper - lower) + lower ); +273 }; +274 +275 +276 /** Stores global settings for the Karma library +277 * @class This object stores the global settings for the Karma library +278 */ +279 Karma.karma = { +280 /** This is the global locale as passed to Karma(), +281 * such as "en", "es_SP" +282 * @property {string} locale This is the global locale as passed to Karma() +283 * @default undefined +284 */ +285 locale : undefined, +286 /** Collection of images with special helper +287 * methods added to each reference +288 * @type object +289 * @default empty object +290 */ +291 image : {}, +292 /** Collection of audio files with special helper +293 * methods added to each reference +294 * @type object +295 * @default empty object +296 */ +297 audio : {}, +298 /** Collection of html 5 canvases with special helper +299 * methods added to each reference +300 * @type object +301 * @default empty object +302 */ +303 canvas : {}, +304 /** Collection of svgs with special helper +305 * methods added to each reference +306 * @type object +307 * @default empty object +308 */ +309 svg : {}, +310 /** Collection of videos with special helper +311 * methods added to each reference +312 * @type object +313 * @default empty object +314 */ +315 video : {}, +316 _localized : false, +317 _assetPath : "assets/", +318 _localePath : "", +319 _initialized : false, +320 _statusDiv: undefined, +321 _loaderDiv : undefined, +322 _counters : { total : 0, errors : 0, loaded : 0}, 323 -324 -325 -326 return this; -327 }, -328 -329 /** Waits until all assets loaded(ready), then calls callback cb -330 * @param {Function} [cb] callback function -331 * @returns this -332 * @throws {Error} if Karma.karma is not initialized with the -333 * Karma({ options }) function -334 * @example -335 * -336 * var k = Karma({ . . . your assets here . . . }); -337 * k.ready(function(){ .. your code here . . .}); -338 * -339 * your code will not be called until all assets have been loaded -340 * into collections -341 * -342 */ -343 ready : function( cb ) { -344 var that = this; -345 if (Karma.karma._initialized !== true){ -346 throw new Error("Karma.karma not initialized"); -347 } -348 -349 if (this._counters.loaded !== this._counters.total){ -350 setTimeout(function(){ that.ready(cb);}, 5); -351 } else if (cb) { -352 //hide the "Karma is loading..." message -353 this._statusDiv.setAttribute('style', 'display:none;'); -354 -355 cb(); -356 } else if (!cb) { -357 //hide the "Karma is loading..." message -358 this._statusDiv.setAttribute('style', 'display:none;'); -359 -360 //if no options passed, show it works message -361 this._showStarterMessage(); -362 } -363 -364 -365 +324 //This constructs the Karma.karma object per values provided by the user +325 _init: function(options) { +326 this._initialized = true; +327 +328 //set up message that show count of assets loaded +329 //and has an ordered list to append error messages to +330 var _statusDiv = this._statusDiv = document.createElement('div'); +331 this._loaderDiv = this._loaderDiv = document.createElement('div'); +332 var errorList = document.createElement('ol'); +333 +334 _statusDiv.setAttribute('id', 'karma-status'); +335 _statusDiv.setAttribute('style', 'position:absolute;'); +336 _statusDiv.innerHTML = 'Karma is loading ...'; +337 this._loaderDiv.setAttribute('id', 'karma-loader'); +338 this._loaderDiv.setAttribute('class', 'status'); +339 errorList.setAttribute('id', 'errorList'); +340 +341 _statusDiv.appendChild(this._loaderDiv); +342 this._statusDiv.appendChild(errorList); +343 document.body.appendChild(_statusDiv); +344 +345 //regular expression that matches the name of aprivate property +346 // the karma object +347 var regexPrivate = new RegExp('^_.*'); +348 +349 for ( var option in options ) { +350 if (options.hasOwnProperty(option)){ +351 if (option === "image" || option === "audio" || option === +352 "svg" || option === "video" || option === "canvas"){ +353 +354 if(!(options[option] instanceof Array)){ +355 throw new Error("" + option + " must be an array"); +356 } else if (options[option].length === 0){ +357 continue; +358 } +359 } else if (regexPrivate.test(option)){ +360 //don't overwrite a private property of karma object +361 continue; +362 } +363 +364 switch (option){ +365 case "locale": 366 -367 return this; -368 }, -369 -370 //Display Apache-like "It works" message if no options -371 _showStarterMessage : function (){ -372 var starterMsg = document.createElement('div'); -373 starterMsg.setAttribute('id', 'starterMsg'); -374 starterMsg.innerHTML = "<h1>It Works</h1>"; -375 document.body.appendChild(starterMsg); -376 }, -377 -378 //Updates visible counter of how many assets are loaded -379 _updateStatus : function (errorMsg) { -380 var loaded = this._counters.loaded; -381 var total = this._counters.total; -382 var errors = this._counters.errors; -383 this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total + -384 "" + (errors > 0 ? " Errors [ " + errors +" ]" : ''); -385 if (errorMsg) { -386 var liError = document.createElement('li'); -387 liError.innerHTML = errorMsg; -388 var errorList = document.getElementById('errorList'); -389 errorList.appendChild(liError); -390 } -391 }, -392 -393 //matches 2 letter country code then optionally -394 //a dash or underscore followed by a country or language identifier -395 //i currently only allow a language identifier 2-3 chars long -396 _isValidLocale : function (locale) { -397 var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$'); -398 return localeRegex.test(locale); -399 }, +367 if (this._isValidLocale(options[option])){ +368 this.locale = this._normalizeLocale(options[option]); +369 this._localized = true; +370 this._localePath = Karma._computeLocalePath(this.locale); +371 } else { +372 throw new Error("locale provided to karma._init() is invalid"); +373 } +374 +375 break; +376 case "image": +377 options[option]._type = 'image'; +378 Karma._makeCollection(options[option], 'image'); +379 break; +380 case "audio": +381 options[option]._type = 'audio'; +382 Karma._makeCollection(options[option], 'audio'); +383 break; +384 case "video": +385 options[option]._type = 'video'; +386 Karma._makeCollection(options[option], 'video'); +387 break; +388 case "svg": +389 options[option]._type = 'svg'; +390 Karma._makeCollection(options[option], 'svg'); +391 break; +392 case "canvas": +393 options[option]._type = 'canvas'; +394 Karma._makeCollection(options[option], 'canvas'); +395 break; +396 } +397 } +398 } +399 400 -401 _normalizeLocale : function(locale) { -402 var lang = ""; -403 var country = ""; -404 var divider = ""; -405 -406 lang = locale.slice(0, 2).toLowerCase(); -407 divider = "_"; -408 country = locale.slice(3, 6).toUpperCase(); -409 -410 return locale.length > 2 ? "" + lang + divider + country : lang; -411 }, -412 -413 // Below are geometry and math helper methods -414 -415 /** -416 * Converts a value from degrees to radians. -417 * @param {Number} angle The angle in degrees -418 * @returns {Number} The angle in radians -419 */ -420 radians : function( angle ){ -421 return ( angle / 180 ) * Math.PI; -422 }, -423 /** -424 * Gets the square of the Euclidian (ordinary) distance between 2 points. -425 * @param {Object} Point No. 0 -426 * @param {Number} Point0.x -427 * @param {Number} Point0.y -428 * @param {Object} Point No. 1 -429 * @param {Number} Point1.x -430 * @param {Number} Point1.y -431 * @returns {Number} The square of the Euclidian distance -432 * @example -433 * -434 * p0 = {x:0, y:1}; -435 * p1 = {x:50, y:70}; -436 * var d = distance2(p0, p1); -437 * -438 */ -439 distance2 : function ( p0, p1 ) { -440 return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y); -441 }, -442 /** -443 * Gets the Euclidian (ordinary) distance between 2 points.<br> -444 * <b>Warning:</b> It's slower than distance2 function -445 * @param {Object} Point No. 0 -446 * @param {Number} Point0.x -447 * @param {Number} Point0.y -448 * @param {Object} Point No. 1 -449 * @param {Number} Point1.x -450 * @param {Number} Point1.y -451 * @returns {Number} The Euclidian distance -452 * @example -453 * -454 * p0 = {x:0, y:1}; -455 * p1 = {x:50, y:70}; -456 * var d = distance2(p0, p1); -457 * -458 */ -459 distance : function ( p0, p1 ) { -460 return Math.sqrt( this.distance2( p0, p1 ) ); -461 }, -462 /** Returns a random number within the range provided -463 * @param {Number} lower limit of the range, lowest number that can be returned -464 * @param {Number} upper limit of the range, highest number that can be returned -465 * @returns {Number} number that is >= lower and <= upper -466 * @example -467 * -468 * var num = rand(0, 10); -469 * -470 * //num could be 0, 1, 2, 3 ... or 10 -471 * -472 */ -473 rand : function ( lower, upper ){ -474 return Math.round( Math.random() * (upper - lower) + lower ); -475 } -476 -477 }; -478 -479 //Helper functions for creating assets -480 -481 Karma._isLocalized = function (boolLocalized) { -482 if (typeof boolLocalized === "boolean" ) { -483 if(boolLocalized === true && -484 Karma.karma.locale === undefined){ -485 throw new Error("You cannot localize a media asset" + -486 " if the global locale for Karma isn't set"); -487 } else { -488 return boolLocalized; -489 } -490 } else if (typeof boolLocalized === undefined){ -491 return false; -492 } else{ -493 throw new Error("This is not a valid value for the localized option"); -494 } -495 }; -496 -497 Karma._computeLocalePath = function(locale) { -498 return Karma.karma._assetPath + locale + "/"; -499 }; -500 -501 -502 -503 -504 Karma._makeCollection = function (configs, type){ -505 var makeAsset = function (config){ -506 var asset = undefined; -507 var target = undefined; -508 switch(type){ -509 case "image": -510 target = Karma.kImage; -511 break; -512 case "audio": -513 target = Karma.kAudio; -514 break; -515 case "video": -516 target = Karma.kVideo; -517 break; -518 case "svg": -519 target = Karma.kSvg; -520 break; -521 case "canvas": -522 target = Karma.kCanvas; -523 break; -524 } -525 -526 asset = Karma.create(target)._init(config); -527 Karma.karma[type][config.name] = asset; -528 }; -529 -530 configs.forEach(function(config){ makeAsset(config);}); -531 }; -532 -533 -534 -535 -536 -537 //Prototype objects for assets -538 +401 +402 return this; +403 }, +404 +405 /** Waits until all assets loaded(ready), then calls callback cb +406 * @param {Function} [cb] callback function +407 * @returns this +408 * @throws {Error} if Karma.karma is not initialized with the +409 * Karma({ options }) function +410 * @example +411 * +412 * var k = Karma({ . . . your assets here . . . }); +413 * k.ready(function(){ .. your code here . . .}); +414 * +415 * your code will not be called until all assets have been loaded +416 * into collections +417 * +418 */ +419 ready : function( cb ) { +420 var that = this; +421 if (Karma.karma._initialized !== true){ +422 throw new Error("Karma.karma not initialized"); +423 } +424 +425 if (this._counters.loaded !== this._counters.total){ +426 setTimeout(function(){ that.ready(cb);}, 5); +427 } else if (cb) { +428 //hide the "Karma is loading..." message +429 this._statusDiv.setAttribute('style', 'display:none;'); +430 +431 cb(); +432 } else if (!cb) { +433 //hide the "Karma is loading..." message +434 this._statusDiv.setAttribute('style', 'display:none;'); +435 +436 //if no options passed, show it works message +437 this._showStarterMessage(); +438 } +439 +440 +441 +442 +443 return this; +444 }, +445 +446 //Display Apache-like "It works" message if no options +447 _showStarterMessage : function (){ +448 var starterMsg = document.createElement('div'); +449 starterMsg.setAttribute('id', 'starterMsg'); +450 starterMsg.innerHTML = "<h1>It Works</h1>"; +451 document.body.appendChild(starterMsg); +452 }, +453 +454 //Updates visible counter of how many assets are loaded +455 _updateStatus : function (errorMsg) { +456 var loaded = this._counters.loaded; +457 var total = this._counters.total; +458 var errors = this._counters.errors; +459 this._loaderDiv.innerHTML = "Loaded " + loaded + " / " + total + +460 "" + (errors > 0 ? " Errors [ " + errors +" ]" : ''); +461 if (errorMsg) { +462 var liError = document.createElement('li'); +463 liError.innerHTML = errorMsg; +464 var errorList = document.getElementById('errorList'); +465 errorList.appendChild(liError); +466 } +467 }, +468 +469 //matches 2 letter country code then optionally +470 //a dash or underscore followed by a country or language identifier +471 //i currently only allow a language identifier 2-3 chars long +472 _isValidLocale : function (locale) { +473 var localeRegex = new RegExp('^[a-zA-Z][a-zA-Z]([-_][a-zA-z]{2,3})?$'); +474 return localeRegex.test(locale); +475 }, +476 +477 _normalizeLocale : function(locale) { +478 var lang = ""; +479 var country = ""; +480 var divider = ""; +481 +482 lang = locale.slice(0, 2).toLowerCase(); +483 divider = "_"; +484 country = locale.slice(3, 6).toUpperCase(); +485 +486 return locale.length > 2 ? "" + lang + divider + country : lang; +487 }, +488 +489 +490 +491 }; +492 +493 //Helper functions for creating assets +494 +495 Karma._isLocalized = function (boolLocalized) { +496 if (typeof boolLocalized === "boolean" ) { +497 if(boolLocalized === true && +498 Karma.karma.locale === undefined){ +499 throw new Error("You cannot localize a media asset" + +500 " if the global locale for Karma isn't set"); +501 } else { +502 return boolLocalized; +503 } +504 } else if (typeof boolLocalized === undefined){ +505 return false; +506 } else{ +507 throw new Error("This is not a valid value for the localized option"); +508 } +509 }; +510 +511 Karma._computeLocalePath = function(locale) { +512 return Karma.karma._assetPath + locale + "/"; +513 }; +514 +515 +516 +517 +518 Karma._makeCollection = function (configs, type){ +519 var makeAsset = function (config){ +520 var asset = undefined; +521 var target = undefined; +522 switch(type){ +523 case "image": +524 target = Karma.kImage; +525 break; +526 case "audio": +527 target = Karma.kAudio; +528 break; +529 case "video": +530 target = Karma.kVideo; +531 break; +532 case "svg": +533 target = Karma.kSvg; +534 break; +535 case "canvas": +536 target = Karma.kCanvas; +537 break; +538 } 539 -540 /** Prototype object for images -541 * @class This object is the prototype for images submitted to Karma in the -542 * Karma() method -543 * @ throws {Error} if the image asset is set to be localized but -544 * the global locale is not set on the Karma.karma object -545 * @ throws {Error} if the name and file properties are not supplied -546 * @example -547 * kImage is the prototype object for images. This 'media' asset is loaded -548 * in a distinctly different way from the canvas or svg assets. -549 * -550 */ -551 Karma.kImage = -552 { -553 /** file location of image -554 * @type String -555 * @default "" -556 */ -557 file : "", -558 /** media object -559 * @type Image -560 * @default undefined -561 */ -562 media : undefined, -563 //actual path to the file -564 _path : "", -565 //if using localized version of this image -566 _localized : false, -567 _type : "image", -568 //initializes kImage instance with values provided by user -569 _init : function (image) { -570 image._localized = image._localized || false; -571 Karma.karma._counters.total++; -572 -573 if (image.name === undefined || image.file === undefined){ -574 throw new Error("properties name and file have to be defined"); -575 } else { -576 this.name = image.name; -577 this.file = image.file; -578 } -579 -580 this.media = new Image(); -581 -582 if(Karma._isLocalized(image._localized)){ -583 this._localized = image._localized; -584 this._path = Karma.karma._localePath + "image/"; -585 } else { -586 this._path = Karma.karma._assetPath + "image/"; -587 } -588 -589 //IMPORTANT: This one magic line loads the file -590 this.media.src = this.src = this._path + this.file; -591 -592 //add event handlers -593 this._addEventHandlers(); -594 -595 -596 return this; -597 }, -598 //Adds event handlers to update the counters when -599 //the image is successfully or unsuccessfully loaded -600 _addEventHandlers : function () { -601 var that = this; +540 asset = Karma.create(target)._init(config); +541 Karma.karma[type][config.name] = asset; +542 }; +543 +544 configs.forEach(function(config){ makeAsset(config);}); +545 }; +546 +547 +548 +549 +550 +551 //Prototype objects for assets +552 +553 +554 /** Prototype object for images +555 * @class This object is the prototype for images submitted to Karma in the +556 * Karma() method +557 * @ throws {Error} if the image asset is set to be localized but +558 * the global locale is not set on the Karma.karma object +559 * @ throws {Error} if the name and file properties are not supplied +560 * @example +561 * kImage is the prototype object for images. This 'media' asset is loaded +562 * in a distinctly different way from the canvas or svg assets. +563 * +564 */ +565 Karma.kImage = +566 { +567 /** file location of image +568 * @type String +569 * @default "" +570 */ +571 file : "", +572 /** media object +573 * @type Image +574 * @default undefined +575 */ +576 media : undefined, +577 //actual path to the file +578 _path : "", +579 //if using localized version of this image +580 _localized : false, +581 _type : "image", +582 //initializes kImage instance with values provided by user +583 _init : function (image) { +584 image._localized = image._localized || false; +585 Karma.karma._counters.total++; +586 +587 if (image.name === undefined || image.file === undefined){ +588 throw new Error("properties name and file have to be defined"); +589 } else { +590 this.name = image.name; +591 this.file = image.file; +592 } +593 +594 this.media = new Image(); +595 +596 if(Karma._isLocalized(image._localized)){ +597 this._localized = image._localized; +598 this._path = Karma.karma._localePath + "image/"; +599 } else { +600 this._path = Karma.karma._assetPath + "image/"; +601 } 602 -603 that.media.addEventListener( -604 "load", -605 function (e) { -606 Karma.karma._counters.loaded++; -607 Karma.karma._updateStatus(); -608 that.status = "loaded";}, false); +603 //IMPORTANT: This one magic line loads the file +604 this.media.src = this.src = this._path + this.file; +605 +606 //add event handlers +607 this._addEventHandlers(); +608 609 -610 that.media.addEventListener( -611 "error", -612 function (e) { -613 Karma.karma._counters.errors++; -614 that.status = "error"; -615 var errorMsg = "Error: " + that._type.toUpperCase() + -616 " " + that.name + " cannot be loaded."; -617 Karma.karma._updateStatus(errorMsg); -618 }, -619 false); -620 that.media.addEventListener( -621 "abort", -622 function (e) { -623 Karma.karma._counters.total++; -624 that.status = "aborted"; -625 var errorMsg = "ABORT: " + that._type.toUpperCase() + -626 " " + that.name + " loading was aborted."; -627 Karma.karma._updateStatus(errorMsg); -628 -629 }, false); -630 } -631 -632 }; -633 -634 /** Prototype object for audio files -635 * @class This object is the prototype for audio files submitted to Karma in the -636 * Karma() method -637 * @ throws {Error} if the individual audio asset is set to be localized but -638 * the globale locale is not set on the Karma.karma object -639 * @ throws {Error} if the name and file properties are not supplied -640 * @example -641 * kAudio is the prototype object for audio -642 * The audio assets are loaded in a distinctly different way -643 * from the canvas or svg assets. They also have distinctly different -644 * helper methods -645 * -646 * You initialize the kAudio assets by passing an array of objects -647 */ -648 Karma.kAudio = { -649 /** file location of asset -650 * @type String -651 * @default "" -652 */ -653 file : "", -654 /** Media object. You can access the src, autobuffer, autoplay, loop, and -655 * controls attributes -656 * via the media property of kAudio. Read more about the properties of the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#media-element-attributes">HTML 5 media element</a> -657 * @type Audio -658 * @default undefined -659 */ -660 media : undefined, -661 //actual path to the file -662 _path : "", -663 //if using localized version of this asset -664 _localized : false, -665 _type : "audio", -666 //initializes kAudio instance with values provided by user -667 _init : function (audio) { -668 audio._localized = audio._localized || false; -669 Karma.karma._counters.total++; -670 -671 if (audio.name === undefined || audio.file === undefined){ -672 throw new Error("properties name and file have to be defined"); -673 } else { -674 this.name = audio.name; -675 this.file = audio.file; -676 } -677 -678 this.media = new Audio(); -679 -680 if(Karma._isLocalized(audio._localized)){ -681 this._localized = audio._localized; -682 this._path = Karma.karma._localePath + "audio/"; -683 } else { -684 this._path = Karma.karma._assetPath + "audio/"; -685 } -686 -687 -688 //IMPORTANT: This one magic line loads the file -689 this.media.src = this.src = this._path + this.file; -690 -691 //add event handlers -692 this._addEventHandlers(); -693 -694 if (this._type === "audio"){ -695 this.media.autobuffer = true; -696 this.media.load(); -697 } -698 -699 -700 return this; -701 }, -702 //Adds event handlers to update the counters when -703 //the asset is successfully or unsuccessfully loaded -704 _addEventHandlers : function () { -705 var that = this; -706 //'canplaythrough' event is a Browser Hack recommended by chromium devs -707 //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4 -708 -709 that.media.addEventListener( -710 "canplaythrough", -711 function (e) { -712 Karma.karma._counters.loaded++; -713 Karma.karma._updateStatus(); -714 that.status = "loaded";}, false); -715 -716 that.media.addEventListener( -717 "error", -718 function (e) { -719 Karma.karma._counters.errors++; -720 that.status = "error"; -721 var errorMsg = "Error: " + that._type.toUpperCase() + -722 " " + that.name + " cannot be loaded."; -723 Karma.karma._updateStatus(errorMsg); -724 }, -725 false); -726 that.media.addEventListener( -727 "abort", -728 function (e) { -729 Karma.karma._counters.total++; -730 that.status = "aborted"; -731 var errorMsg = "ABORT: " + that._type.toUpperCase() + -732 " " + that.name + " loading was aborted."; -733 Karma.karma._updateStatus(errorMsg); -734 -735 }, false); -736 -737 }, -738 /** Plays the audio file */ -739 play : function () { -740 this.media.play(); -741 } -742 -743 }; -744 -745 /** NYI:Prototype object for Video files -746 * @class Not Yet Implemented:This object is the prototype for video files submitted -747 * to Karma in the Karma() method -748 * @ throws {Error} if the individual video asset is set to be localized but -749 * the globale locale is not set on the Karma.karma object -750 * @ throws {Error} if the name and file properties are not supplied -751 */ -752 Karma.kVideo = { -753 /** file location of asset -754 * @type String -755 * @default "" -756 */ -757 file : "", -758 /** media object -759 * @type Video -760 * @default undefined -761 */ -762 media : undefined, -763 //actual path to the file -764 _path : "", -765 //if using localized version of this asset -766 _localized : false, -767 _type : "video", -768 //initializes kVideo instance with values provided by user -769 _init : function (video) { -770 //Not Yet Implemented -771 Karma.karma._counters.errors++; -772 throw new Error("Video is not Yet Implemented"); -773 -774 video._localized = video._localized || false; -775 Karma.karma._counters.total++; -776 -777 if (video.name === undefined || video.file === undefined){ -778 throw new Error("properties name and file have to be defined"); -779 } else { -780 this.name = video.name; -781 this.file = video.file; -782 } -783 -784 this.media = new Video(); -785 -786 if(Karma._isLocalized(video._localized)){ -787 this._localized = video._localized; -788 this._path = Karma.karma._localePath + "video/"; -789 } else { -790 this._path = Karma.karma._assetPath + "video/"; -791 } -792 -793 -794 //IMPORTANT: This one magic line loads the file -795 this.media.src = this.src = this._path + this.file; -796 -797 //add event handlers -798 this._addEventHandlers(); -799 -800 return this; -801 }, -802 //Adds event handlers to update the counters when -803 //the asset is successfully or unsuccessfully loaded -804 _addEventHandlers : function () { -805 var that = this; -806 //'canplaythrough' event is a Browser Hack recommended by chromium devs -807 //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4 -808 -809 that.media.addEventListener( -810 "canplaythrough", -811 function (e) { -812 Karma.karma._counters.loaded++; -813 Karma.karma._updateStatus(); -814 that.status = "loaded";}, false); -815 -816 that.media.addEventListener( -817 "error", -818 function (e) { -819 Karma.karma._counters.errors++; -820 that.status = "error"; -821 var errorMsg = "Error: " + that._type.toUpperCase() + -822 " " + that.name + " cannot be loaded."; -823 Karma.karma._updateStatus(errorMsg); -824 }, -825 false); -826 that.media.addEventListener( -827 "abort", -828 function (e) { -829 Karma.karma._counters.total++; -830 that.status = "aborted"; -831 var errorMsg = "ABORT: " + that._type.toUpperCase() + -832 " " + that.name + " loading was aborted."; -833 Karma.karma._updateStatus(errorMsg); -834 -835 }, false); -836 -837 } -838 -839 }; -840 -841 -842 -843 /** Prototype object for each canvas element submitted to Karma in the -844 * Karma() method -845 * @throws {Error} if the name and domId for the canvas element are not specified -846 * @thows {Error} if the supplied domId does not match an element in the DOM -847 * @class This object is the prototype for each canvas element submitted to Karma in the -848 * Karma() method -849 */ -850 Karma.kCanvas = { -851 /** Name of the canvas, used internally by karma.js -852 * @type String -853 * @default '' -854 */ -855 name : '', -856 /** Width of canvas element -857 * @type Number -858 * @default 0 -859 */ -860 width: 0, -861 /** Height of canvas element -862 * @type Number -863 * @default 0 -864 */ -865 height: 0, -866 /** Whether canvas is visible -867 * @type boolean -868 * @default true -869 */ -870 visible: true, -871 /** Element ID for canvas element in html document. This value is read-only -872 * @type String -873 * @default undefined -874 */ -875 domId: undefined, -876 /** Reference to the DOM element -877 * @type DOMElement -878 * @default undefined -879 * @example -880 * //You can access all properties and methods of the underlying DOM element -881 * //using the 'node' property -882 * Karma.karma.canvas.someCanvas.node.dispatchEvent( ... some event ...); -883 * var stuff = Karma.karma.canvas.someCanvas.node.innerHTML; -884 * -885 */ -886 node: undefined, -887 /** The 2 Dimensional Rendering context property for this canvas -888 * @type 2DRenderingContext -889 * @default undefined -890 * @example -891 * //Almost all of the context attributes and methods are wrapped in helper functions -892 * //but you can also access them directly using the ctx property -893 * Karma.karma.canvas.someCanvas.ctx.drawImage(someImage, x, y); -894 * Karma.karma.canvas.someCanvas.ctx.fillStyle = "#ffffff"; -895 */ -896 ctx: undefined, -897 -898 //initializes object with values provides by user -899 _init: function (config) { -900 for (var option in config){ -901 if (config.hasOwnProperty(option)){ -902 switch (option){ -903 case "name": -904 this.name = config[option]; -905 break; -906 case "domId": -907 this.domId = config[option]; -908 break; -909 case "width": -910 if(!this.height){ -911 throw new Error("If you specify a width you must also" + -912 "specify a height"); -913 } -914 this.width = config[option]; -915 break; -916 case "height": -917 if(!this.width){ -918 throw new Error("If you specify a height you must also" + -919 "specify a width"); -920 } -921 this.height = parseInt(config.option, 10); +610 return this; +611 }, +612 //Adds event handlers to update the counters when +613 //the image is successfully or unsuccessfully loaded +614 _addEventHandlers : function () { +615 var that = this; +616 +617 that.media.addEventListener( +618 "load", +619 function (e) { +620 Karma.karma._counters.loaded++; +621 Karma.karma._updateStatus(); +622 that.status = "loaded";}, false); +623 +624 that.media.addEventListener( +625 "error", +626 function (e) { +627 Karma.karma._counters.errors++; +628 that.status = "error"; +629 var errorMsg = "Error: " + that._type.toUpperCase() + +630 " " + that.name + " cannot be loaded."; +631 Karma.karma._updateStatus(errorMsg); +632 }, +633 false); +634 that.media.addEventListener( +635 "abort", +636 function (e) { +637 Karma.karma._counters.total++; +638 that.status = "aborted"; +639 var errorMsg = "ABORT: " + that._type.toUpperCase() + +640 " " + that.name + " loading was aborted."; +641 Karma.karma._updateStatus(errorMsg); +642 +643 }, false); +644 } +645 +646 }; +647 +648 /** Prototype object for audio files +649 * @class This object is the prototype for audio files submitted to Karma in the +650 * Karma() method +651 * @ throws {Error} if the individual audio asset is set to be localized but +652 * the globale locale is not set on the Karma.karma object +653 * @ throws {Error} if the name and file properties are not supplied +654 * @example +655 * kAudio is the prototype object for audio +656 * The audio assets are loaded in a distinctly different way +657 * from the canvas or svg assets. They also have distinctly different +658 * helper methods +659 * +660 * You initialize the kAudio assets by passing an array of objects +661 */ +662 Karma.kAudio = { +663 /** file location of asset +664 * @type String +665 * @default "" +666 */ +667 file : "", +668 /** Media object. You can access the src, autobuffer, autoplay, loop, and +669 * controls attributes +670 * via the media property of kAudio. Read more about the properties of the <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/video.html#media-element-attributes">HTML 5 media element</a> +671 * @type Audio +672 * @default undefined +673 */ +674 media : undefined, +675 //actual path to the file +676 _path : "", +677 //if using localized version of this asset +678 _localized : false, +679 _type : "audio", +680 //initializes kAudio instance with values provided by user +681 _init : function (audio) { +682 audio._localized = audio._localized || false; +683 Karma.karma._counters.total++; +684 +685 if (audio.name === undefined || audio.file === undefined){ +686 throw new Error("properties name and file have to be defined"); +687 } else { +688 this.name = audio.name; +689 this.file = audio.file; +690 } +691 +692 this.media = new Audio(); +693 +694 if(Karma._isLocalized(audio._localized)){ +695 this._localized = audio._localized; +696 this._path = Karma.karma._localePath + "audio/"; +697 } else { +698 this._path = Karma.karma._assetPath + "audio/"; +699 } +700 +701 +702 //IMPORTANT: This one magic line loads the file +703 this.media.src = this.src = this._path + this.file; +704 +705 //add event handlers +706 this._addEventHandlers(); +707 +708 if (this._type === "audio"){ +709 this.media.autobuffer = true; +710 this.media.load(); +711 } +712 +713 +714 return this; +715 }, +716 //Adds event handlers to update the counters when +717 //the asset is successfully or unsuccessfully loaded +718 _addEventHandlers : function () { +719 var that = this; +720 //'canplaythrough' event is a Browser Hack recommended by chromium devs +721 //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4 +722 +723 that.media.addEventListener( +724 "canplaythrough", +725 function (e) { +726 Karma.karma._counters.loaded++; +727 Karma.karma._updateStatus(); +728 that.status = "loaded";}, false); +729 +730 that.media.addEventListener( +731 "error", +732 function (e) { +733 Karma.karma._counters.errors++; +734 that.status = "error"; +735 var errorMsg = "Error: " + that._type.toUpperCase() + +736 " " + that.name + " cannot be loaded."; +737 Karma.karma._updateStatus(errorMsg); +738 }, +739 false); +740 that.media.addEventListener( +741 "abort", +742 function (e) { +743 Karma.karma._counters.total++; +744 that.status = "aborted"; +745 var errorMsg = "ABORT: " + that._type.toUpperCase() + +746 " " + that.name + " loading was aborted."; +747 Karma.karma._updateStatus(errorMsg); +748 +749 }, false); +750 +751 }, +752 /** Plays the audio file */ +753 play : function () { +754 this.media.play(); +755 } +756 +757 }; +758 +759 /** NYI:Prototype object for Video files +760 * @class Not Yet Implemented:This object is the prototype for video files submitted +761 * to Karma in the Karma() method +762 * @ throws {Error} if the individual video asset is set to be localized but +763 * the globale locale is not set on the Karma.karma object +764 * @ throws {Error} if the name and file properties are not supplied +765 */ +766 Karma.kVideo = { +767 /** file location of asset +768 * @type String +769 * @default "" +770 */ +771 file : "", +772 /** media object +773 * @type Video +774 * @default undefined +775 */ +776 media : undefined, +777 //actual path to the file +778 _path : "", +779 //if using localized version of this asset +780 _localized : false, +781 _type : "video", +782 //initializes kVideo instance with values provided by user +783 _init : function (video) { +784 //Not Yet Implemented +785 Karma.karma._counters.errors++; +786 throw new Error("Video is not Yet Implemented"); +787 +788 video._localized = video._localized || false; +789 Karma.karma._counters.total++; +790 +791 if (video.name === undefined || video.file === undefined){ +792 throw new Error("properties name and file have to be defined"); +793 } else { +794 this.name = video.name; +795 this.file = video.file; +796 } +797 +798 this.media = new Video(); +799 +800 if(Karma._isLocalized(video._localized)){ +801 this._localized = video._localized; +802 this._path = Karma.karma._localePath + "video/"; +803 } else { +804 this._path = Karma.karma._assetPath + "video/"; +805 } +806 +807 +808 //IMPORTANT: This one magic line loads the file +809 this.media.src = this.src = this._path + this.file; +810 +811 //add event handlers +812 this._addEventHandlers(); +813 +814 return this; +815 }, +816 //Adds event handlers to update the counters when +817 //the asset is successfully or unsuccessfully loaded +818 _addEventHandlers : function () { +819 var that = this; +820 //'canplaythrough' event is a Browser Hack recommended by chromium devs +821 //http://code.google.com/p/chromium/issues/detail?id=20251&q=loading%20audio&colspec=ID%20Stars%20Pri%20Area%20Type%20Status%20Summary%20Modified%20Owner%20Mstone%20OS#c4 +822 +823 that.media.addEventListener( +824 "canplaythrough", +825 function (e) { +826 Karma.karma._counters.loaded++; +827 Karma.karma._updateStatus(); +828 that.status = "loaded";}, false); +829 +830 that.media.addEventListener( +831 "error", +832 function (e) { +833 Karma.karma._counters.errors++; +834 that.status = "error"; +835 var errorMsg = "Error: " + that._type.toUpperCase() + +836 " " + that.name + " cannot be loaded."; +837 Karma.karma._updateStatus(errorMsg); +838 }, +839 false); +840 that.media.addEventListener( +841 "abort", +842 function (e) { +843 Karma.karma._counters.total++; +844 that.status = "aborted"; +845 var errorMsg = "ABORT: " + that._type.toUpperCase() + +846 " " + that.name + " loading was aborted."; +847 Karma.karma._updateStatus(errorMsg); +848 +849 }, false); +850 +851 } +852 +853 }; +854 +855 +856 +857 /** Prototype object for each canvas element submitted to Karma in the +858 * Karma() method +859 * @throws {Error} if the name and domId for the canvas element are not specified +860 * @thows {Error} if the supplied domId does not match an element in the DOM +861 * @class This object is the prototype for each canvas element submitted to Karma in the +862 * Karma() method +863 */ +864 Karma.kCanvas = { +865 /** Name of the canvas, used internally by karma.js +866 * @type String +867 * @default '' +868 */ +869 name : '', +870 /** Width of canvas element +871 * @type Number +872 * @default 0 +873 */ +874 width: 0, +875 /** Height of canvas element +876 * @type Number +877 * @default 0 +878 */ +879 height: 0, +880 /** Whether canvas is visible +881 * @type boolean +882 * @default true +883 */ +884 visible: true, +885 /** Element ID for canvas element in html document. This value is read-only +886 * @type String +887 * @default undefined +888 */ +889 domId: undefined, +890 /** Reference to the DOM element +891 * @type DOMElement +892 * @default undefined +893 * @example +894 * //You can access all properties and methods of the underlying DOM element +895 * //using the 'node' property +896 * Karma.karma.canvas.someCanvas.node.dispatchEvent( ... some event ...); +897 * var stuff = Karma.karma.canvas.someCanvas.node.innerHTML; +898 * +899 */ +900 node: undefined, +901 /** The 2 Dimensional Rendering context property for this canvas +902 * @type 2DRenderingContext +903 * @default undefined +904 * @example +905 * //Almost all of the context attributes and methods are wrapped in helper functions +906 * //but you can also access them directly using the ctx property +907 * Karma.karma.canvas.someCanvas.ctx.drawImage(someImage, x, y); +908 * Karma.karma.canvas.someCanvas.ctx.fillStyle = "#ffffff"; +909 */ +910 ctx: undefined, +911 +912 //initializes object with values provides by user +913 _init: function (config) { +914 for (var option in config){ +915 if (config.hasOwnProperty(option)){ +916 switch (option){ +917 case "name": +918 this.name = config[option]; +919 break; +920 case "domId": +921 this.domId = config[option]; 922 break; -923 case "fps": -924 this.fps = parseInt(config.option, 10); -925 break; -926 } -927 } -928 } -929 -930 if(this.domId && document.getElementById(this.domId)){ -931 this.node = document.getElementById(this.domId); -932 this.ctx = this.node.getContext('2d'); -933 } else { -934 throw new Error('you must specify a valid domId that' + -935 'is in your html page'); -936 } -937 -938 if(!config.height && !config.width){ -939 this.width = parseInt(this.node.getAttribute('width'), 10); -940 this.height = parseInt(this.node.getAttribute('height'), 10); -941 } -942 -943 return this; -944 }, -945 /** Clear area of canvas element specified by parameters, if no -946 * parameters supplied, clears entire canvas -947 * @param {Number} [x=0] x coordinate, defaults to zero if left blank -948 * @param {Number} [y=0] y coordinate, defaults to zero if left blank -949 * @param {Number} [width=0] width of area to be cleared, defaults -950 * entire width of canvas -951 * @param {Number} [height=0] height of area to be cleared, defaults -952 * entire height of canvas -953 * @returns this -954 * @example -955 * -956 * k.canvas.ninja.clear(); -957 * // clears the entire ninja canvas -958 * -959 * k.canvas.ninja.clear(0, 10, 20, 30); -960 * //clears a specific portion of the ninja canvas -961 * -962 */ -963 clear : function ( x, y, width, height ) { -964 var that = this; -965 that.ctx.clearRect( -966 x || 0, -967 y || 0, -968 width || that.width, -969 height || that.height -970 ); -971 return that; -972 }, -973 -974 /** The globalAlpha attribute gives an alpha value that is applied to shapes -975 * and images before they are composited onto the canvas -976 * @param {Number} number in the range from 0.0 to 1.0 -977 * @returns this -978 */ -979 globalAlpha : function (attribute){ -980 var name = 'globalAlpha'; -981 this.ctx[name] = attribute; -982 return this; -983 }, -984 -985 /** Sets the globalCompositeOperation attribute, which sets how shapes and images -986 * are drawn onto the existing bitmap, once they have had globalAlpha and the -987 * current transformation matrix applied. -988 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -989 * @param {String} globalCompositeOperation source-atop, -990 * source-in, source-out, -991 * source-over, destination-atop, destination-in, destination-out, destination-over, -992 * lighter -993 * @returns this -994 */ -995 globalCompositeOperation: function (attribute){ -996 var name = ' globalCompositeOperation'; -997 this.ctx[name] = attribute; -998 return this; -999 }, -1000 -1001 /** Sets the lineWidth attribute which gives the width of lines, in coordinate space -1002 * units. -1003 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1004 * @param {Number} lineWidth -1005 * @returns this -1006 */ -1007 lineWidth: function (attribute){ -1008 var name = 'lineWidth'; -1009 this.ctx[name] = attribute; -1010 return this; -1011 }, -1012 /** The lineCap attribute defines the type of endings that UAs will place on -1013 * the end of lines. -1014 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1015 * @param {String} type butt, round, square -1016 * @returns this -1017 */ -1018 lineCap: function (attribute){ -1019 var name = 'lineCap'; -1020 this.ctx[name] = attribute; -1021 return this; -1022 }, -1023 /** The lineJoin attribute defines the type of corners that UAs will place -1024 * where two lines meet. The three valid values are bevel, round, and miter. -1025 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1026 * @param {String} type -1027 * @returns this -1028 */ -1029 lineJoin: function (attribute){ -1030 var name = 'lineJoin'; -1031 this.ctx[name] = attribute; -1032 return this; -1033 }, -1034 -1035 /** Sets the miter limit -1036 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1037 * @param {Number} number -1038 * @returns this -1039 */ -1040 miterLimit: function (attribute){ -1041 var name = 'miterLimit'; -1042 this.ctx[name] = attribute; -1043 return this; -1044 }, -1045 /** Sets the font property and takes the same syntax as setting the font property -1046 * in CSS -1047 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1048 * @param {String} -1049 * @returns this -1050 */ -1051 font: function (attribute){ -1052 var name = 'font'; -1053 this.ctx[name] = attribute; -1054 return this; -1055 }, -1056 -1057 /** Changes the text alignment. The possible values are start, end, left, right, -1058 * and center. The default is start. Other values are ignored. -1059 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1060 * @param {string} alignment -1061 * @returns this -1062 */ -1063 textAlign: function (attribute){ -1064 var name = 'textAlign'; -1065 this.ctx[name] = attribute; -1066 return this; -1067 }, -1068 -1069 /** Changes the baseline alignment. If the value is one of top, hanging, middle, -1070 * alphabetic, ideographic, or bottom, then the value must be changed to the new value. -1071 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1072 * @param {String} alignment -1073 * @returns this -1074 */ -1075 textBaseline: function (attribute){ -1076 var name = 'textBaseline'; -1077 this.ctx[name] = attribute; -1078 return this; -1079 }, -1080 -1081 /** Save the current state of the context -1082 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1083 * @param -1084 * @returns this -1085 */ -1086 save : function ( ){ -1087 var name = 'save'; -1088 this.ctx[name].apply(this.ctx, arguments); -1089 return this; -1090 }, -1091 /** Restore the saved context -1092 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1093 * @param -1094 * @returns this -1095 */ -1096 restore : function ( ){ -1097 var name = 'restore'; -1098 this.ctx[name].apply(this.ctx, arguments); -1099 return this; -1100 }, -1101 /** Perform a scale transformation -1102 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1103 * @param -1104 * @returns this -1105 */ -1106 scale : function ( ){ -1107 var name = 'scale'; -1108 this.ctx[name].apply(this.ctx, arguments); -1109 return this; -1110 }, -1111 /** Perform a rotation transformation -1112 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1113 * @param -1114 * @returns this -1115 */ -1116 rotate : function ( ){ -1117 var name = 'rotate'; -1118 this.ctx[name].apply(this.ctx, arguments); -1119 return this; -1120 }, -1121 /** Performa a translation transformation -1122 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1123 * @param -1124 * @returns this -1125 */ -1126 translate : function ( ){ -1127 var name = 'translate'; -1128 this.ctx[name].apply(this.ctx, arguments); -1129 return this; -1130 }, -1131 -1132 /** Transform the identity matrix -1133 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1134 * @param -1135 * @returns this -1136 */ -1137 transform : function ( ){ -1138 var name = 'transform'; -1139 this.ctx[name].apply(this.ctx, arguments); -1140 return this; -1141 }, -1142 /** Set the transform -1143 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1144 * @param -1145 * @returns this -1146 */ -1147 setTransform : function ( ){ -1148 var name = 'setTransform'; -1149 this.ctx[name].apply(this.ctx, arguments); -1150 return this; -1151 }, -1152 /** Clear a rectangular area -1153 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1154 * @param -1155 * @returns this -1156 */ -1157 clearRect : function ( ){ -1158 var name = 'clearRect'; -1159 this.ctx[name].apply(this.ctx, arguments); -1160 return this; -1161 }, -1162 /** Fill a rectangular area -1163 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1164 * @param -1165 * @returns this -1166 */ -1167 fillRect : function ( ){ -1168 var name = 'fillRect'; -1169 this.ctx[name].apply(this.ctx, arguments); -1170 return this; -1171 }, -1172 -1173 /** Draw the outline of the rectangle -1174 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1175 * @param -1176 * @returns this -1177 */ -1178 strokeRect : function ( ){ -1179 var name = 'strokeRect'; -1180 this.ctx[name].apply(this.ctx, arguments); -1181 return this; -1182 }, -1183 /** Begin a path -1184 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1185 * @param -1186 * @returns this -1187 */ -1188 beginPath : function ( ){ -1189 var name = 'beginPath'; -1190 this.ctx[name].apply(this.ctx, arguments); -1191 return this; -1192 }, -1193 /** End a path -1194 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1195 * @param -1196 * @returns this -1197 */ -1198 closePath : function ( ){ -1199 var name = 'closePath'; -1200 this.ctx[name].apply(this.ctx, arguments); -1201 return this; -1202 }, -1203 /** Move to specified coordinates -1204 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1205 * @param -1206 * @returns this -1207 */ -1208 moveTo : function ( ){ -1209 var name = 'moveTo'; -1210 this.ctx[name].apply(this.ctx, arguments); -1211 return this; -1212 }, -1213 -1214 -1215 /** Draw a line to the given coordinates -1216 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1217 * @param -1218 * @returns this -1219 */ -1220 lineTo : function ( ){ -1221 var name = 'lineTo'; -1222 this.ctx[name].apply(this.ctx, arguments); -1223 return this; -1224 }, -1225 -1226 /** Draw a quadratic curve to given coordinates -1227 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1228 * @param -1229 * @returns this -1230 */ -1231 quadraticCurveTo : function ( ){ -1232 var name = 'quadraticCurveTo'; -1233 this.ctx[name].apply(this.ctx, arguments); -1234 return this; -1235 }, -1236 /** Draw a bezier curve to given coordinates -1237 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1238 * @param -1239 * @returns this -1240 */ -1241 bezierCurveTo : function ( ){ -1242 var name = 'bezierCurveTo'; -1243 this.ctx[name].apply(this.ctx, arguments); -1244 return this; -1245 }, -1246 /** Draw an arc to the given points -1247 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1248 * @param -1249 * @returns this -1250 */ -1251 arcTo : function ( ){ -1252 var name = 'arcTo'; -1253 this.ctx[name].apply(this.ctx, arguments); -1254 return this; -1255 }, -1256 /** Create an arc -1257 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1258 * @param -1259 * @returns this -1260 */ -1261 arc : function ( ){ -1262 var name = 'arc'; -1263 this.ctx[name].apply(this.ctx, arguments); -1264 return this; -1265 }, -1266 -1267 /** Create a rectangle -1268 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1269 * @param -1270 * @returns this -1271 */ -1272 rect : function ( ){ -1273 var name = 'rect'; -1274 this.ctx[name].apply(this.ctx, arguments); -1275 return this; -1276 }, -1277 /** fill in the current subpaths with the current fillstyle -1278 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1279 * @param -1280 * @returns this -1281 */ -1282 fill : function ( ){ -1283 var name = 'fill'; -1284 this.ctx[name].apply(this.ctx, arguments); -1285 return this; -1286 }, -1287 /** Stroke the subpaths -1288 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1289 * @param -1290 * @returns this -1291 */ -1292 stroke : function ( ){ -1293 var name = 'stroke'; -1294 this.ctx[name].apply(this.ctx, arguments); -1295 return this; -1296 }, -1297 -1298 /** description -1299 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1300 * @param -1301 * @returns this -1302 */ -1303 clip : function ( ){ -1304 var name = 'clip'; -1305 this.ctx[name].apply(this.ctx, arguments); -1306 return this; -1307 }, -1308 /** description -1309 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1310 * @param -1311 * @returns this -1312 */ -1313 fillText : function ( ){ -1314 var name = 'fillText'; -1315 this.ctx[name].apply(this.ctx, arguments); -1316 return this; -1317 }, -1318 /** description -1319 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1320 * @param -1321 * @returns this -1322 */ -1323 strokeText : function ( ){ -1324 var name = 'strokeText'; -1325 this.ctx[name].apply(this.ctx, arguments); -1326 return this; -1327 }, -1328 /** description -1329 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1330 * @param -1331 * @returns this -1332 */ -1333 measureText : function ( ){ -1334 var name = 'measureText'; -1335 this.ctx[name].apply(this.ctx, arguments); -1336 return this; -1337 }, -1338 /** description -1339 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1340 * @param -1341 * @returns this -1342 */ -1343 isPointInPath : function ( ){ -1344 var name = 'isPointInPath'; -1345 this.ctx[name].apply(this.ctx, arguments); -1346 return this; -1347 }, -1348 -1349 /** Sets the stroke style -1350 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1351 * @param -1352 * @returns this -1353 */ -1354 strokeStyle: function (attribute){ -1355 var name = 'strokeStyle'; -1356 this.ctx[name] = attribute; -1357 return this; -1358 }, -1359 -1360 /** Sets the fill style -1361 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1362 * @param -1363 * @returns this -1364 */ -1365 fillStyle: function (attribute){ -1366 var name = 'fillStyle'; -1367 this.ctx[name] = attribute; -1368 return this; -1369 }, -1370 /** description -1371 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1372 * @param -1373 * @returns this -1374 */ -1375 createLinearGradient : function ( ){ -1376 var name = 'createLinearGradient'; -1377 this.ctx[name].apply(this.ctx, arguments); -1378 return this; -1379 }, -1380 /** description -1381 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1382 * @param -1383 * @returns this -1384 */ -1385 createRadialGradient : function ( ){ -1386 var name = 'createRadialGradient'; -1387 this.ctx[name].apply(this.ctx, arguments); -1388 return this; -1389 }, -1390 /** description -1391 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1392 * @param -1393 * @returns this -1394 */ -1395 createPattern : function ( ){ -1396 var name = 'createPattern'; -1397 this.ctx[name].apply(this.ctx, arguments); -1398 return this; -1399 }, -1400 /** description -1401 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1402 * @param -1403 * @returns this -1404 */ -1405 shadowOffsetX: function (attribute){ -1406 var name = 'shadowOffsetX'; -1407 this.ctx[name] = attribute; -1408 return this; -1409 }, -1410 /** description -1411 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1412 * @param -1413 * @returns this -1414 */ -1415 shadowOffsetY: function (attribute){ -1416 var name = 'shadowOffsetY'; -1417 this.ctx[name] = attribute; -1418 return this; -1419 }, -1420 /** description -1421 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1422 * @param -1423 * @returns this -1424 */ -1425 shadowBlur: function (attribute){ -1426 var name = 'shadowBlur'; -1427 this.ctx[name] = attribute; -1428 return this; -1429 }, -1430 /** description -1431 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1432 * @param -1433 * @returns this -1434 */ -1435 shadowColor: function (attribute){ -1436 var name = 'shadowColor'; -1437 this.ctx[name] = attribute; -1438 return this; -1439 }, -1440 /** description -1441 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1442 * @param -1443 * @returns this -1444 */ -1445 drawImage : function ( ){ -1446 var name = 'drawImage'; -1447 this.ctx[name].apply(this.ctx, arguments); -1448 return this; -1449 }, -1450 /** description -1451 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1452 * @param -1453 * @returns this -1454 */ -1455 getImageData : function ( ){ -1456 var name = 'getImageData'; -1457 this.ctx[name].apply(this.ctx, arguments); -1458 return this; -1459 }, -1460 /** description -1461 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1462 * @param -1463 * @returns this -1464 */ -1465 putImageData : function ( ){ -1466 var name = 'putImageData'; -1467 this.ctx[name].apply(this.ctx, arguments); -1468 return this; -1469 }, -1470 /** description -1471 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1472 * @param -1473 * @returns this -1474 */ -1475 createImageData : function ( ){ -1476 var name = 'createImageData'; -1477 this.ctx[name].apply(this.ctx, arguments); -1478 return this; -1479 }, -1480 /** description -1481 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> -1482 * @param -1483 * @returns this -1484 */ -1485 drawWindow : function ( ){ -1486 var name = 'drawWindow'; -1487 this.ctx[name].apply(this.ctx, arguments); -1488 return this; -1489 }, -1490 -1491 -1492 -1493 -1494 }; -1495 -1496 -1497 /** Prototype object for each svg element submitted to Karma in the -1498 * Karma() method -1499 * @throws {Error} if the name and domId for the svg element are not specified -1500 * @thows {Error} if the supplied domId does not match an element in the DOM -1501 * @class This object is the prototype for each svg element submitted to Karma in the -1502 * Karma() method -1503 */ -1504 Karma.kSvg = { -1505 /** name of instance, used internally -1506 * @typeof string -1507 * @default "" -1508 */ -1509 name : "", -1510 /** width of element -1511 * @type number -1512 * @default 0 -1513 */ -1514 width: 0, -1515 /** height of element -1516 * @type number -1517 * @default 0 -1518 */ -1519 height: 0, -1520 /** Status of element, either "loaded" or "error" -1521 * @type string -1522 * @default "" -1523 */ -1524 status: "", -1525 /** Whether canvas is visible. This value is read-only -1526 * @type boolean -1527 * @default true -1528 */ -1529 visible: true, -1530 /** Element ID for canvas element in html document. -1531 * @type String -1532 * @default undefined -1533 */ -1534 domId: undefined, -1535 /** Reference to the DOM element. -1536 * @type DOMElement -1537 * @default undefined -1538 * @example -1539 * //You can access all properties and methods of the underlying DOM element -1540 * //using the 'node' property -1541 * Karma.karma.svg.someSvg.node.dispatchEvent; -1542 * Karma.karma.svg.someSvg.node.addEvenListener(...); -1543 */ -1544 node: undefined, -1545 /** Reference to the SVGDocument. You can use the this.doc to manipulate -1546 * the SVG document -1547 * @type SVGDocument -1548 * @default undefined -1549 * @example -1550 * var myElem = Karma.karma.svg.someSvg.doc.getElementById('foobar'); -1551 * Karma.karma.svg.someSvg.doc.createElement(...); -1552 * Karma.karma.svg.someSvg.doc.removeChild(someNode); -1553 * -1554 */ -1555 doc: undefined, -1556 /** Reference to the root element of the SVG Document -1557 * @type DocumentElement -1558 * @default undefined -1559 * @example -1560 * // The root element is equivalent to "document" in a regular html document -1561 * // The root attribute is used frequently with the jQuery SVG plugin for CSS selectors -1562 * $('#someId', Karma.karma.svg.someSvg.root).css(.. manipulate css attributes ...); -1563 */ -1564 root: undefined, -1565 _localized : undefined, -1566 _init: function (config) { -1567 Karma.karma._counters.total++; -1568 -1569 for (var option in config){ -1570 if (config.hasOwnProperty(option)){ -1571 switch (option){ -1572 case "name": -1573 this.name = config[option]; -1574 break; -1575 case "domId": -1576 this.domId = config[option]; -1577 break; -1578 case "width": -1579 if(!this.height){ -1580 throw new Error("If you specify a width you must also" + -1581 "specify a height"); -1582 } -1583 this.width = parseInt(config[option], 10); -1584 break; -1585 case "height": -1586 if(!this.width){ -1587 throw new Error("If you specify a height you must also" + -1588 "specify a width"); -1589 } -1590 this.height = config[option]; +923 case "width": +924 if(!this.height){ +925 throw new Error("If you specify a width you must also" + +926 "specify a height"); +927 } +928 this.width = config[option]; +929 break; +930 case "height": +931 if(!this.width){ +932 throw new Error("If you specify a height you must also" + +933 "specify a width"); +934 } +935 this.height = parseInt(config.option, 10); +936 break; +937 case "fps": +938 this.fps = parseInt(config.option, 10); +939 break; +940 } +941 } +942 } +943 +944 if(this.domId && document.getElementById(this.domId)){ +945 this.node = document.getElementById(this.domId); +946 this.ctx = this.node.getContext('2d'); +947 } else { +948 throw new Error('you must specify a valid domId that' + +949 'is in your html page'); +950 } +951 +952 if(!config.height && !config.width){ +953 this.width = parseInt(this.node.getAttribute('width'), 10); +954 this.height = parseInt(this.node.getAttribute('height'), 10); +955 } +956 +957 return this; +958 }, +959 /** Clear area of canvas element specified by parameters, if no +960 * parameters supplied, clears entire canvas +961 * @param {Number} [x=0] x coordinate, defaults to zero if left blank +962 * @param {Number} [y=0] y coordinate, defaults to zero if left blank +963 * @param {Number} [width=0] width of area to be cleared, defaults +964 * entire width of canvas +965 * @param {Number} [height=0] height of area to be cleared, defaults +966 * entire height of canvas +967 * @returns this +968 * @example +969 * +970 * k.canvas.ninja.clear(); +971 * // clears the entire ninja canvas +972 * +973 * k.canvas.ninja.clear(0, 10, 20, 30); +974 * //clears a specific portion of the ninja canvas +975 * +976 */ +977 clear : function ( x, y, width, height ) { +978 var that = this; +979 that.ctx.clearRect( +980 x || 0, +981 y || 0, +982 width || that.width, +983 height || that.height +984 ); +985 return that; +986 }, +987 +988 /** The globalAlpha attribute gives an alpha value that is applied to shapes +989 * and images before they are composited onto the canvas +990 * @param {Number} number in the range from 0.0 to 1.0 +991 * @returns this +992 */ +993 globalAlpha : function (attribute){ +994 var name = 'globalAlpha'; +995 this.ctx[name] = attribute; +996 return this; +997 }, +998 +999 /** Sets the globalCompositeOperation attribute, which sets how shapes and images +1000 * are drawn onto the existing bitmap, once they have had globalAlpha and the +1001 * current transformation matrix applied. +1002 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1003 * @param {String} globalCompositeOperation source-atop, +1004 * source-in, source-out, +1005 * source-over, destination-atop, destination-in, destination-out, destination-over, +1006 * lighter +1007 * @returns this +1008 */ +1009 globalCompositeOperation: function (attribute){ +1010 var name = ' globalCompositeOperation'; +1011 this.ctx[name] = attribute; +1012 return this; +1013 }, +1014 +1015 /** Sets the lineWidth attribute which gives the width of lines, in coordinate space +1016 * units. +1017 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1018 * @param {Number} lineWidth +1019 * @returns this +1020 */ +1021 lineWidth: function (attribute){ +1022 var name = 'lineWidth'; +1023 this.ctx[name] = attribute; +1024 return this; +1025 }, +1026 /** The lineCap attribute defines the type of endings that UAs will place on +1027 * the end of lines. +1028 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1029 * @param {String} type butt, round, square +1030 * @returns this +1031 */ +1032 lineCap: function (attribute){ +1033 var name = 'lineCap'; +1034 this.ctx[name] = attribute; +1035 return this; +1036 }, +1037 /** The lineJoin attribute defines the type of corners that UAs will place +1038 * where two lines meet. The three valid values are bevel, round, and miter. +1039 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1040 * @param {String} type +1041 * @returns this +1042 */ +1043 lineJoin: function (attribute){ +1044 var name = 'lineJoin'; +1045 this.ctx[name] = attribute; +1046 return this; +1047 }, +1048 +1049 /** Sets the miter limit +1050 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1051 * @param {Number} number +1052 * @returns this +1053 */ +1054 miterLimit: function (attribute){ +1055 var name = 'miterLimit'; +1056 this.ctx[name] = attribute; +1057 return this; +1058 }, +1059 /** Sets the font property and takes the same syntax as setting the font property +1060 * in CSS +1061 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1062 * @param {String} +1063 * @returns this +1064 */ +1065 font: function (attribute){ +1066 var name = 'font'; +1067 this.ctx[name] = attribute; +1068 return this; +1069 }, +1070 +1071 /** Changes the text alignment. The possible values are start, end, left, right, +1072 * and center. The default is start. Other values are ignored. +1073 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1074 * @param {string} alignment +1075 * @returns this +1076 */ +1077 textAlign: function (attribute){ +1078 var name = 'textAlign'; +1079 this.ctx[name] = attribute; +1080 return this; +1081 }, +1082 +1083 /** Changes the baseline alignment. If the value is one of top, hanging, middle, +1084 * alphabetic, ideographic, or bottom, then the value must be changed to the new value. +1085 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1086 * @param {String} alignment +1087 * @returns this +1088 */ +1089 textBaseline: function (attribute){ +1090 var name = 'textBaseline'; +1091 this.ctx[name] = attribute; +1092 return this; +1093 }, +1094 +1095 /** Save the current state of the context +1096 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1097 * @param +1098 * @returns this +1099 */ +1100 save : function ( ){ +1101 var name = 'save'; +1102 this.ctx[name].apply(this.ctx, arguments); +1103 return this; +1104 }, +1105 /** Restore the saved context +1106 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1107 * @param +1108 * @returns this +1109 */ +1110 restore : function ( ){ +1111 var name = 'restore'; +1112 this.ctx[name].apply(this.ctx, arguments); +1113 return this; +1114 }, +1115 /** Perform a scale transformation +1116 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1117 * @param +1118 * @returns this +1119 */ +1120 scale : function ( ){ +1121 var name = 'scale'; +1122 this.ctx[name].apply(this.ctx, arguments); +1123 return this; +1124 }, +1125 /** Perform a rotation transformation +1126 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1127 * @param +1128 * @returns this +1129 */ +1130 rotate : function ( ){ +1131 var name = 'rotate'; +1132 this.ctx[name].apply(this.ctx, arguments); +1133 return this; +1134 }, +1135 /** Performa a translation transformation +1136 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1137 * @param +1138 * @returns this +1139 */ +1140 translate : function ( ){ +1141 var name = 'translate'; +1142 this.ctx[name].apply(this.ctx, arguments); +1143 return this; +1144 }, +1145 +1146 /** Transform the identity matrix +1147 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1148 * @param +1149 * @returns this +1150 */ +1151 transform : function ( ){ +1152 var name = 'transform'; +1153 this.ctx[name].apply(this.ctx, arguments); +1154 return this; +1155 }, +1156 /** Set the transform +1157 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1158 * @param +1159 * @returns this +1160 */ +1161 setTransform : function ( ){ +1162 var name = 'setTransform'; +1163 this.ctx[name].apply(this.ctx, arguments); +1164 return this; +1165 }, +1166 /** Clear a rectangular area +1167 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1168 * @param +1169 * @returns this +1170 */ +1171 clearRect : function ( ){ +1172 var name = 'clearRect'; +1173 this.ctx[name].apply(this.ctx, arguments); +1174 return this; +1175 }, +1176 /** Fill a rectangular area +1177 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1178 * @param +1179 * @returns this +1180 */ +1181 fillRect : function ( ){ +1182 var name = 'fillRect'; +1183 this.ctx[name].apply(this.ctx, arguments); +1184 return this; +1185 }, +1186 +1187 /** Draw the outline of the rectangle +1188 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1189 * @param +1190 * @returns this +1191 */ +1192 strokeRect : function ( ){ +1193 var name = 'strokeRect'; +1194 this.ctx[name].apply(this.ctx, arguments); +1195 return this; +1196 }, +1197 /** Begin a path +1198 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1199 * @param +1200 * @returns this +1201 */ +1202 beginPath : function ( ){ +1203 var name = 'beginPath'; +1204 this.ctx[name].apply(this.ctx, arguments); +1205 return this; +1206 }, +1207 /** End a path +1208 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1209 * @param +1210 * @returns this +1211 */ +1212 closePath : function ( ){ +1213 var name = 'closePath'; +1214 this.ctx[name].apply(this.ctx, arguments); +1215 return this; +1216 }, +1217 /** Move to specified coordinates +1218 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1219 * @param +1220 * @returns this +1221 */ +1222 moveTo : function ( ){ +1223 var name = 'moveTo'; +1224 this.ctx[name].apply(this.ctx, arguments); +1225 return this; +1226 }, +1227 +1228 +1229 /** Draw a line to the given coordinates +1230 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1231 * @param +1232 * @returns this +1233 */ +1234 lineTo : function ( ){ +1235 var name = 'lineTo'; +1236 this.ctx[name].apply(this.ctx, arguments); +1237 return this; +1238 }, +1239 +1240 /** Draw a quadratic curve to given coordinates +1241 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1242 * @param +1243 * @returns this +1244 */ +1245 quadraticCurveTo : function ( ){ +1246 var name = 'quadraticCurveTo'; +1247 this.ctx[name].apply(this.ctx, arguments); +1248 return this; +1249 }, +1250 /** Draw a bezier curve to given coordinates +1251 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1252 * @param +1253 * @returns this +1254 */ +1255 bezierCurveTo : function ( ){ +1256 var name = 'bezierCurveTo'; +1257 this.ctx[name].apply(this.ctx, arguments); +1258 return this; +1259 }, +1260 /** Draw an arc to the given points +1261 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1262 * @param +1263 * @returns this +1264 */ +1265 arcTo : function ( ){ +1266 var name = 'arcTo'; +1267 this.ctx[name].apply(this.ctx, arguments); +1268 return this; +1269 }, +1270 /** Create an arc +1271 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1272 * @param +1273 * @returns this +1274 */ +1275 arc : function ( ){ +1276 var name = 'arc'; +1277 this.ctx[name].apply(this.ctx, arguments); +1278 return this; +1279 }, +1280 +1281 /** Create a rectangle +1282 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1283 * @param +1284 * @returns this +1285 */ +1286 rect : function ( ){ +1287 var name = 'rect'; +1288 this.ctx[name].apply(this.ctx, arguments); +1289 return this; +1290 }, +1291 /** fill in the current subpaths with the current fillstyle +1292 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1293 * @param +1294 * @returns this +1295 */ +1296 fill : function ( ){ +1297 var name = 'fill'; +1298 this.ctx[name].apply(this.ctx, arguments); +1299 return this; +1300 }, +1301 /** Stroke the subpaths +1302 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1303 * @param +1304 * @returns this +1305 */ +1306 stroke : function ( ){ +1307 var name = 'stroke'; +1308 this.ctx[name].apply(this.ctx, arguments); +1309 return this; +1310 }, +1311 +1312 /** description +1313 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1314 * @param +1315 * @returns this +1316 */ +1317 clip : function ( ){ +1318 var name = 'clip'; +1319 this.ctx[name].apply(this.ctx, arguments); +1320 return this; +1321 }, +1322 /** description +1323 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1324 * @param +1325 * @returns this +1326 */ +1327 fillText : function ( ){ +1328 var name = 'fillText'; +1329 this.ctx[name].apply(this.ctx, arguments); +1330 return this; +1331 }, +1332 /** description +1333 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1334 * @param +1335 * @returns this +1336 */ +1337 strokeText : function ( ){ +1338 var name = 'strokeText'; +1339 this.ctx[name].apply(this.ctx, arguments); +1340 return this; +1341 }, +1342 /** description +1343 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1344 * @param +1345 * @returns this +1346 */ +1347 measureText : function ( ){ +1348 var name = 'measureText'; +1349 this.ctx[name].apply(this.ctx, arguments); +1350 return this; +1351 }, +1352 /** description +1353 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1354 * @param +1355 * @returns this +1356 */ +1357 isPointInPath : function ( ){ +1358 var name = 'isPointInPath'; +1359 this.ctx[name].apply(this.ctx, arguments); +1360 return this; +1361 }, +1362 +1363 /** Sets the stroke style +1364 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1365 * @param +1366 * @returns this +1367 */ +1368 strokeStyle: function (attribute){ +1369 var name = 'strokeStyle'; +1370 this.ctx[name] = attribute; +1371 return this; +1372 }, +1373 +1374 /** Sets the fill style +1375 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1376 * @param +1377 * @returns this +1378 */ +1379 fillStyle: function (attribute){ +1380 var name = 'fillStyle'; +1381 this.ctx[name] = attribute; +1382 return this; +1383 }, +1384 /** description +1385 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1386 * @param +1387 * @returns this +1388 */ +1389 createLinearGradient : function ( ){ +1390 var name = 'createLinearGradient'; +1391 this.ctx[name].apply(this.ctx, arguments); +1392 return this; +1393 }, +1394 /** description +1395 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1396 * @param +1397 * @returns this +1398 */ +1399 createRadialGradient : function ( ){ +1400 var name = 'createRadialGradient'; +1401 this.ctx[name].apply(this.ctx, arguments); +1402 return this; +1403 }, +1404 /** description +1405 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1406 * @param +1407 * @returns this +1408 */ +1409 createPattern : function ( ){ +1410 var name = 'createPattern'; +1411 this.ctx[name].apply(this.ctx, arguments); +1412 return this; +1413 }, +1414 /** description +1415 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1416 * @param +1417 * @returns this +1418 */ +1419 shadowOffsetX: function (attribute){ +1420 var name = 'shadowOffsetX'; +1421 this.ctx[name] = attribute; +1422 return this; +1423 }, +1424 /** description +1425 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1426 * @param +1427 * @returns this +1428 */ +1429 shadowOffsetY: function (attribute){ +1430 var name = 'shadowOffsetY'; +1431 this.ctx[name] = attribute; +1432 return this; +1433 }, +1434 /** description +1435 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1436 * @param +1437 * @returns this +1438 */ +1439 shadowBlur: function (attribute){ +1440 var name = 'shadowBlur'; +1441 this.ctx[name] = attribute; +1442 return this; +1443 }, +1444 /** description +1445 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1446 * @param +1447 * @returns this +1448 */ +1449 shadowColor: function (attribute){ +1450 var name = 'shadowColor'; +1451 this.ctx[name] = attribute; +1452 return this; +1453 }, +1454 /** description +1455 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1456 * @param +1457 * @returns this +1458 */ +1459 drawImage : function ( ){ +1460 var name = 'drawImage'; +1461 this.ctx[name].apply(this.ctx, arguments); +1462 return this; +1463 }, +1464 /** description +1465 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1466 * @param +1467 * @returns this +1468 */ +1469 getImageData : function ( ){ +1470 var name = 'getImageData'; +1471 this.ctx[name].apply(this.ctx, arguments); +1472 return this; +1473 }, +1474 /** description +1475 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1476 * @param +1477 * @returns this +1478 */ +1479 putImageData : function ( ){ +1480 var name = 'putImageData'; +1481 this.ctx[name].apply(this.ctx, arguments); +1482 return this; +1483 }, +1484 /** description +1485 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1486 * @param +1487 * @returns this +1488 */ +1489 createImageData : function ( ){ +1490 var name = 'createImageData'; +1491 this.ctx[name].apply(this.ctx, arguments); +1492 return this; +1493 }, +1494 /** description +1495 * For full details see <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-globalcompositeoperation">W3C docs</a> +1496 * @param +1497 * @returns this +1498 */ +1499 drawWindow : function ( ){ +1500 var name = 'drawWindow'; +1501 this.ctx[name].apply(this.ctx, arguments); +1502 return this; +1503 }, +1504 +1505 +1506 +1507 +1508 }; +1509 +1510 +1511 /** Prototype object for each svg element submitted to Karma in the +1512 * Karma() method +1513 * @throws {Error} if the name and domId for the svg element are not specified +1514 * @thows {Error} if the supplied domId does not match an element in the DOM +1515 * @class This object is the prototype for each svg element submitted to Karma in the +1516 * Karma() method +1517 */ +1518 Karma.kSvg = { +1519 /** name of instance, used internally +1520 * @typeof string +1521 * @default "" +1522 */ +1523 name : "", +1524 /** width of element +1525 * @type number +1526 * @default 0 +1527 */ +1528 width: 0, +1529 /** height of element +1530 * @type number +1531 * @default 0 +1532 */ +1533 height: 0, +1534 /** Status of element, either "loaded" or "error" +1535 * @type string +1536 * @default "" +1537 */ +1538 status: "", +1539 /** Whether canvas is visible. This value is read-only +1540 * @type boolean +1541 * @default true +1542 */ +1543 visible: true, +1544 /** Element ID for canvas element in html document. +1545 * @type String +1546 * @default undefined +1547 */ +1548 domId: undefined, +1549 /** Reference to the DOM element. +1550 * @type DOMElement +1551 * @default undefined +1552 * @example +1553 * //You can access all properties and methods of the underlying DOM element +1554 * //using the 'node' property +1555 * Karma.karma.svg.someSvg.node.dispatchEvent; +1556 * Karma.karma.svg.someSvg.node.addEvenListener(...); +1557 */ +1558 node: undefined, +1559 /** Reference to the SVGDocument. You can use the this.doc to manipulate +1560 * the SVG document +1561 * @type SVGDocument +1562 * @default undefined +1563 * @example +1564 * var myElem = Karma.karma.svg.someSvg.doc.getElementById('foobar'); +1565 * Karma.karma.svg.someSvg.doc.createElement(...); +1566 * Karma.karma.svg.someSvg.doc.removeChild(someNode); +1567 * +1568 */ +1569 doc: undefined, +1570 /** Reference to the root element of the SVG Document +1571 * @type DocumentElement +1572 * @default undefined +1573 * @example +1574 * // The root element is equivalent to "document" in a regular html document +1575 * // The root attribute is used frequently with the jQuery SVG plugin for CSS selectors +1576 * $('#someId', Karma.karma.svg.someSvg.root).css(.. manipulate css attributes ...); +1577 */ +1578 root: undefined, +1579 _localized : undefined, +1580 _init: function (config) { +1581 Karma.karma._counters.total++; +1582 +1583 for (var option in config){ +1584 if (config.hasOwnProperty(option)){ +1585 switch (option){ +1586 case "name": +1587 this.name = config[option]; +1588 break; +1589 case "domId": +1590 this.domId = config[option]; 1591 break; -1592 } -1593 } -1594 } -1595 -1596 if(this.domId && document.getElementById(this.domId)){ -1597 this.node = document.getElementById(this.domId); -1598 } else { -1599 throw new Error('you must specify a valid domId that' + -1600 'is in your html page'); -1601 } -1602 -1603 if(!config.height && !config.width){ -1604 this.width = parseInt(this.node.getAttribute('width'), 10); -1605 this.height = parseInt(this.node.getAttribute('height'), 10); -1606 } -1607 -1608 var that = this; -1609 that._addEventHandlers(); -1610 -1611 return this; -1612 -1613 -1614 }, -1615 _addEventHandlers : function () { -1616 var that = this; -1617 that.doc = that.node.getSVGDocument(); -1618 that.node.addEventListener( -1619 "load", -1620 function (e) { -1621 that.doc = that.node.getSVGDocument(); -1622 that.root = that.doc.documentElement; -1623 Karma.karma._counters.loaded++; -1624 Karma.karma._updateStatus(); -1625 that.status = "loaded"; -1626 }, false); -1627 -1628 that.node.addEventListener( -1629 "error", -1630 function (e) { -1631 Karma.karma._counters.loaded--; -1632 Karma.karma._counters.errors++; -1633 that.status = "error"; -1634 var errorMsg = "Error: " + that._type.toUpperCase() + -1635 " " + that.name + " cannot be loaded."; -1636 Karma.karma._updateStatus(errorMsg); -1637 }, -1638 false); -1639 that.node.addEventListener( -1640 "abort", -1641 function (e) { -1642 that.status = "aborted"; -1643 var errorMsg = "ABORT: " + that._type.toUpperCase() + -1644 " " + that.name + " loading was aborted."; -1645 Karma.karma._updateStatus(errorMsg); -1646 -1647 }, false); -1648 -1649 } -1650 }; -1651 \ No newline at end of file +1592 case "width": +1593 if(!this.height){ +1594 throw new Error("If you specify a width you must also" + +1595 "specify a height"); +1596 } +1597 this.width = parseInt(config[option], 10); +1598 break; +1599 case "height": +1600 if(!this.width){ +1601 throw new Error("If you specify a height you must also" + +1602 "specify a width"); +1603 } +1604 this.height = config[option]; +1605 break; +1606 } +1607 } +1608 } +1609 +1610 if(this.domId && document.getElementById(this.domId)){ +1611 this.node = document.getElementById(this.domId); +1612 } else { +1613 throw new Error('you must specify a valid domId that' + +1614 'is in your html page'); +1615 } +1616 +1617 if(!config.height && !config.width){ +1618 this.width = parseInt(this.node.getAttribute('width'), 10); +1619 this.height = parseInt(this.node.getAttribute('height'), 10); +1620 } +1621 +1622 var that = this; +1623 that._addEventHandlers(); +1624 +1625 return this; +1626 +1627 +1628 }, +1629 _addEventHandlers : function () { +1630 var that = this; +1631 that.doc = that.node.getSVGDocument(); +1632 that.node.addEventListener( +1633 "load", +1634 function (e) { +1635 that.doc = that.node.getSVGDocument(); +1636 that.root = that.doc.documentElement; +1637 Karma.karma._counters.loaded++; +1638 Karma.karma._updateStatus(); +1639 that.status = "loaded"; +1640 }, false); +1641 +1642 that.node.addEventListener( +1643 "error", +1644 function (e) { +1645 Karma.karma._counters.loaded--; +1646 Karma.karma._counters.errors++; +1647 that.status = "error"; +1648 var errorMsg = "Error: " + that._type.toUpperCase() + +1649 " " + that.name + " cannot be loaded."; +1650 Karma.karma._updateStatus(errorMsg); +1651 }, +1652 false); +1653 that.node.addEventListener( +1654 "abort", +1655 function (e) { +1656 that.status = "aborted"; +1657 var errorMsg = "ABORT: " + that._type.toUpperCase() + +1658 " " + that.name + " loading was aborted."; +1659 Karma.karma._updateStatus(errorMsg); +1660 +1661 }, false); +1662 +1663 } +1664 }; +1665 \ No newline at end of file diff --git a/examples/Conozco-Uruguay/assets/svg/alien-sad.svg b/examples/Conozco-Uruguay/assets/svg/alien-sad.svg index 34ea921..34ea921 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/alien-sad.svg +++ b/examples/Conozco-Uruguay/assets/svg/alien-sad.svg diff --git a/examples/Conozco-Uruguay/assets/svg/alien1.svg b/examples/Conozco-Uruguay/assets/svg/alien1.svg index 2bcf866..2bcf866 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/alien1.svg +++ b/examples/Conozco-Uruguay/assets/svg/alien1.svg diff --git a/examples/Conozco-Uruguay/assets/svg/alien2.svg b/examples/Conozco-Uruguay/assets/svg/alien2.svg index bf6f73e..bf6f73e 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/alien2.svg +++ b/examples/Conozco-Uruguay/assets/svg/alien2.svg diff --git a/examples/Conozco-Uruguay/assets/svg/alien3.svg b/examples/Conozco-Uruguay/assets/svg/alien3.svg index 377ee92..377ee92 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/alien3.svg +++ b/examples/Conozco-Uruguay/assets/svg/alien3.svg diff --git a/examples/Conozco-Uruguay/assets/svg/alien4.svg b/examples/Conozco-Uruguay/assets/svg/alien4.svg index e726de1..e726de1 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/alien4.svg +++ b/examples/Conozco-Uruguay/assets/svg/alien4.svg diff --git a/examples/Conozco-Uruguay/assets/svg/alien5.svg b/examples/Conozco-Uruguay/assets/svg/alien5.svg index b86eaa8..b86eaa8 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/alien5.svg +++ b/examples/Conozco-Uruguay/assets/svg/alien5.svg diff --git a/examples/Conozco-Uruguay/assets/svg/capitals2.svg b/examples/Conozco-Uruguay/assets/svg/capitals2.svg index a549de0..a549de0 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/capitals2.svg +++ b/examples/Conozco-Uruguay/assets/svg/capitals2.svg diff --git a/examples/Conozco-Uruguay/assets/svg/helpIcon.svg b/examples/Conozco-Uruguay/assets/svg/helpIcon.svg index d83c915..d83c915 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/helpIcon.svg +++ b/examples/Conozco-Uruguay/assets/svg/helpIcon.svg diff --git a/examples/Conozco-Uruguay/assets/svg/helpScreen.svg b/examples/Conozco-Uruguay/assets/svg/helpScreen.svg index 6271a3d..6271a3d 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/helpScreen.svg +++ b/examples/Conozco-Uruguay/assets/svg/helpScreen.svg diff --git a/examples/Conozco-Uruguay/assets/svg/playAgain.svg b/examples/Conozco-Uruguay/assets/svg/playAgain.svg index 251eaf5..251eaf5 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/playAgain.svg +++ b/examples/Conozco-Uruguay/assets/svg/playAgain.svg diff --git a/examples/Conozco-Uruguay/assets/svg/quitIcon.svg b/examples/Conozco-Uruguay/assets/svg/quitIcon.svg index 51d8cdb..51d8cdb 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/quitIcon.svg +++ b/examples/Conozco-Uruguay/assets/svg/quitIcon.svg diff --git a/examples/Conozco-Uruguay/assets/svg/spaceship1.svg b/examples/Conozco-Uruguay/assets/svg/spaceship1.svg index 0572a51..0572a51 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/spaceship1.svg +++ b/examples/Conozco-Uruguay/assets/svg/spaceship1.svg diff --git a/examples/Conozco-Uruguay/assets/svg/spaceship2.svg b/examples/Conozco-Uruguay/assets/svg/spaceship2.svg index 4288c2e..4288c2e 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/spaceship2.svg +++ b/examples/Conozco-Uruguay/assets/svg/spaceship2.svg diff --git a/examples/Conozco-Uruguay/assets/svg/spaceship80x200.svg b/examples/Conozco-Uruguay/assets/svg/spaceship80x200.svg index e7d84eb..e7d84eb 100644..100755 --- a/examples/Conozco-Uruguay/assets/svg/spaceship80x200.svg +++ b/examples/Conozco-Uruguay/assets/svg/spaceship80x200.svg diff --git a/examples/Math_Largest_Number_Identification/js/lesson.js b/examples/Math_Largest_Number_Identification/js/lesson.js index 769b7b4..769b7b4 100644..100755 --- a/examples/Math_Largest_Number_Identification/js/lesson.js +++ b/examples/Math_Largest_Number_Identification/js/lesson.js diff --git a/examples/NumberWords-svg/assets/svg/crossword.svg b/examples/NumberWords-svg/assets/svg/crossword.svg index 19fa940..19fa940 100644..100755 --- a/examples/NumberWords-svg/assets/svg/crossword.svg +++ b/examples/NumberWords-svg/assets/svg/crossword.svg diff --git a/examples/NumberWords-svg/index.html b/examples/NumberWords-svg/index.html index dd93b92..dd93b92 100644..100755 --- a/examples/NumberWords-svg/index.html +++ b/examples/NumberWords-svg/index.html diff --git a/examples/NumberWords-svg/js/lesson.js b/examples/NumberWords-svg/js/lesson.js index d9e9347..d9e9347 100644..100755 --- a/examples/NumberWords-svg/js/lesson.js +++ b/examples/NumberWords-svg/js/lesson.js diff --git a/examples/NumberWords/assets/image/football.png b/examples/NumberWords/assets/image/football.png index 93dbd71..93dbd71 100644..100755 --- a/examples/NumberWords/assets/image/football.png +++ b/examples/NumberWords/assets/image/football.png Binary files differ diff --git a/examples/NumberWords/assets/image/gameOver.png b/examples/NumberWords/assets/image/gameOver.png index 8114f48..8114f48 100644..100755 --- a/examples/NumberWords/assets/image/gameOver.png +++ b/examples/NumberWords/assets/image/gameOver.png Binary files differ diff --git a/examples/NumberWords/css/lesson.css b/examples/NumberWords/css/lesson.css index 1850cdc..1850cdc 100644..100755 --- a/examples/NumberWords/css/lesson.css +++ b/examples/NumberWords/css/lesson.css diff --git a/examples/NumberWords/index.html b/examples/NumberWords/index.html index 4c9319b..4c9319b 100644..100755 --- a/examples/NumberWords/index.html +++ b/examples/NumberWords/index.html diff --git a/examples/NumberWords/js/lesson.js b/examples/NumberWords/js/lesson.js index cf16aba..4eed9b0 100644..100755 --- a/examples/NumberWords/js/lesson.js +++ b/examples/NumberWords/js/lesson.js @@ -25,7 +25,7 @@ $(document).ready (function(){ var shuffle = function (choices) { for(var i=0;i= endTimerY ){ - //you didn't answer in time - k.sounds["trigger"].play(); - answer(false, true); - game(); - } - else { - k.canvases['timer'].clear(); - startTimerY = startTimerY + offsetTimerY; - k.canvases['timer'].ctx.fillStyle = "#fff"; - k.canvases['timer'].ctx.fillRect(10, startTimerY, endTimerX, 20); - } - }; - - - function game () { - $.each(k.canvases, function () { - if (this.name != "chimp"){ - this.clear(); - } - }); - - - writeScore(); - total = k.rand( 2, 10 ); //the total - n0 = total - k.rand(1, total - 1 ); //first number - n1 = total - n0; //second number - - //chose one option (the correct option) - //and then put the correct value into it - correct = k.rand( 0, 2 ); - choices[ correct ] = total; - - for (var i=0; i<3; i++) { - //generate the two other options - if ( choices[i] === total) { - continue; - } else { - // generate the other options - choices[ i ] = k.rand( 2, 10 ); - for (var j = 0; j < i; j++){ - if (choices[i] === choices[j]) { - choices[ i ] = k.rand( 2, 10 ); - } - } - } - } - - var imgId = imgNames[ level ] ; - - - var card = function (surface, n, minx, miny, d ) { - surface.save(); - //var r = k.rectangle({x:minx, y:miny, width:maskd, height:maskd, - // stroke:false,fill:false}).draw(surface); - - // var r = surface.rectangle({x:minx, y:miny, width:maskd, height:maskd, - // stroke:false,fill:false} ); - - //do the clip - //surface.clip(); - var pos = []; - var x, y, flag; - - - for (var i=0; i + * Warning: It's slower than distance2 function + * @param {Object} Point No. 0 + * @param {Number} Point0.x + * @param {Number} Point0.y + * @param {Object} Point No. 1 + * @param {Number} Point1.x + * @param {Number} Point1.y + * @returns {Number} The Euclidian distance + * @example + * + * p0 = {x:0, y:1}; + * p1 = {x:50, y:70}; + * var d = distance2(p0, p1); + * + */ +Karma.distance = function ( p0, p1 ) { + return Math.sqrt( this.distance2( p0, p1 ) ); +}; + +/** Returns a random number within the range provided + * @param {Number} lower limit of the range, lowest number that can be returned + * @param {Number} upper limit of the range, highest number that can be returned + * @returns {Number} number that is >= lower and <= upper + * @example + * + * var num = rand(0, 10); + * + * //num could be 0, 1, 2, 3 ... or 10 + * + */ +Karma.rand = function ( lower, upper ){ + return Math.round( Math.random() * (upper - lower) + lower ); +}; + /** Stores global settings for the Karma library * @class This object stores the global settings for the Karma library @@ -410,69 +486,7 @@ Karma.karma = { return locale.length > 2 ? "" + lang + divider + country : lang; }, - // Below are geometry and math helper methods - - /** - * Converts a value from degrees to radians. - * @param {Number} angle The angle in degrees - * @returns {Number} The angle in radians - */ - radians : function( angle ){ - return ( angle / 180 ) * Math.PI; - }, - /** - * Gets the square of the Euclidian (ordinary) distance between 2 points. - * @param {Object} Point No. 0 - * @param {Number} Point0.x - * @param {Number} Point0.y - * @param {Object} Point No. 1 - * @param {Number} Point1.x - * @param {Number} Point1.y - * @returns {Number} The square of the Euclidian distance - * @example - * - * p0 = {x:0, y:1}; - * p1 = {x:50, y:70}; - * var d = distance2(p0, p1); - * - */ - distance2 : function ( p0, p1 ) { - return (p1.x - p0.x) * (p1.x - p0.x) + (p1.y - p1.y) * (p1.y - p1.y); - }, - /** - * Gets the Euclidian (ordinary) distance between 2 points.
- * Warning: It's slower than distance2 function - * @param {Object} Point No. 0 - * @param {Number} Point0.x - * @param {Number} Point0.y - * @param {Object} Point No. 1 - * @param {Number} Point1.x - * @param {Number} Point1.y - * @returns {Number} The Euclidian distance - * @example - * - * p0 = {x:0, y:1}; - * p1 = {x:50, y:70}; - * var d = distance2(p0, p1); - * - */ - distance : function ( p0, p1 ) { - return Math.sqrt( this.distance2( p0, p1 ) ); - }, - /** Returns a random number within the range provided - * @param {Number} lower limit of the range, lowest number that can be returned - * @param {Number} upper limit of the range, highest number that can be returned - * @returns {Number} number that is >= lower and <= upper - * @example - * - * var num = rand(0, 10); - * - * //num could be 0, 1, 2, 3 ... or 10 - * - */ - rand : function ( lower, upper ){ - return Math.round( Math.random() * (upper - lower) + lower ); - } + }; diff --git a/tests/js/tests.js b/tests/js/tests.js index d774524..15e1f81 100755 --- a/tests/js/tests.js +++ b/tests/js/tests.js @@ -748,32 +748,32 @@ //Karma.karma.radians - test('Karma.karma.radians', + test('Karma.radians', function(){ expect(1); - ok(k.radians(50) >= 0.87 && - k.radians(50) <= 0.88, + ok(Karma.radians(50) >= 0.87 && + Karma.radians(50) <= 0.88, "correct result computed"); }); - //Karma.karma.distance2 - test('Karma.karma.distance2', + //Karma.distance2 + test('Karma.distance2', function(){ - ok(k.distance2({x: 1, y:2}, {x: 9, y: 15}) === 64, + ok(Karma.distance2({x: 1, y:2}, {x: 9, y: 15}) === 64, "returns correct value"); }); - //Karma.karma.distance - test('Karma.karma.distance', + //Karma.distance + test('Karma.distance', function(){ - ok(k.distance({x: 1, y:2}, {x: 9, y: 15}) === 8, + ok(Karma.distance({x: 1, y:2}, {x: 9, y: 15}) === 8, "returns correct value"); }); - //Karma.karma.rand - test('Karma.karma.rand', + //Karma.rand + test('Karma.rand', function(){ - var rand = k.rand(5, 8); + var rand = Karma.rand(5, 8); ok(rand >= 5 && rand <= 8, "Generates valid range of numbers"); } diff --git a/tools/jsdoc-toolkit/README.txt b/tools/jsdoc-toolkit/README.txt index 3782da8..3782da8 100644..100755 --- a/tools/jsdoc-toolkit/README.txt +++ b/tools/jsdoc-toolkit/README.txt diff --git a/tools/jsdoc-toolkit/app/frame.js b/tools/jsdoc-toolkit/app/frame.js index 1beb405..1beb405 100644..100755 --- a/tools/jsdoc-toolkit/app/frame.js +++ b/tools/jsdoc-toolkit/app/frame.js diff --git a/tools/jsdoc-toolkit/app/frame/Chain.js b/tools/jsdoc-toolkit/app/frame/Chain.js index 506469d..506469d 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/Chain.js +++ b/tools/jsdoc-toolkit/app/frame/Chain.js diff --git a/tools/jsdoc-toolkit/app/frame/Dumper.js b/tools/jsdoc-toolkit/app/frame/Dumper.js index d8b007b..d8b007b 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/Dumper.js +++ b/tools/jsdoc-toolkit/app/frame/Dumper.js diff --git a/tools/jsdoc-toolkit/app/frame/Hash.js b/tools/jsdoc-toolkit/app/frame/Hash.js index 62cfad6..62cfad6 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/Hash.js +++ b/tools/jsdoc-toolkit/app/frame/Hash.js diff --git a/tools/jsdoc-toolkit/app/frame/Link.js b/tools/jsdoc-toolkit/app/frame/Link.js index ef5dc0a..ef5dc0a 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/Link.js +++ b/tools/jsdoc-toolkit/app/frame/Link.js diff --git a/tools/jsdoc-toolkit/app/frame/Namespace.js b/tools/jsdoc-toolkit/app/frame/Namespace.js index fa1e41d..fa1e41d 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/Namespace.js +++ b/tools/jsdoc-toolkit/app/frame/Namespace.js diff --git a/tools/jsdoc-toolkit/app/frame/Opt.js b/tools/jsdoc-toolkit/app/frame/Opt.js index 352f159..352f159 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/Opt.js +++ b/tools/jsdoc-toolkit/app/frame/Opt.js diff --git a/tools/jsdoc-toolkit/app/frame/Reflection.js b/tools/jsdoc-toolkit/app/frame/Reflection.js index 0968f1c..0968f1c 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/Reflection.js +++ b/tools/jsdoc-toolkit/app/frame/Reflection.js diff --git a/tools/jsdoc-toolkit/app/frame/String.js b/tools/jsdoc-toolkit/app/frame/String.js index c183c27..c183c27 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/String.js +++ b/tools/jsdoc-toolkit/app/frame/String.js diff --git a/tools/jsdoc-toolkit/app/frame/Testrun.js b/tools/jsdoc-toolkit/app/frame/Testrun.js index dbd80fc..dbd80fc 100644..100755 --- a/tools/jsdoc-toolkit/app/frame/Testrun.js +++ b/tools/jsdoc-toolkit/app/frame/Testrun.js diff --git a/tools/jsdoc-toolkit/app/handlers/FOODOC.js b/tools/jsdoc-toolkit/app/handlers/FOODOC.js index b208f55..b208f55 100644..100755 --- a/tools/jsdoc-toolkit/app/handlers/FOODOC.js +++ b/tools/jsdoc-toolkit/app/handlers/FOODOC.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC.js b/tools/jsdoc-toolkit/app/lib/JSDOC.js index ca59089..ca59089 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/DocComment.js b/tools/jsdoc-toolkit/app/lib/JSDOC/DocComment.js index c6c8d7d..c6c8d7d 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/DocComment.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/DocTag.js b/tools/jsdoc-toolkit/app/lib/JSDOC/DocTag.js index 77ec07c..77ec07c 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/DocTag.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js b/tools/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js index 2c4bfb8..2c4bfb8 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js b/tools/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js index bcaebc9..bcaebc9 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/Lang.js b/tools/jsdoc-toolkit/app/lib/JSDOC/Lang.js index 62919d7..62919d7 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/Lang.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/Lang.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/Parser.js b/tools/jsdoc-toolkit/app/lib/JSDOC/Parser.js index f407dd1..f407dd1 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/Parser.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/Parser.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js b/tools/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js index 9c91193..9c91193 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/Symbol.js b/tools/jsdoc-toolkit/app/lib/JSDOC/Symbol.js index c5b76a8..c5b76a8 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/Symbol.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js b/tools/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js index 82657e4..82657e4 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/TextStream.js b/tools/jsdoc-toolkit/app/lib/JSDOC/TextStream.js index ccc48a8..ccc48a8 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/TextStream.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/Token.js b/tools/jsdoc-toolkit/app/lib/JSDOC/Token.js index fb7f9d9..fb7f9d9 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/Token.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/Token.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js b/tools/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js index 9f658fb..9f658fb 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js b/tools/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js index 1eeb44c..1eeb44c 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/Util.js b/tools/jsdoc-toolkit/app/lib/JSDOC/Util.js index 6d7edb3..6d7edb3 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/Util.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/Util.js diff --git a/tools/jsdoc-toolkit/app/lib/JSDOC/Walker.js b/tools/jsdoc-toolkit/app/lib/JSDOC/Walker.js index befec4d..befec4d 100644..100755 --- a/tools/jsdoc-toolkit/app/lib/JSDOC/Walker.js +++ b/tools/jsdoc-toolkit/app/lib/JSDOC/Walker.js diff --git a/tools/jsdoc-toolkit/app/main.js b/tools/jsdoc-toolkit/app/main.js index 9b78182..9b78182 100644..100755 --- a/tools/jsdoc-toolkit/app/main.js +++ b/tools/jsdoc-toolkit/app/main.js diff --git a/tools/jsdoc-toolkit/app/plugins/commentSrcJson.js b/tools/jsdoc-toolkit/app/plugins/commentSrcJson.js index e826b57..e826b57 100644..100755 --- a/tools/jsdoc-toolkit/app/plugins/commentSrcJson.js +++ b/tools/jsdoc-toolkit/app/plugins/commentSrcJson.js diff --git a/tools/jsdoc-toolkit/app/plugins/frameworkPrototype.js b/tools/jsdoc-toolkit/app/plugins/frameworkPrototype.js index 9c41751..9c41751 100644..100755 --- a/tools/jsdoc-toolkit/app/plugins/frameworkPrototype.js +++ b/tools/jsdoc-toolkit/app/plugins/frameworkPrototype.js diff --git a/tools/jsdoc-toolkit/app/plugins/functionCall.js b/tools/jsdoc-toolkit/app/plugins/functionCall.js index 6f87705..6f87705 100644..100755 --- a/tools/jsdoc-toolkit/app/plugins/functionCall.js +++ b/tools/jsdoc-toolkit/app/plugins/functionCall.js diff --git a/tools/jsdoc-toolkit/app/plugins/publishSrcHilite.js b/tools/jsdoc-toolkit/app/plugins/publishSrcHilite.js index 65514f2..65514f2 100644..100755 --- a/tools/jsdoc-toolkit/app/plugins/publishSrcHilite.js +++ b/tools/jsdoc-toolkit/app/plugins/publishSrcHilite.js diff --git a/tools/jsdoc-toolkit/app/plugins/symbolLink.js b/tools/jsdoc-toolkit/app/plugins/symbolLink.js index c87f1ca..c87f1ca 100644..100755 --- a/tools/jsdoc-toolkit/app/plugins/symbolLink.js +++ b/tools/jsdoc-toolkit/app/plugins/symbolLink.js diff --git a/tools/jsdoc-toolkit/app/plugins/tagParamConfig.js b/tools/jsdoc-toolkit/app/plugins/tagParamConfig.js index 3ea8a1b..3ea8a1b 100644..100755 --- a/tools/jsdoc-toolkit/app/plugins/tagParamConfig.js +++ b/tools/jsdoc-toolkit/app/plugins/tagParamConfig.js diff --git a/tools/jsdoc-toolkit/app/plugins/tagSynonyms.js b/tools/jsdoc-toolkit/app/plugins/tagSynonyms.js index 49a874f..49a874f 100644..100755 --- a/tools/jsdoc-toolkit/app/plugins/tagSynonyms.js +++ b/tools/jsdoc-toolkit/app/plugins/tagSynonyms.js diff --git a/tools/jsdoc-toolkit/app/run.js b/tools/jsdoc-toolkit/app/run.js index 1f875cd..1f875cd 100644..100755 --- a/tools/jsdoc-toolkit/app/run.js +++ b/tools/jsdoc-toolkit/app/run.js diff --git a/tools/jsdoc-toolkit/app/t/TestDoc.js b/tools/jsdoc-toolkit/app/t/TestDoc.js index c0768b7..c0768b7 100644..100755 --- a/tools/jsdoc-toolkit/app/t/TestDoc.js +++ b/tools/jsdoc-toolkit/app/t/TestDoc.js diff --git a/tools/jsdoc-toolkit/app/t/runner.js b/tools/jsdoc-toolkit/app/t/runner.js index 3f9fb4c..3f9fb4c 100644..100755 --- a/tools/jsdoc-toolkit/app/t/runner.js +++ b/tools/jsdoc-toolkit/app/t/runner.js diff --git a/tools/jsdoc-toolkit/app/test.js b/tools/jsdoc-toolkit/app/test.js index 787d84f..787d84f 100644..100755 --- a/tools/jsdoc-toolkit/app/test.js +++ b/tools/jsdoc-toolkit/app/test.js diff --git a/tools/jsdoc-toolkit/app/test/addon.js b/tools/jsdoc-toolkit/app/test/addon.js index 8886205..8886205 100644..100755 --- a/tools/jsdoc-toolkit/app/test/addon.js +++ b/tools/jsdoc-toolkit/app/test/addon.js diff --git a/tools/jsdoc-toolkit/app/test/anon_inner.js b/tools/jsdoc-toolkit/app/test/anon_inner.js index 227eeee..227eeee 100644..100755 --- a/tools/jsdoc-toolkit/app/test/anon_inner.js +++ b/tools/jsdoc-toolkit/app/test/anon_inner.js diff --git a/tools/jsdoc-toolkit/app/test/augments.js b/tools/jsdoc-toolkit/app/test/augments.js index 12e706e..12e706e 100644..100755 --- a/tools/jsdoc-toolkit/app/test/augments.js +++ b/tools/jsdoc-toolkit/app/test/augments.js diff --git a/tools/jsdoc-toolkit/app/test/augments2.js b/tools/jsdoc-toolkit/app/test/augments2.js index e8388f0..e8388f0 100644..100755 --- a/tools/jsdoc-toolkit/app/test/augments2.js +++ b/tools/jsdoc-toolkit/app/test/augments2.js diff --git a/tools/jsdoc-toolkit/app/test/borrows.js b/tools/jsdoc-toolkit/app/test/borrows.js index a5d8ea4..a5d8ea4 100644..100755 --- a/tools/jsdoc-toolkit/app/test/borrows.js +++ b/tools/jsdoc-toolkit/app/test/borrows.js diff --git a/tools/jsdoc-toolkit/app/test/borrows2.js b/tools/jsdoc-toolkit/app/test/borrows2.js index c0d5ea2..c0d5ea2 100644..100755 --- a/tools/jsdoc-toolkit/app/test/borrows2.js +++ b/tools/jsdoc-toolkit/app/test/borrows2.js diff --git a/tools/jsdoc-toolkit/app/test/config.js b/tools/jsdoc-toolkit/app/test/config.js index 0748a21..0748a21 100644..100755 --- a/tools/jsdoc-toolkit/app/test/config.js +++ b/tools/jsdoc-toolkit/app/test/config.js diff --git a/tools/jsdoc-toolkit/app/test/constructs.js b/tools/jsdoc-toolkit/app/test/constructs.js index cca5dbd..cca5dbd 100644..100755 --- a/tools/jsdoc-toolkit/app/test/constructs.js +++ b/tools/jsdoc-toolkit/app/test/constructs.js diff --git a/tools/jsdoc-toolkit/app/test/encoding.js b/tools/jsdoc-toolkit/app/test/encoding.js index ba64219..ba64219 100644..100755 --- a/tools/jsdoc-toolkit/app/test/encoding.js +++ b/tools/jsdoc-toolkit/app/test/encoding.js diff --git a/tools/jsdoc-toolkit/app/test/encoding_other.js b/tools/jsdoc-toolkit/app/test/encoding_other.js index b144da4..b144da4 100644..100755 --- a/tools/jsdoc-toolkit/app/test/encoding_other.js +++ b/tools/jsdoc-toolkit/app/test/encoding_other.js diff --git a/tools/jsdoc-toolkit/app/test/event.js b/tools/jsdoc-toolkit/app/test/event.js index 7e41d6f..7e41d6f 100644..100755 --- a/tools/jsdoc-toolkit/app/test/event.js +++ b/tools/jsdoc-toolkit/app/test/event.js diff --git a/tools/jsdoc-toolkit/app/test/exports.js b/tools/jsdoc-toolkit/app/test/exports.js index 63a87cb..63a87cb 100644..100755 --- a/tools/jsdoc-toolkit/app/test/exports.js +++ b/tools/jsdoc-toolkit/app/test/exports.js diff --git a/tools/jsdoc-toolkit/app/test/functions_anon.js b/tools/jsdoc-toolkit/app/test/functions_anon.js index e9dd6c1..e9dd6c1 100644..100755 --- a/tools/jsdoc-toolkit/app/test/functions_anon.js +++ b/tools/jsdoc-toolkit/app/test/functions_anon.js diff --git a/tools/jsdoc-toolkit/app/test/functions_nested.js b/tools/jsdoc-toolkit/app/test/functions_nested.js index f044faf..f044faf 100644..100755 --- a/tools/jsdoc-toolkit/app/test/functions_nested.js +++ b/tools/jsdoc-toolkit/app/test/functions_nested.js diff --git a/tools/jsdoc-toolkit/app/test/global.js b/tools/jsdoc-toolkit/app/test/global.js index 5ea4894..5ea4894 100644..100755 --- a/tools/jsdoc-toolkit/app/test/global.js +++ b/tools/jsdoc-toolkit/app/test/global.js diff --git a/tools/jsdoc-toolkit/app/test/globals.js b/tools/jsdoc-toolkit/app/test/globals.js index 3f83fb1..3f83fb1 100644..100755 --- a/tools/jsdoc-toolkit/app/test/globals.js +++ b/tools/jsdoc-toolkit/app/test/globals.js diff --git a/tools/jsdoc-toolkit/app/test/ignore.js b/tools/jsdoc-toolkit/app/test/ignore.js index d3fac9e..d3fac9e 100644..100755 --- a/tools/jsdoc-toolkit/app/test/ignore.js +++ b/tools/jsdoc-toolkit/app/test/ignore.js diff --git a/tools/jsdoc-toolkit/app/test/inner.js b/tools/jsdoc-toolkit/app/test/inner.js index 37cfa9d..37cfa9d 100644..100755 --- a/tools/jsdoc-toolkit/app/test/inner.js +++ b/tools/jsdoc-toolkit/app/test/inner.js diff --git a/tools/jsdoc-toolkit/app/test/jsdoc_test.js b/tools/jsdoc-toolkit/app/test/jsdoc_test.js index 0817712..0817712 100644..100755 --- a/tools/jsdoc-toolkit/app/test/jsdoc_test.js +++ b/tools/jsdoc-toolkit/app/test/jsdoc_test.js diff --git a/tools/jsdoc-toolkit/app/test/lend.js b/tools/jsdoc-toolkit/app/test/lend.js index 92b15d5..92b15d5 100644..100755 --- a/tools/jsdoc-toolkit/app/test/lend.js +++ b/tools/jsdoc-toolkit/app/test/lend.js diff --git a/tools/jsdoc-toolkit/app/test/memberof.js b/tools/jsdoc-toolkit/app/test/memberof.js index 883bbde..883bbde 100644..100755 --- a/tools/jsdoc-toolkit/app/test/memberof.js +++ b/tools/jsdoc-toolkit/app/test/memberof.js diff --git a/tools/jsdoc-toolkit/app/test/memberof_constructor.js b/tools/jsdoc-toolkit/app/test/memberof_constructor.js index 80fde73..80fde73 100644..100755 --- a/tools/jsdoc-toolkit/app/test/memberof_constructor.js +++ b/tools/jsdoc-toolkit/app/test/memberof_constructor.js diff --git a/tools/jsdoc-toolkit/app/test/module.js b/tools/jsdoc-toolkit/app/test/module.js index 5b3fe42..5b3fe42 100644..100755 --- a/tools/jsdoc-toolkit/app/test/module.js +++ b/tools/jsdoc-toolkit/app/test/module.js diff --git a/tools/jsdoc-toolkit/app/test/name.js b/tools/jsdoc-toolkit/app/test/name.js index e88a51a..e88a51a 100644..100755 --- a/tools/jsdoc-toolkit/app/test/name.js +++ b/tools/jsdoc-toolkit/app/test/name.js diff --git a/tools/jsdoc-toolkit/app/test/namespace_nested.js b/tools/jsdoc-toolkit/app/test/namespace_nested.js index 46cafa2..46cafa2 100644..100755 --- a/tools/jsdoc-toolkit/app/test/namespace_nested.js +++ b/tools/jsdoc-toolkit/app/test/namespace_nested.js diff --git a/tools/jsdoc-toolkit/app/test/nocode.js b/tools/jsdoc-toolkit/app/test/nocode.js index 1cf99bc..1cf99bc 100644..100755 --- a/tools/jsdoc-toolkit/app/test/nocode.js +++ b/tools/jsdoc-toolkit/app/test/nocode.js diff --git a/tools/jsdoc-toolkit/app/test/oblit_anon.js b/tools/jsdoc-toolkit/app/test/oblit_anon.js index 8d9e941..8d9e941 100644..100755 --- a/tools/jsdoc-toolkit/app/test/oblit_anon.js +++ b/tools/jsdoc-toolkit/app/test/oblit_anon.js diff --git a/tools/jsdoc-toolkit/app/test/overview.js b/tools/jsdoc-toolkit/app/test/overview.js index 1dfc09b..1dfc09b 100644..100755 --- a/tools/jsdoc-toolkit/app/test/overview.js +++ b/tools/jsdoc-toolkit/app/test/overview.js diff --git a/tools/jsdoc-toolkit/app/test/param_inline.js b/tools/jsdoc-toolkit/app/test/param_inline.js index 09845b2..09845b2 100644..100755 --- a/tools/jsdoc-toolkit/app/test/param_inline.js +++ b/tools/jsdoc-toolkit/app/test/param_inline.js diff --git a/tools/jsdoc-toolkit/app/test/params_optional.js b/tools/jsdoc-toolkit/app/test/params_optional.js index 18bf598..18bf598 100644..100755 --- a/tools/jsdoc-toolkit/app/test/params_optional.js +++ b/tools/jsdoc-toolkit/app/test/params_optional.js diff --git a/tools/jsdoc-toolkit/app/test/prototype.js b/tools/jsdoc-toolkit/app/test/prototype.js index 1147008..1147008 100644..100755 --- a/tools/jsdoc-toolkit/app/test/prototype.js +++ b/tools/jsdoc-toolkit/app/test/prototype.js diff --git a/tools/jsdoc-toolkit/app/test/prototype_nested.js b/tools/jsdoc-toolkit/app/test/prototype_nested.js index e8ca1ce..e8ca1ce 100644..100755 --- a/tools/jsdoc-toolkit/app/test/prototype_nested.js +++ b/tools/jsdoc-toolkit/app/test/prototype_nested.js diff --git a/tools/jsdoc-toolkit/app/test/prototype_oblit.js b/tools/jsdoc-toolkit/app/test/prototype_oblit.js index 6cfc39c..6cfc39c 100644..100755 --- a/tools/jsdoc-toolkit/app/test/prototype_oblit.js +++ b/tools/jsdoc-toolkit/app/test/prototype_oblit.js diff --git a/tools/jsdoc-toolkit/app/test/prototype_oblit_constructor.js b/tools/jsdoc-toolkit/app/test/prototype_oblit_constructor.js index 9248248..9248248 100644..100755 --- a/tools/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +++ b/tools/jsdoc-toolkit/app/test/prototype_oblit_constructor.js diff --git a/tools/jsdoc-toolkit/app/test/public.js b/tools/jsdoc-toolkit/app/test/public.js index 35d34f6..35d34f6 100644..100755 --- a/tools/jsdoc-toolkit/app/test/public.js +++ b/tools/jsdoc-toolkit/app/test/public.js diff --git a/tools/jsdoc-toolkit/app/test/scripts/code.js b/tools/jsdoc-toolkit/app/test/scripts/code.js index e9d7ed2..e9d7ed2 100644..100755 --- a/tools/jsdoc-toolkit/app/test/scripts/code.js +++ b/tools/jsdoc-toolkit/app/test/scripts/code.js diff --git a/tools/jsdoc-toolkit/app/test/scripts/notcode.txt b/tools/jsdoc-toolkit/app/test/scripts/notcode.txt index fcd737e..fcd737e 100644..100755 --- a/tools/jsdoc-toolkit/app/test/scripts/notcode.txt +++ b/tools/jsdoc-toolkit/app/test/scripts/notcode.txt diff --git a/tools/jsdoc-toolkit/app/test/shared.js b/tools/jsdoc-toolkit/app/test/shared.js index e1c277a..e1c277a 100644..100755 --- a/tools/jsdoc-toolkit/app/test/shared.js +++ b/tools/jsdoc-toolkit/app/test/shared.js diff --git a/tools/jsdoc-toolkit/app/test/shared2.js b/tools/jsdoc-toolkit/app/test/shared2.js index 3f7736a..3f7736a 100644..100755 --- a/tools/jsdoc-toolkit/app/test/shared2.js +++ b/tools/jsdoc-toolkit/app/test/shared2.js diff --git a/tools/jsdoc-toolkit/app/test/shortcuts.js b/tools/jsdoc-toolkit/app/test/shortcuts.js index f738f1e..f738f1e 100644..100755 --- a/tools/jsdoc-toolkit/app/test/shortcuts.js +++ b/tools/jsdoc-toolkit/app/test/shortcuts.js diff --git a/tools/jsdoc-toolkit/app/test/static_this.js b/tools/jsdoc-toolkit/app/test/static_this.js index 9407b20..9407b20 100644..100755 --- a/tools/jsdoc-toolkit/app/test/static_this.js +++ b/tools/jsdoc-toolkit/app/test/static_this.js diff --git a/tools/jsdoc-toolkit/app/test/synonyms.js b/tools/jsdoc-toolkit/app/test/synonyms.js index 09066b9..09066b9 100644..100755 --- a/tools/jsdoc-toolkit/app/test/synonyms.js +++ b/tools/jsdoc-toolkit/app/test/synonyms.js diff --git a/tools/jsdoc-toolkit/app/test/tosource.js b/tools/jsdoc-toolkit/app/test/tosource.js index 706d476..706d476 100644..100755 --- a/tools/jsdoc-toolkit/app/test/tosource.js +++ b/tools/jsdoc-toolkit/app/test/tosource.js diff --git a/tools/jsdoc-toolkit/app/test/variable_redefine.js b/tools/jsdoc-toolkit/app/test/variable_redefine.js index 2c07da0..2c07da0 100644..100755 --- a/tools/jsdoc-toolkit/app/test/variable_redefine.js +++ b/tools/jsdoc-toolkit/app/test/variable_redefine.js diff --git a/tools/jsdoc-toolkit/changes.txt b/tools/jsdoc-toolkit/changes.txt index d664750..d664750 100644..100755 --- a/tools/jsdoc-toolkit/changes.txt +++ b/tools/jsdoc-toolkit/changes.txt diff --git a/tools/jsdoc-toolkit/conf/sample.conf b/tools/jsdoc-toolkit/conf/sample.conf index ad0f08e..ad0f08e 100644..100755 --- a/tools/jsdoc-toolkit/conf/sample.conf +++ b/tools/jsdoc-toolkit/conf/sample.conf diff --git a/tools/jsdoc-toolkit/java/build.xml b/tools/jsdoc-toolkit/java/build.xml index bb845ce..bb845ce 100644..100755 --- a/tools/jsdoc-toolkit/java/build.xml +++ b/tools/jsdoc-toolkit/java/build.xml diff --git a/tools/jsdoc-toolkit/java/build_1.4.xml b/tools/jsdoc-toolkit/java/build_1.4.xml index ab408a4..ab408a4 100644..100755 --- a/tools/jsdoc-toolkit/java/build_1.4.xml +++ b/tools/jsdoc-toolkit/java/build_1.4.xml diff --git a/tools/jsdoc-toolkit/java/classes/js.jar b/tools/jsdoc-toolkit/java/classes/js.jar index 0352cb1..0352cb1 100644..100755 --- a/tools/jsdoc-toolkit/java/classes/js.jar +++ b/tools/jsdoc-toolkit/java/classes/js.jar Binary files differ diff --git a/tools/jsdoc-toolkit/java/src/JsRun.java b/tools/jsdoc-toolkit/java/src/JsRun.java index 25f519a..25f519a 100644..100755 --- a/tools/jsdoc-toolkit/java/src/JsRun.java +++ b/tools/jsdoc-toolkit/java/src/JsRun.java diff --git a/tools/jsdoc-toolkit/jsdebug.jar b/tools/jsdoc-toolkit/jsdebug.jar index a0ac7da..a0ac7da 100644..100755 --- a/tools/jsdoc-toolkit/jsdebug.jar +++ b/tools/jsdoc-toolkit/jsdebug.jar Binary files differ diff --git a/tools/jsdoc-toolkit/jsrun.jar b/tools/jsdoc-toolkit/jsrun.jar index 49c03f4..49c03f4 100644..100755 --- a/tools/jsdoc-toolkit/jsrun.jar +++ b/tools/jsdoc-toolkit/jsrun.jar Binary files differ diff --git a/tools/jsdoc-toolkit/jsrun.sh b/tools/jsdoc-toolkit/jsrun.sh index 74ca79c..74ca79c 100644..100755 --- a/tools/jsdoc-toolkit/jsrun.sh +++ b/tools/jsdoc-toolkit/jsrun.sh diff --git a/tools/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl b/tools/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl index 32f4358..32f4358 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +++ b/tools/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl diff --git a/tools/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl b/tools/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl index 4c7de1c..4c7de1c 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +++ b/tools/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl diff --git a/tools/jsdoc-toolkit/templates/jsdoc/class.tmpl b/tools/jsdoc-toolkit/templates/jsdoc/class.tmpl index 181ed11..181ed11 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/class.tmpl +++ b/tools/jsdoc-toolkit/templates/jsdoc/class.tmpl diff --git a/tools/jsdoc-toolkit/templates/jsdoc/index.tmpl b/tools/jsdoc-toolkit/templates/jsdoc/index.tmpl index a5dc115..a5dc115 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/index.tmpl +++ b/tools/jsdoc-toolkit/templates/jsdoc/index.tmpl diff --git a/tools/jsdoc-toolkit/templates/jsdoc/publish.js b/tools/jsdoc-toolkit/templates/jsdoc/publish.js index 446c92b..446c92b 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/publish.js +++ b/tools/jsdoc-toolkit/templates/jsdoc/publish.js diff --git a/tools/jsdoc-toolkit/templates/jsdoc/static/default.css b/tools/jsdoc-toolkit/templates/jsdoc/static/default.css index 97e021e..97e021e 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/static/default.css +++ b/tools/jsdoc-toolkit/templates/jsdoc/static/default.css diff --git a/tools/jsdoc-toolkit/templates/jsdoc/static/header.html b/tools/jsdoc-toolkit/templates/jsdoc/static/header.html index 353b735..353b735 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/static/header.html +++ b/tools/jsdoc-toolkit/templates/jsdoc/static/header.html diff --git a/tools/jsdoc-toolkit/templates/jsdoc/static/index.html b/tools/jsdoc-toolkit/templates/jsdoc/static/index.html index 661f6f6..661f6f6 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/static/index.html +++ b/tools/jsdoc-toolkit/templates/jsdoc/static/index.html diff --git a/tools/jsdoc-toolkit/templates/jsdoc/symbol.tmpl b/tools/jsdoc-toolkit/templates/jsdoc/symbol.tmpl index f8f4bd1..f8f4bd1 100644..100755 --- a/tools/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +++ b/tools/jsdoc-toolkit/templates/jsdoc/symbol.tmpl diff --git a/tools/xo_bundle/MANIFEST b/tools/xo_bundle/MANIFEST index 10e4068..10e4068 100644..100755 --- a/tools/xo_bundle/MANIFEST +++ b/tools/xo_bundle/MANIFEST -- cgit v0.9.1