Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchristophd@sugarlabs.org <christophd@sugarlabs.org>2009-08-27 09:42:49 (GMT)
committer christophd@sugarlabs.org <christophd@sugarlabs.org>2009-08-27 09:42:49 (GMT)
commit21bb63cfb7038be3fa08f83d8ea062bc5a106fb6 (patch)
tree6c140c0e0bddeda9e6c675cb96542ae8457ec946
parent59970dd675da8a3cfabd48cd46b25eb1f33ba00b (diff)
parent489b0c79bceb1a834eea001bca2e0b668764f1b0 (diff)
Merge branch 'master' of git://git.sugarlabs.org/karma/mainline
-rw-r--r--examples/adding_up_to_10/assets/generic/images/happyChimp_200x209.pngbin0 -> 27552 bytes
-rw-r--r--examples/adding_up_to_10/assets/generic/images/logo_w_name.pngbin0 -> 3726 bytes
-rw-r--r--examples/adding_up_to_10/assets/generic/images/normalChimp_200x209.pngbin0 -> 25474 bytes
-rw-r--r--examples/adding_up_to_10/assets/generic/images/sadChimp_200x209.pngbin0 -> 26127 bytes
-rw-r--r--examples/adding_up_to_10/assets/generic/images/sidebar.pngbin0 -> 8189 bytes
-rw-r--r--examples/adding_up_to_10/assets/generic/images/yellowBox.pngbin0 -> 1524 bytes
-rw-r--r--examples/adding_up_to_10/css/mytest.css71
-rw-r--r--examples/adding_up_to_10/css/mytest.css.~1~45
-rw-r--r--examples/adding_up_to_10/css/mytest.css.~2~64
-rw-r--r--examples/adding_up_to_10/js/mytest.js35
-rw-r--r--examples/adding_up_to_10/js/mytest.js.~1~35
-rwxr-xr-xexamples/adding_up_to_10/mytest.html134
-rwxr-xr-xjs/jquery.karma-0.1.js430
-rwxr-xr-xjs/jquery.karma-0.2.js266
14 files changed, 289 insertions, 791 deletions
diff --git a/examples/adding_up_to_10/assets/generic/images/happyChimp_200x209.png b/examples/adding_up_to_10/assets/generic/images/happyChimp_200x209.png
new file mode 100644
index 0000000..1103ac4
--- /dev/null
+++ b/examples/adding_up_to_10/assets/generic/images/happyChimp_200x209.png
Binary files differ
diff --git a/examples/adding_up_to_10/assets/generic/images/logo_w_name.png b/examples/adding_up_to_10/assets/generic/images/logo_w_name.png
new file mode 100644
index 0000000..8943803
--- /dev/null
+++ b/examples/adding_up_to_10/assets/generic/images/logo_w_name.png
Binary files differ
diff --git a/examples/adding_up_to_10/assets/generic/images/normalChimp_200x209.png b/examples/adding_up_to_10/assets/generic/images/normalChimp_200x209.png
new file mode 100644
index 0000000..59cdf68
--- /dev/null
+++ b/examples/adding_up_to_10/assets/generic/images/normalChimp_200x209.png
Binary files differ
diff --git a/examples/adding_up_to_10/assets/generic/images/sadChimp_200x209.png b/examples/adding_up_to_10/assets/generic/images/sadChimp_200x209.png
new file mode 100644
index 0000000..7dc2d37
--- /dev/null
+++ b/examples/adding_up_to_10/assets/generic/images/sadChimp_200x209.png
Binary files differ
diff --git a/examples/adding_up_to_10/assets/generic/images/sidebar.png b/examples/adding_up_to_10/assets/generic/images/sidebar.png
new file mode 100644
index 0000000..9632788
--- /dev/null
+++ b/examples/adding_up_to_10/assets/generic/images/sidebar.png
Binary files differ
diff --git a/examples/adding_up_to_10/assets/generic/images/yellowBox.png b/examples/adding_up_to_10/assets/generic/images/yellowBox.png
new file mode 100644
index 0000000..f7a72ca
--- /dev/null
+++ b/examples/adding_up_to_10/assets/generic/images/yellowBox.png
Binary files differ
diff --git a/examples/adding_up_to_10/css/mytest.css b/examples/adding_up_to_10/css/mytest.css
new file mode 100644
index 0000000..8ede8d9
--- /dev/null
+++ b/examples/adding_up_to_10/css/mytest.css
@@ -0,0 +1,71 @@
+#mainmain {
+ position: absolute;
+ height: 100%;
+ width: 100%;
+}
+
+#main {
+ height: 100%;
+ width: 70%;
+ float: left;
+}
+
+#mainTop {
+ height:50%;
+ width:100%;
+}
+#mainBottom {
+ height:50%;
+ width:100%;
+}
+#sidebar {
+ background:blue none repeat scroll 0 0;
+ float:left;
+ height:100%;
+ width:30%;
+}
+#mainTopLeft {
+ width:40%;
+ height:100%;
+ background:yellow;
+ float:left;
+}
+
+#mainTopMiddle {
+ width:20%;
+ height:100%;
+ background:red;
+ float:left;
+}
+
+#mainTopRight {
+ width:40%;
+ height:100%;
+ background:green;
+ float:left;
+}
+
+
+
+#mainBottomLeft {
+ float:left;
+ width:33.3%;
+ height:100%;
+ background:yellow;
+}
+
+
+#mainBottomMiddle {
+ float:left;
+ width:33.3%;
+ height:100%;
+ background:red;
+}
+
+
+#mainBottomRight {
+ float:left;
+ width:33.3%;
+ height:100%;
+ background:green;
+} \ No newline at end of file
diff --git a/examples/adding_up_to_10/css/mytest.css.~1~ b/examples/adding_up_to_10/css/mytest.css.~1~
new file mode 100644
index 0000000..21c75f9
--- /dev/null
+++ b/examples/adding_up_to_10/css/mytest.css.~1~
@@ -0,0 +1,45 @@
+#main {
+ float: left;
+ width: 68%;
+ height: 90%;
+ border: 2px solid black;
+}
+
+#mainTop {
+ width: 100%;
+ height: 90%;
+ border: 2px solid black;
+}
+
+#mainTopCanvas {
+ width: 100%;
+ height: 100%;
+ border: 2px solid black;
+}
+
+#mainBottom {
+ width: 100%;
+ height: 40%;
+ border: 2px solid black;
+}
+
+#aside {
+ float: right;
+ width: 28%;
+ height: 90%;
+ border: 2px solid blue;
+}
+
+#asideCanvas {
+ width: 40%;
+ height: 30%;
+ border: 2px solid black;
+}
+
+#mainBottomCanvas {
+ width: 60%;
+ height: 30%;
+ border: 2px solid black;
+}
+
+
diff --git a/examples/adding_up_to_10/css/mytest.css.~2~ b/examples/adding_up_to_10/css/mytest.css.~2~
new file mode 100644
index 0000000..42f5a6c
--- /dev/null
+++ b/examples/adding_up_to_10/css/mytest.css.~2~
@@ -0,0 +1,64 @@
+#main {
+ float:left;
+ height:50%;
+ width:80%;
+}
+#mainTop {
+ height:100%;
+ width:100%;
+}
+#mainBottom {
+ height:100%;
+ width:100%;
+}
+#sidebar {
+ background:blue none repeat scroll 0 0;
+ float:right;
+ height:100%;
+ width:20%;
+}
+#mainTopLeft {
+ width:40%;
+ height:100%;
+ background:yellow;
+ float:left;
+}
+
+#mainTopMiddle {
+ width:20%;
+ height:100%;
+ background:red;
+ float:left;
+}
+
+#mainTopRight {
+ width:40%;
+ height:100%;
+ background:green;
+ float:left;
+}
+
+
+
+#mainBottomLeft {
+ float:left;
+ width:33.3%;
+ height:100%;
+ background:yellow;
+}
+
+
+#mainBottomMiddle {
+ float:left;
+ width:33.3%;
+ height:100%;
+ background:red;
+}
+
+
+#mainBottomRight {
+ float:left;
+ width:33.3%;
+ height:100%;
+ background:green;
+} \ No newline at end of file
diff --git a/examples/adding_up_to_10/js/mytest.js b/examples/adding_up_to_10/js/mytest.js
new file mode 100644
index 0000000..fa3ed20
--- /dev/null
+++ b/examples/adding_up_to_10/js/mytest.js
@@ -0,0 +1,35 @@
+window.addEventListener('load', function() {
+ var mainTopCanvas = document.getElementById('mainTopCanvas');
+ var mainBottomCanvas = document.getElementById('mainBottomCanvas');
+ var asideCanvas = document.getElementById('asideCanvas');
+
+ var tcCtx = mainTopCanvas.getContext('2d');
+ var bcCtx = mainBottomCanvas.getContext('2d');
+ var acCtx = asideCanvas.getContext('2d');
+ var startY = 0;
+
+ var logo = new Image();
+
+/* logo.src = 'assets/generic/images/logo_w_name.png';
+ logo.onload = function () {};
+
+ tcCtx.drawImage(logo, 0, 0, 0, 0);
+ tcCtx.drawImage(logo, 30, 60, 258, 80);
+
+
+ var timerFn = function () {
+ if (startY !== 0) {
+ tcCtx.clearRect(0, startY - 10,300,10);
+ }
+ tcCtx.fillRect(0, startY,300,10);
+ startY = startY + 10;
+
+ };
+
+ var id = setInterval (timerFn, 1000);
+*/
+
+
+}, false);
+
+
diff --git a/examples/adding_up_to_10/js/mytest.js.~1~ b/examples/adding_up_to_10/js/mytest.js.~1~
new file mode 100644
index 0000000..a2ba1e7
--- /dev/null
+++ b/examples/adding_up_to_10/js/mytest.js.~1~
@@ -0,0 +1,35 @@
+window.addEventListener('load', function() {
+ var mainTopCanvas = document.getElementById('mainTopCanvas');
+ var mainBottomCanvas = document.getElementById('mainBottomCanvas');
+ var asideCanvas = document.getElementById('asideCanvas');
+
+ var tcCtx = mainTopCanvas.getContext('2d');
+ var bcCtx = mainBottomCanvas.getContext('2d');
+ var acCtx = asideCanvas.getContext('2d');
+ var startY = 0;
+
+ var logo = new Image();
+
+ /* logo.src = 'assets/generic/images/logo_w_name.png';
+ logo.onload = function () {};
+
+ tcCtx.drawImage(logo, 0, 0, 0, 0);
+ tcCtx.drawImage(logo, 30, 60, 258, 80);
+
+
+ var timerFn = function () {
+ if (startY !== 0) {
+ tcCtx.clearRect(0, startY - 10,300,10);
+ }
+ tcCtx.fillRect(0, startY,300,10);
+ startY = startY + 10;
+
+ };
+
+ var id = setInterval (timerFn, 1000);
+*/
+
+
+}, false);
+
+
diff --git a/examples/adding_up_to_10/mytest.html b/examples/adding_up_to_10/mytest.html
index 06dd6a2..2645605 100755
--- a/examples/adding_up_to_10/mytest.html
+++ b/examples/adding_up_to_10/mytest.html
@@ -1,119 +1,63 @@
-<html lang="en">
+<!DOCTYPE html>
+<html lang="en">
<head>
<title>Karma - Adding Up to 10</title>
- <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal"/>
-
-
-
- <style type="text/css">
- #main {
- float: left;
- width: 68%;
- height: 90%;
- border: 2px solid black;
- }
-
- #mainTop {
- width: 100%;
- height: 90%;
- border: 2px solid black;
- }
-
- #mainTopCanvas {
- width: 100%;
- height: 100%;
- border: 2px solid black;
- }
-
- #mainBottom {
- width: 100%;
- height: 40%;
- border: 2px solid black;
- }
-
- #aside {
- float: right;
- width: 28%;
- height: 90%;
- border: 2px solid blue;
- }
-
- #asideCanvas {
- width: 40%;
- height: 30%;
- border: 2px solid black;
- }
-
- #mainBottomCanvas {
- width: 60%;
- height: 30%;
- border: 2px solid black;
- }
-
-
- </style>
-
-<script type="text/javascript">
- window.addEventListener('load', function() {
- var mainTopCanvas = document.getElementById('mainTopCanvas');
- var mainBottomCanvas = document.getElementById('mainBottomCanvas');
- var asideCanvas = document.getElementById('asideCanvas');
-
- var tcCtx = mainTopCanvas.getContext('2d');
- var bcCtx = mainBottomCanvas.getContext('2d');
- var acCtx = asideCanvas.getContext('2d');
- var startY = 0;
-
- var logo = new Image();
-
- logo.src = 'assets/generic/images/logo_w_name.png';
-
- tcCtx.drawImage(logo, 0,0, 65, 20);
-
-
-
-/* var timerFn = function () {
- if (startY !== 0) {
- tcCtx.clearRect(0, startY - 10,300,10);
- }
- tcCtx.fillRect(0, startY,300,10);
- startY = startY + 10;
-
- };
-
- var id = setInterval (timerFn, 1000);
-*/
-
-
- }, false);
-
-
-</script>
-
+ <meta name="keywords" content="karma,javascript,html5,sugar,sugarlabs,gsoc,ole,nepal" />
+ <link type="text/css" rel="stylesheet" href="css/mytest.css" />
+ <!-- <script type="text/javascript" src="js/mytest.js"></script> -->
</head>
<body>
-<div>
+<div id="mainmain">
<div id="main">
<div id="mainTop">
-<canvas id="mainTopCanvas"></canvas>
+<!--<canvas id="mainTopCanvas"></canvas>-->
+<div id="mainTopLeft"></div>
+<div id="mainTopMiddle"></div>
+<div id="mainTopRight"></div>
+blah
+
</div>
+
<div id="mainBottom">
-<canvas id="mainBottomCanvas"></canvas>
+<!-- <canvas id="mainBottomCanvas"></canvas> -->
+<div id="mainBottomLeft"></div>
+<div id="mainBottomMiddle"></div>
+<div id="mainBottomRight"></div>
</div>
</div>
-<div id="aside">
-<canvas id="asideCanvas"></canvas>
+<div id="sidebar">
+<!-- <canvas id="sidebarCanvas"></canvas> -->
+<div id="sidebarTop"></div>
+<div id="sidebarMiddle"></div>
+<div id="sidebarBottom"></div>
+
+
</div>
</div>
+
+<!--
+<img id="topLeftBox" src="assets/generic/images/yellowBox.png" alt="">
+<img id="topRightBox" src="assets/generic/images/yellowBox.png" alt="">
+<img id="bottomLeftBox" src="assets/generic/images/yellowBox.png" alt="">
+<img id="bottomMiddleBox" src="assets/generic/images/yellowBox.png" alt="">
+<img id="bottomRightBox" src="assets/generic/images/yellowBox.png" alt="">
+<img id="plussign" src="assets/generic/images/plussign.png" alt="">
+<img id="timer" src="assets/generic/images/scorebox.png" alt="">
+<img id="scorebox" src="assets/generic/images/scorebox.png" alt="">
+<img id="chimp" src="assets/generic/images/normalChimp_200x209.png" alt="">
+<img id="sidebar" src="assets/generic/images/sidebar.png" alt="">
+<img id="chimp" src="assets/generic/images/normalChimp_200x209.png" alt="">
+-->
+
</body>
</html> \ No newline at end of file
diff --git a/js/jquery.karma-0.1.js b/js/jquery.karma-0.1.js
deleted file mode 100755
index 6ab1ba6..0000000
--- a/js/jquery.karma-0.1.js
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- http://wiki.sugarlabs.org/go/Karma
- Karma Framework v1.0alpha
- under MIT license: http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt
-*/
-//
-//var console = { log:""};
-(function($){
-
-
-
-
-
- $.karma = function( options ){
- //START of private stuff
- /**
- * localizeLanguage
- * get the language acording to the browser language
- */
- var localizeLanguage = function () {
- //console.log += navigator.language +"\n";
- var lang = navigator.language || navigator.browserLanguage; //mozilla / ie
- lang = lang.replace(/_/, '-').toLowerCase();
- if (lang.length > 3 ) {
- var country = lang.substring(3, 5);
- lang = lang.substring(0, 2);
- if ( country.match(/[^a-zA-Z]/) === null ) {
- country = country.toUpperCase();
- return { "lang": lang + "-" + country, "langCode": lang, "countryCode": country };
- }
- }
- return { "lang": lang };
- }
- /**
- *i18n
- *i18n wrapper, creates a new Gettext object and returns a shortcout 'i18n' to translate that elements
- */
- var i18n = function ( options ) {
- var gt = new Gettext( options );
- if ( typeof ( gt ) === 'undefined' )
- throw new Error("Unable to initialize Gettext object");
- var i18n = function (str1, str2, str3, str4 ) {
- var n, context, singular, plural;
- if (typeof(str4) != 'undefined') {
- // number, context, singular, plural
- return gt.npgettext(str2, str3, str4, str1);
- } else if (typeof(str3) != 'undefined') {
- // number, singular, plural
- return gt.ngettext(str2, str3, str1);
- } else if (typeof(str2) != 'undefined') {
- // context, msgid
- return gt.pgettext(str1, str2);
- } else if (typeof(str1) != 'undefined') {
- // msgid
- return gt.gettext(str1);
- } else {
- // nothing passed in; return blank string.
- // XXX: we could error here, but that may cause more harm than good.
- return '';
- }
- }
- return i18n;
- };
- /**
- *
- */
- var localiseContent = function ( lang ) {
- var toFix = ["images", "sounds", "videos"];
- for (var i = 0; i < toFix.length; i++) {
- path[ toFix[ i ] ].localized = path[ toFix[ i ] ].localized.replace('\$', lang );
- }
- }
- /**
- *
- */
- var tryLocalize = function ( ) {
- var loaded = undefined;
- var tryNext = true;
- //try to load the po or json language file if it exists.
- //the lang order is acording to options.language.alternatives
- //the type (po or json or ...) is defined in supportedLangFiles
- $.each( options.language.alternatives, function ( c, lang ) {
- for (var i=0; i < supportedLangFiles.length && tryNext === true; i++) {
- $.ajax({
- url: path.po + lang + "." + supportedLangFiles[i].ext,
- cache: true,
- dataType: "text",
- async: false, //important: touch it at your own risk
- success: function( data, textStatus ){
-
- loaded = lang + "." + supportedLangFiles[i].ext;
- //i18n
- //we pass the data so we avoid re-loading the file
- //creates the shorcout
- options.i18n.root[ options.i18n.shortcout ] = i18n(
- {
- domain : lang,
- file : { type: supportedLangFiles[i].type , uri: this.url, data: data }
- }
- );
- localiseContent( lang );
- tryNext = false;
- },
- error: function ( XHR, textStatus, errorThrown ) {
- //the file doesn't exist or it wasn't possible to load it
- tryNext = true;
- }
- });
- return tryNext;
- }
- });
- return loaded;
- }
-
-
-
-
- //
- //relative path to the po, images, sounds, etc. from the html
- //localized is recalculated in tryLocalize
- //defined here: http://wiki.sugarlabs.org/go/Karma/Bundle_layout
- var path = {
- po: "po/",
- images: {
- localized: "assets/$/images/",
- generic: "assets/generic/images/"
- },
- sounds: {
- localized: "assets/$/sounds/",
- generic: "assets/generic/sounds/"
- },
- videos: {
- localized: "assets/$/videos/",
- generic: "assets/generic/videos/"
- }
- };
- var supportedLangFiles = [
- { ext: "po", type: 'application/x-po' },
- { ext: "json", type: 'application/json'}
- ];
- //END of private stuff
-
- // default options
- var defaultOptions ={
- container: undefined,
- language: {
- lang: undefined,
- alternatives: ['en-US', 'en'],
- countryCode: undefined,
- langCode: undefined,
- loaded: undefined //private
- },
- i18n: {
- root: self,
- shortcout: "_"
- },
- canvasName: undefined,
- width: 100,
- height: 100,
- fps: 24
- };
- var k = {
- container: undefined,
- w: 100,
- h: 100,
- canvas: undefined,
- ctx: undefined,
- id: undefined,
- fillStyle: undefined,
-
- };
- var output={
- language: { },
- library: { images: [], sounds: [], videos:[], shapes:[] }
- };
- //1 argument: string. assume that it's the container
- if ( typeof options === "string" ) {
- options = { container: options };
- } else {
- if ( typeof options.language === "string" ) {
- //if language is string, assume that it's the language.lang
- defaultOptions.language.lang = options.language ;
- }else {
-
- $.extend( defaultOptions.language, localizeLanguage() );
- }
- }
-
- $.extend( options, defaultOptions );
-
- //add the localized language to the language.alternatives
- if ( typeof options.language.countryCode !== "undefined" ) {
- options.language.alternatives.unshift( options.language.langCode, options.language.countryCode );
- }
- if ( typeof options.language.lang !== "undefined" ) {
- options.language.alternatives.unshift( options.language.lang );
- }
- //try to load the localized lang file (po or json or ...)
-
- output.language.loaded = tryLocalize( );
-
- //*************************************
- /**
- *
- *
- */
- var KObject = function() {
-
- this.localized = true;
-
- }
- var Shape = function() {
- this.x = 0;
- this.y = 0;
-
- this.shapes = [];
- this.images = [];
- }
- Shape.prototype = new KObject();
-
- Shape.prototype.draw = function () {
-
- }
-
-
- var KImage =function ( options ) { //todo: add path, w, h, sync
- /*if (typeof options === "undefined" || typeof options.file === "undefined" ) {
- throw new Error("Unable to initialize KImage");
- }*/
- //private functions
- var that = this;
- this.parse= function( file ){
- //alert("okj");
- return this.localized === true ?
- path.images.localized + file :
- path.images.generic + file;
- }
- //
- if (typeof options.localized === "boolean" ) {
- this.localized = options.localized;
- }
-
- this.type = "image"
- this._status = undefined;
- this.src = this.parse(options.file);
- this.x = 0;
- this.y = 0;
- //callbacks
- this.callbacks = options.callbacks || [] ;
- //
- //img stuff
- this.img = new Image();
- this.img.src = this.src;
- this._status = "loading";
- this.img.onload = function () {
- this._status = "loaded";
- that.onload();
- }
- this.img.onerror = function () {
- this._status = "error";
- that.onerror();
- }
-
- }
- KImage.prototype = new KObject();
-
- KImage.prototype.onload = function ( cb ) { if (typeof cb === "function" ) cb(); }
- KImage.prototype.onerror = function ( ) { }
- KImage.prototype.display = function ( x, y ) {
-
-
- if ( this.img.complete === true ) {
-
- k.ctx.drawImage( this.img, x || this.x, y || this.y );
- }
- }
- KImage.prototype.status = function ( ) {
- return this._status;
- }
- //
- var KSound = function( options ) {
-
- if (typeof options === "string" ) {
- //return new Audio( options );
- return new Audio( options );
- }else {
- return new Audio();
- }
- }
- KSound.prototype = new KObject();
-
- var TimeLine = function ( ) {
- this.fps = defaultOptions.fps || fps;
- this.paused = false;
- this.frame = 0;
-
- //
- this.shapes = [];
- this.sounds = [];
- this.timelines = [];
- //
- this.keys = [ ]; //frame,
- }
- TimeLine.prototype.pause = function() {
- this.paused = true;
- }
- TimeLine.prototype.play = function() {
- if ( this.paused === false ) {
- this.draw( frame );
- }
- }
- TimeLine.prototype.draw = function() {
- for( var i=0; i<this.shapes.length; i++){
- this.shapes[ i ].draw();
- }
- }
- //
- if ( typeof options.container === "string" ) {
- k.container = $(options.container);
- }else if ( typeof options.container === "object" ){ //<-- uncomplete
- k.container = options.container;
- }
-
- //
-
- //environment
- output.init = function ( items ) {
-
- var counter = 0;
- var checkAllLoaded = function() {
- counter++;
- if (counter == items["images"].length ) {//+ items["sounds"].length
- /*for (var k in output.library.images) {
- output.library.images[k].display();
- }*/
- k.masterCb();
-
- }
- }
- $.each ( items["images"], function ( i, k ) {
- var img =output.image( { file: k.file, localized: k.localized } )
- output.library.images[ k.id ] = img;
- img.onload( checkAllLoaded );
- });
-
- }
-
- output.draw = function ( cb ) {
- k.masterCb = cb;
- }
- output.background = function ( options ) {
- if(typeof options === "string") {
- if (options[0]==="#") {
- k.container.css({'background-color' : options });
- }
- }
- }
- output.size = function ( w, h ) {
- k.canvas = document.createElement("canvas");
- k.canvas.width = k.w = w;
- k.canvas.height = k.h = h;
- k.ctx = k.canvas.getContext("2d");
- k.container[0].appendChild( k.canvas );
- //k.container.append('<canvas id="'+k.id+'" width="'+ k.w +'" height="'+ k.h +'">');
- }
- //shape
- output.shape = function ( options ){
- return new KShape( options );
- }
- //image
- output.image = function ( options ){
- return new KImage( options );
- }
- //sound
- output.sound = function ( options ){
- return new KSound( options );
- }
- //math
- output.math = {
- rand : function ( lower, upper ){
- return Math.round ( Math.random() * (upper - lower) + lower );
- }
- }
- //geometry
- output.geometry = {
- distance2 : function ( a, b ) {
- return (b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y);
- },
- distance : function ( a, b ) {
- //return Math.sqrt( this.distance2( a, b ) );
- }
- }
- //graphics
-
- output.rect = function ( x, y, w, h ){
- if ( w == 0 || h == 0) return;
- k.ctx.beginPath();
- k.ctx.fillStyle = "#006699";//k.fillStyle;
- k.ctx.rect( x, y, w, h );
- k.ctx.fill();
- k.ctx.closePath();
- }
- output.window = function() {
-
-
- }
- output.ctx = function () {return k.ctx;}
-
- //
- return output;
-
- };
- /*$.fn.extend({
- karma : function( id ) {
- //if (id===undefined) return ;
- return this.each(function() {
- if ( this.getContext !== undefined) {
- ctx = this;
- }
- });
- }
- });*/
-
- /*$.each(karmaNameSpace, function(i) {
- //$.fn[i] = this;
- $.karma[i] = this;
- });*/
-
-
-})(jQuery);
diff --git a/js/jquery.karma-0.2.js b/js/jquery.karma-0.2.js
deleted file mode 100755
index 6f0e15c..0000000
--- a/js/jquery.karma-0.2.js
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
-* Karma Framework
-* http://wiki.sugarlabs.org/go/Karma
-* under MIT license: http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt
-*
-*
-*/
-(function ($) {
-var Karma = function( options ) {
- var that = this;
- this.version = "0.2 alpha";
- //
- //relative path to the po, images, sounds, etc. from the html
- //defined here: http://wiki.sugarlabs.org/go/Karma/Bundle_layout
- //localized is recalculated in tryLocalize ($ = language.lang)
- this.paths = {
- po: "po/",
- images: {
- localized: "assets/$/images/",
- generic: "assets/generic/images/"
- },
- sounds: {
- localized: "assets/$/sounds/",
- generic: "assets/generic/sounds/"
- },
- videos: {
- localized: "assets/$/videos/",
- generic: "assets/generic/videos/"
- }
- };
- this.supportedLangFiles = [
- { ext: "po", type: 'application/x-po' },
- { ext: "json", type: 'application/json'}
- ];
- //
- //PRIVATE STUFF start
- /**
- * localizeLanguage
- * get the language acording to the browser language
- */
- var localizeLanguage = function () {
- //console.log += navigator.language +"\n";
- var lang = navigator.language || navigator.browserLanguage; //mozilla / ie
- lang = lang.replace(/_/, '-').toLowerCase();
- if (lang.length > 3 ) {
- var country = lang.substring(3, 5);
- lang = lang.substring(0, 2);
- if ( country.match(/[^a-zA-Z]/) === null ) {
- country = country.toUpperCase();
- return { "lang": lang + "-" + country, "langCode": lang, "countryCode": country };
- }
- }
- return { "lang": lang };
- }
- /**
- *i18nWrapper
- *creates a new Gettext object and returns a shortcut function to translate strings
- */
- var i18nWrapper = function ( options ) {
- var gt = new Gettext( options );
- if ( typeof ( gt ) === 'undefined' )
- throw new Error("Unable to initialize Gettext object");
- return (function (str1, str2, str3, str4 ) {
- var n, context, singular, plural;
- if (typeof(str4) != 'undefined') {
- // number, context, singular, plural
- return gt.npgettext(str2, str3, str4, str1);
- } else if (typeof(str3) != 'undefined') {
- // number, singular, plural
- return gt.ngettext(str2, str3, str1);
- } else if (typeof(str2) != 'undefined') {
- // context, msgid
- return gt.pgettext(str1, str2);
- } else if (typeof(str1) != 'undefined') {
- // msgid
- return gt.gettext(str1);
- } else {
- // nothing passed in; return blank string.
- // XXX: we could error here, but that may cause more harm than good.
- return '';
- }
- });
- };
- /**
- *
- */
- var loadAlternatives = function ( ) {
- var loaded = undefined;
- var tryNext = true;
- //try to load the po or json language file if it exists.
- //the lang order is acording to options.language.alternatives
- //the type (po or json or ...) is defined in supportedLangFiles
- $.each( that.language.alternatives, function ( c, lang ) {
- for (var i=0; i < that.supportedLangFiles.length && tryNext === true; i++) {
- $.ajax({
- url: that.paths.po + lang + "." + that.supportedLangFiles[i].ext,
- cache: true,
- dataType: "text",
- async: false, //important: touch it at your own risk
- success: function( data, textStatus ){
-
- loaded = lang + "." + that.supportedLangFiles[i].ext;
- //i18n
- //we pass the data so we avoid re-loading the file
- //creates the shorcout
- that.i18n.root[ that.i18n.shortcut ] = i18nWrapper(
- {
- domain : lang,
- file : {
- type: that.supportedLangFiles[i].type ,
- uri: this.url, data: data
- }
- }
- );
- //localiseContent( lang );
- tryNext = false;
- },
- error: function ( XHR, textStatus, errorThrown ) {
- //the file doesn't exist or it wasn't possible to load it
- tryNext = true;
- }
- });
- return tryNext;
- }
- });
- return loaded;
- }
- //PRIVATE STUFF end
- // default options
- var defaultOptions ={
- container: "#karma-main",
- language: {
- lang: undefined,
- alternatives: ['en-US', 'en'],
- countryCode: undefined,
- langCode: undefined,
- },
- i18n: {
- root: self, // self is global
- shortcut: "_"
- },
- canvas: undefined,
- width: 100,
- height: 100,
- fps: 24
- };
- //
- this.output={
- language: { },
- library: { images: [], sounds: [], videos:[], shapes:[] }
- };
-
- //initializes the defaultOptions argument
- //1 argument: string. assume it's the container
- if ( typeof options === "string" ) {
- options = { container: options };
- options.language = localizeLanguage() ;
- } else if (typeof options === "object" ){
- if ( typeof options.lang === "string" ) {
- //if language is string, assume it's the language.lang
- options.language = { lang: options.lang };
- }
- }
- $.extend( true, defaultOptions, options );
- //
- //copy defaultOptions to this, we use this.xyz instead this.defaultOptions.xyz
- for (var i in defaultOptions ) {
- this[ i ] = defaultOptions[i];
- }
-
- //initializes i18n
- //add the localized language to the language.alternatives
- if ( typeof this.language.countryCode !== "undefined" ) {
- this.language.alternatives.unshift( this.language.langCode, this.language.countryCode );
- }
- if ( typeof this.language.lang !== "undefined" ) {
- this.language.alternatives.unshift( this.language.lang );
- }
- //try to load the localized lang file (po or json or ...)
- this.output.language.loaded = loadAlternatives( );
- //
-
- //initializes the container
- if ( typeof this.container === "string" ) {
- this.container = $( this.container );
- }
-
-}
-
-//*********KObject START ********
-var KObject = function () {
- this.localized = true; //default true: all the content will be localized
-}
-//*********KObject END ********
-
-//*********KMedia START ********
-var KMedia = function () {
- this._type = undefined;
- this._status = undefined;
- this.src = undefined;
- this.media;
-}
-KMedia.prototype = new KObject();
-//*********KMedia END ********
-
-
-//*********KImage START ********
-var KImage = function ( options ) {
- var defaultOptions = {
- x: 0,
- y: 0,
- width: 0,
- height: 0
- };
- $.extend( defaultOptions, options );
- //copy defaultOptions to this
- for (var i in defaultOptions ) {
- this[ i ] = defaultOptions[ i ];
- }
-}
-KImage.prototype = new KMedia();
-KImage.prototype.display = function ( x, y ) {
-
-}
-//*********KImage END ********
-
-var KClip = function ( options ) {
- var defaultOptions = {
- shapes: []
- };
- $.extend( defaultOptions, options );
- //copy defaultOptions to this
- for (var i in defaultOptions ) {
- this[ i ] = defaultOptions[ i ];
- }
-
-}
-//*********Karma ************************************
-
-/**
-*
-**/
-Karma.prototype.size = function ( w, h) {
- this.canvas = document.createElement("canvas");
- this.canvas.width = this.width = ( this.width || w );
- this.canvas.height = this.height = ( this.height || h );
- if ( this.canvas.getContext ) {
- this.ctx = this.canvas.getContext("2d");
- this.container[ 0 ].appendChild( this.canvas );
- }else {
- throw new Error ("Your browser doesn't support canvas, try Firefox or Google chrome");
- }
- return this;
-}
-
-Karma.prototype.geometry = {
- radians : function( angle ){
- return ( angle / 180 ) * Math.PI;
- }
-}
-//
-//karma wrapper, we avoid using "new"
-karma = function (options) {
- return new Karma( options )
-}
-})(jQuery); \ No newline at end of file