diff -r 858e90c7cbaa -r 6c08d4d7219e front_idill/extern/fajran-tuiojs/src/tuio.js --- a/front_idill/extern/fajran-tuiojs/src/tuio.js Fri Apr 06 18:36:40 2012 +0200 +++ b/front_idill/extern/fajran-tuiojs/src/tuio.js Thu Apr 12 13:09:46 2012 +0200 @@ -1,3 +1,5 @@ + +var test = 0; (function() { var TUIO = function() { @@ -17,13 +19,17 @@ object_remove: function(data) { }, cursor_add: function(data) { }, cursor_update: function(data) { }, - cursor_remove: function(data) { } + cursor_remove: function(data) { }, + string_add: function(data) { }, + string_update: function(data) { }, + string_remove: function(data) { } } // Instance variables this.objects = []; this.cursors = []; + this.strings = []; this._data = {}; @@ -71,7 +77,10 @@ } }, - callback: function(type, sid, fid, x, y, z, angle) { + cursorCallback: function(type, sid, fid, x, y, z, angle) { + if(type >= 6) + return; + var data; if ((type != 0) && (type != 3)) { @@ -133,6 +142,61 @@ delete this._data[sid]; } }, + + stringCallback: function(type, sid, code) { + if(type < 6) + return; + + var data; + + if ((type != 6)) { + data = this._data[sid]; + } + else { + data = { + sid: sid, + code: code + } + this._data[sid] = data; + } + + //data.code = code; + + switch (type) { + case 6: + if(this.strings != null && this.strings.length <= 0) + { + this.strings.push(data); + this._invoke('string_add', data); + test++; + //alert(test); + } + break; + + case 7: + this._invoke('string_update', data); + break; + + case 8: + //var str = ""; + //for(var j = 0 ; j < this.strings.length ; j++) + //str += "(" + this.strings[i].sid + ")" + this.strings[i].code + " "; + //alert(str); + //this.strings.splice(this.strings.indexOf(data), 1); + this.strings.length = 0; + this._invoke('string_remove', data); + test--; + alert(test); + break; + + default: + break; + } + + if ((type == 8)) { + delete this._data[sid]; + } + }, // Convenient callbacks set @@ -141,7 +205,10 @@ object_remove: function(f) { this._default_listener.object_remove = f; }, cursor_add: function(f) { this._default_listener.cursor_add = f; }, cursor_update: function(f) { this._default_listener.cursor_update = f; }, - cursor_remove: function(f) { this._default_listener.cursor_remove = f; } + cursor_remove: function(f) { this._default_listener.cursor_remove = f; }, + string_add: function(f) { this._default_listener.string_add = f; }, + string_update: function(f) { this._default_listener.string_update = f; }, + string_remove: function(f) { this._default_listener.string_remove = f; } }; this.tuio = new TUIO();