rsence-pre 2.3.0.18 → 2.3.0.19

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.0.18.pre
1
+ 2.3.0.19.pre
@@ -21,9 +21,9 @@ HChatPanel = HScrollView.extend
21
21
  @userIcons = []
22
22
  _users = @value.users
23
23
  _themeUser = {}
24
- _defaultBubble = HVM.clone( HSpeechBubble.prototype.controlDefaults.prototype.colors )
24
+ _defaultBubble = @cloneObject( HSpeechBubble.prototype.controlDefaults.prototype.colors )
25
25
  for _userId, _user of _users
26
- _colors = HVM.clone( _defaultBubble )
26
+ _colors = @cloneObject( _defaultBubble )
27
27
  if _user.color_bg?
28
28
  _gradientStart = _user.color_bg
29
29
  _gradientStep1 = @hexColorSubtract( _gradientStart, '#111' )
@@ -170,6 +170,7 @@ COMM.Queue = HApplication.extend({
170
170
  **/
171
171
  unshiftEval: function(_evalStr,_arguments){
172
172
  var _function;
173
+ console.log('WARNING: COMM.unshiftEval is deprecated; Update your code!');
173
174
  eval('_function = function(){'+_evalStr+'}');
174
175
  this.unshift(_function);
175
176
  },
@@ -179,7 +180,25 @@ COMM.Queue = HApplication.extend({
179
180
  **/
180
181
  pushEval: function(_evalStr){
181
182
  var _function;
183
+ console.log('WARNING: COMM.pushEval is deprecated; Update your code!');
182
184
  eval('_function = function(){'+_evalStr+'}');
183
185
  this.push(_function);
186
+ },
187
+
188
+ _scripts: {},
189
+
190
+ addScript: function(_scriptId,_scriptSrc){
191
+ var
192
+ _script = document.createElement('script');
193
+ this._scripts[_scriptId] = _script;
194
+ _script.textContent = _scriptSrc;
195
+ document.head.appendChild(_script);
196
+ },
197
+
198
+ delScript: function(_scriptId){
199
+ var
200
+ _script = this._scripts[_scriptId];
201
+ document.head.removeChild(_script);
202
+ delete this._scripts[_scriptId];
184
203
  }
185
204
  }).nu();
@@ -33,11 +33,11 @@ COMM.Transporter = HApplication.extend({
33
33
  },
34
34
 
35
35
  _detectNativeJSONSupport: function(){
36
- if(window['JSON']){
36
+ if(window.JSON){
37
37
  var
38
38
  _JSON = window.JSON,
39
39
  _fun = 'function';
40
- if((typeof _JSON['parse'] === _fun) && (typeof _JSON['stringify'] === _fun)){
40
+ if((typeof _JSON.parse === _fun) && (typeof _JSON.stringify === _fun)){
41
41
  this.parseResponseArray = this._nativeParseResponseArray;
42
42
  }
43
43
  }
@@ -70,7 +70,7 @@ COMM.Transporter = HApplication.extend({
70
70
  // },
71
71
 
72
72
  parseResponseArray: function( _responseText ){
73
- return HVM.decode( _responseText );
73
+ return this.decodeObject( _responseText );
74
74
  },
75
75
 
76
76
  _nativeParseResponseArray: function( _responseText ){
@@ -95,16 +95,16 @@ COMM.Transporter = HApplication.extend({
95
95
  _valueManager.create( _valueId, _valueData );
96
96
  }
97
97
  }
98
- if(_values['set'] instanceof Array){
99
- for(i=0;i<_values['set'].length;i++){
100
- _valueId = _values['set'][i][0];
101
- _valueData = _values['set'][i][1];
98
+ if(_values.set instanceof Array){
99
+ for(i=0;i<_values.set.length;i++){
100
+ _valueId = _values.set[i][0];
101
+ _valueData = _values.set[i][1];
102
102
  _valueManager.s( _valueId, _valueData );
103
103
  }
104
104
  }
105
- if(_values['del'] instanceof Array){
106
- for(i=0;i<_values['del'].length;i++){
107
- _valueId = _values['del'][i];
105
+ if(_values.del instanceof Array){
106
+ for(i=0;i<_values.del.length;i++){
107
+ _valueId = _values.del[i];
108
108
  _valueManager.del( _valueId );
109
109
  }
110
110
  }
@@ -145,20 +145,29 @@ COMM.Transporter = HApplication.extend({
145
145
  _session.newKey(_sesKey);
146
146
  }
147
147
  _this.setValues( _values );
148
+ _outputScript = '(function(_queue){';
148
149
  for(;i<_responseArrayLen;i++){
149
- try {
150
- _queue.pushEval( _responseArray[i] );
151
- }
152
- catch(e) {
153
- _this._clientEvalError = _queue.clientException( e, _responseArray[i] );
154
- }
150
+ _outputScript += '_queue.push( (function(){';
151
+ _outputScript += _responseArray[i];
152
+ _outputScript += '}) );';
153
+ // try {
154
+ // console.log(_responseArray[i]);
155
+ // _queue.pushEval( _responseArray[i] );
156
+ // }
157
+ // catch(e) {
158
+ // console.log('clientEvalError:',_queue.clientException( e, _responseArray[i] ));
159
+ // _this._clientEvalError = _queue.clientException( e, _responseArray[i] );
160
+ // }
155
161
  }
162
+ _outputScript += '_queue.push( (function(){COMM.Transporter.flushBusy();}) );';
163
+ _outputScript += '_queue.push( (function(){_queue.delScript("'+_sesKey+'");}) );';
164
+ _outputScript += '_queue.flush();';
165
+ _outputScript += '})(COMM.Queue);';
166
+ _queue.addScript(_sesKey,_outputScript);
156
167
  if(_this._serverInterruptView && _sesKey !== '' ){
157
168
  _this._serverInterruptView.die();
158
169
  _this._serverInterruptView = false;
159
170
  }
160
- _queue.push( function(){COMM.Transporter.flushBusy();} );
161
- _queue.flush();
162
171
  },
163
172
 
164
173
  /** Sets the +busy+ flag to false and resynchronizes immediately,
@@ -314,7 +323,7 @@ COMM.Transporter = HApplication.extend({
314
323
  // console.log('sync.');
315
324
  this.busy = true;
316
325
  var _now = new Date().getTime();
317
- if(window['sesWatcher'] && window.sesWatcher['sesTimeoutValue']){
326
+ if(window.sesWatcher && window.sesWatcher.sesTimeoutValue){
318
327
  // Sets the value of the session watcher to the current time. It could cause an unnecessary re-sync poll immediately after this sync otherwise.
319
328
  sesWatcher.sesTimeoutValue.set( _now );
320
329
  }
@@ -324,7 +333,7 @@ COMM.Transporter = HApplication.extend({
324
333
  // _boundary = _now.toString(36)+(Math.random()*10000).toString(36)+(Math.random()*10000).toString(36),
325
334
  // _separator = '--'+_boundary,
326
335
  // _errorMessage = _this.getClientEvalError(),
327
- _body = HVM.sync();
336
+ _body = COMM.Values.sync();
328
337
  // _body = _separator+
329
338
  // '\r\nContent-Disposition: form-data; name="ses_key"\r\nContent-Type: text/plain\r\n'+
330
339
  // '\r\n'+COMM.Session.ses_key+'\r\n'+_separator;
@@ -138,292 +138,6 @@ COMM.Values = UtilMethods.extend({
138
138
  return this.typeChr( _obj );
139
139
  },
140
140
 
141
- // Returns an encoded version of the array _arr as a string
142
- _encodeArr: function(_arr){
143
- var _str = '[',
144
- _output = [],
145
- _len = _arr.length,
146
- _this = this,
147
- _item,
148
- i = 0;
149
- for(;i<_len;i++){
150
- _item = _this.encode(_arr[i]);
151
- _output.push( _item );
152
- }
153
- _str += _output.join(',')+']';
154
- return _str;
155
- },
156
-
157
- // Returns a decoded array with decoded content of array _arr
158
- _decodeArr: function(_arr){
159
- var _output = [],
160
- _len = _arr.length,
161
- _this = this,
162
- _item,
163
- i = 0;
164
- for(;i<_len;i++){
165
- _item = _this.decode(_arr[i]);
166
- _output.push( _item );
167
- }
168
- return _output;
169
- },
170
-
171
- // Returns an encoded version of the Hash (Object) _hash as a string
172
- _encodeHash: function(_hash){
173
- var _str = '{',
174
- _output = [],
175
- _this = this,
176
- _key,
177
- _value;
178
- for(_key in _hash){
179
- _value = _hash[_key];
180
- _output.push( _this.encode( _key ) + ':' + _this.encode( _value ) );
181
- }
182
- _str += _output.join(',')+'}';
183
- return _str;
184
- },
185
-
186
- // Returns a decoded version of the Hash (Object) _hash
187
- _decodeHash: function(_hash){
188
- var _output = {},
189
- _this = this,
190
- _key,
191
- _value;
192
- for(_key in _hash){
193
- _value = _hash[_key];
194
- _output[_this.decode(_key)] = _this.decode(_value);
195
- }
196
- return _output;
197
- },
198
-
199
- // Regular expression match/replace pairs for string escaping.
200
- _stringSubstitutions: [
201
- [(/\\/g), '\\\\'],
202
- //[(/\b/g), '\\b'],
203
- [(/\t/g), '\\t'],
204
- [(/\n/g), '\\n'],
205
- [(/\f/g), '\\f'],
206
- [(/\r/g), '\\r'],
207
- [(/"/g), '\\"']
208
- ],
209
-
210
- // Quotes a string (escapes quotation marks and places quotes around)
211
- _quoteString: function(_str){
212
- var _this = this,
213
- _substitutions = _this._stringSubstitutions,
214
- i = 0, _len = _substitutions.length,
215
- _line, _from, _to, _output = '';
216
- for(;i<_len;i++){
217
- _line = _substitutions[i];
218
- _from = _line[0];
219
- _to = _line[1];
220
- _str = _str.replace( _from, _to );
221
- }
222
- return '"' + _str + '"';
223
- },
224
-
225
- // Encodes the native character set to url-encoded unicode.
226
- // Likely causes issues with non-ascii strings, shouldn't be called (for now).
227
- _encodeString: function(_str){
228
- console.log( 'WARNING: encodeString called with string: ',_str );
229
- var _outStr;
230
- try {
231
- _outStr = unescape( encodeURIComponent( _str ) );
232
- }
233
- catch(e) {
234
- _outStr = _str;
235
- }
236
- return _outStr;
237
- },
238
-
239
- // Decodes the url-encoded unicode to the native character set
240
- _decodeString: function(_str){
241
- var _outStr;
242
- try {
243
- _outStr = decodeURIComponent( escape( _str ) );
244
- }
245
- catch(e) {
246
- _outStr = _str;
247
- }
248
- return _outStr;
249
- },
250
-
251
- /** = Description
252
- * Encodes an object to a ascii string (special characters url-encoded).
253
- *
254
- * = Parameters
255
- * +_obj+:: Any object
256
- *
257
- * = Returns
258
- * A +String+ representation of the +_obj+
259
- *
260
- **/
261
- encode: function(_obj){
262
- var _str, _type, _this = this;
263
- if(_obj === null){
264
- return 'null';
265
- }
266
- else if(_obj !== undefined){
267
- _type = _this.type(_obj);
268
- if(!_type){
269
- return 'null';
270
- }
271
- switch(_type){
272
- case 'b': _str = String(_obj); break;
273
- case 'n': _str = String(_obj); break;
274
- case 's': _str = _this._quoteString(_obj); break;
275
- // Might need further investigation, but _encodeString is disabled for now:
276
- // case 's': _str = _this._quoteString(_this._encodeString(_obj)); break;
277
- case 'd': _str = '"@'+String(_obj.getTime()/1000)+'"'; break;
278
- case 'a': _str = _this._encodeArr(_obj); break;
279
- case 'h': _str = _this._encodeHash(_obj); break;
280
- default: _str = 'null'; break;
281
- }
282
- }
283
- else {
284
- return 'null';
285
- }
286
- return _str;
287
- },
288
-
289
- _nativeEncode: function(_obj){
290
- try{
291
- return JSON.stringify( _obj );
292
- }
293
- catch(e){
294
- console.log('invalid json:',_obj);
295
- return "{}";
296
- }
297
- },
298
-
299
-
300
- /** = Description
301
- * Decodes a JSON object. Decodes url-encoded strings contained.
302
- *
303
- * = Parameters
304
- * +_ibj+:: A raw object with special characters url-encoded.
305
- *
306
- * = Returns
307
- * An version of the object with the contained strings decoded to unicode.
308
- *
309
- **/
310
- decode: function(_ibj){
311
- var _obj, _type, _this = this;
312
- if(_ibj !== null && _ibj !== undefined){
313
- _type = _this.type(_ibj);
314
- if(!_type){
315
- return null;
316
- }
317
- switch(_type){
318
- case 'b': _obj = _ibj; break;
319
- case 'n': _obj = _ibj; break;
320
- case 's': _obj = _this._decodeString(_ibj); break;
321
- case 'd': _obj = _ibj; break;
322
- case 'a': _obj = _this._decodeArr(_ibj); break;
323
- case 'h': _obj = _this._decodeHash(_ibj); break;
324
- default: _obj = null; break;
325
- }
326
- }
327
- else {
328
- return null;
329
- }
330
- return _obj;
331
- },
332
-
333
- _nativeDecode: function(_ibj){
334
- var _obj, _type, _this = this;
335
- if(_ibj !== null && _ibj !== undefined){
336
- _type = _this.type(_ibj);
337
- if(!_type){
338
- return null;
339
- }
340
- switch(_type){
341
- case 'b': _obj = _ibj; break;
342
- case 'n': _obj = _ibj; break;
343
- case 's': _obj = _this._decodeString(_ibj); break;
344
- case 'd': _obj = _ibj; break;
345
- case 'a': _obj = JSON.parse(_ibj); break;
346
- case 'h': _obj = JSON.parse(_ibj); break;
347
- default: _obj = null; break;
348
- }
349
- }
350
- else {
351
- return null;
352
- }
353
- return _obj;
354
- },
355
-
356
- /** = Description
357
- * Makes a deep copy of the object.
358
- *
359
- * When you use assignment of a js object, only primitive object types
360
- * (strings, numbers and booleans) are copied. This method makes a deep
361
- * (nested) clone of the input object.
362
- *
363
- * = Parameters
364
- * +_obj+:: Any object.
365
- *
366
- * = Returns
367
- * A copy of the object.
368
- *
369
- **/
370
- clone: function( _obj, _shallow ){
371
- if(_obj === null){
372
- return null;
373
- }
374
- else if (_obj === undefined){
375
- console.log('Undefined object, supplementing with null.');
376
- return null;
377
- }
378
- var _item,
379
- _cloned;
380
- if( _obj instanceof Array ){
381
- _cloned = [];
382
- for( _item = 0; _item < _obj.length; _item ++ ){
383
- if(_shallow){
384
- _cloned[ _item ] = _obj[ _item ];
385
- }
386
- else {
387
- _cloned[ _item ] = this.clone( _obj[ _item ] );
388
- }
389
- }
390
- return _cloned;
391
- }
392
- else if( _obj instanceof Object ){
393
- _cloned = {};
394
- for( _item in _obj ){
395
- if(_shallow){
396
- _cloned[ _item ] = _obj[ _item ];
397
- }
398
- else {
399
- _cloned[ _item ] = this.clone( _obj[ _item ] );
400
- }
401
- }
402
- return _cloned;
403
- }
404
- else {
405
- return _obj;
406
- }
407
- },
408
-
409
- _nativeClone: function( _obj ){
410
- if(_obj === null){
411
- return null;
412
- }
413
- else if (_obj === undefined){
414
- console.log('Undefined object, supplementing with null.');
415
- return null;
416
- }
417
- if( (_obj instanceof Array) || (_obj instanceof Object) ){
418
- // conversion via encoding/decoding via JSON string.
419
- return JSON.parse( JSON.stringify( _obj ) );
420
- }
421
- else {
422
- // no conversion needed (numbers, strings, booleans etc..)
423
- return _obj;
424
- }
425
- },
426
-
427
141
  /** = Description
428
142
  * Returns an URI-encoded string representation of all the changed values to
429
143
  * synchronize to the server.
@@ -459,41 +173,19 @@ COMM.Values = UtilMethods.extend({
459
173
  return _this.encode(_response);
460
174
  },
461
175
 
462
- // Old sync implementation:
463
- // sync: function(){
464
- // if(this.tosync.length===0){
465
- // return false;
466
- // }
467
- // var
468
- // _syncValues = {},
469
- // _this = this,
470
- // _values = _this.values,
471
- // _tosync = _this.tosync,
472
- // _len = _tosync.length,
473
- // i = 0, _id, _value;
474
- // for(;i<_len;i++){
475
- // _id = _tosync.shift();
476
- // _value = _values[_id].value;
477
- // _syncValues[_id] = _value;
478
- // }
479
- // return encodeURIComponent(_this.encode(_syncValues));
480
- // },
481
-
482
- _detectNativeJSONSupport: function(){
483
- if(window['JSON']){
484
- var
485
- _JSON = window.JSON,
486
- _fun = 'function';
487
- if((typeof _JSON['parse'] === _fun) && (typeof _JSON['stringify'] === _fun)){
488
- // console.log('Has native JSON support. Re-routing encode, decode and clone methods of COMM.Values...');
489
- this.clone = this._nativeClone;
490
- this.encode = this._nativeEncode;
491
- // this.decode = this._nativeDecode;
492
- }
493
- }
176
+ encode: function(_obj){
177
+ return this.encodeObject(_obj);
178
+ },
179
+
180
+ decode: function(_obj){
181
+ return this.decodeObject(_obj);
182
+ },
183
+
184
+ clone: function(_obj){
185
+ return this.cloneObject(_obj);
494
186
  }
187
+
495
188
  });
496
- COMM.Values._detectNativeJSONSupport();
497
189
 
498
190
  // Backwards compatibility assignment for code that still
499
191
  // uses HVM as a reference of the Value Manager:
@@ -22,6 +22,7 @@ HAlertSheet = HSheet.extend({
22
22
  * and an alert button.
23
23
  **/
24
24
  drawSubviews: function(){
25
+ this.base();
25
26
  this.icon = HImageView.nu(
26
27
  [ 16, 16, 48, 48 ],
27
28
  this, {
@@ -25,7 +25,7 @@ HOnOffButton = HCheckbox.extend
25
25
  @offLabel = _label
26
26
  @refreshLabelOff()
27
27
  refreshLabelOff: ->
28
- @setMarkupOfPart( 'offlabel', @labelOff )
28
+ @setMarkupOfPart( 'offlabel', @labelOff ) if @drawn
29
29
  refreshValue: ->
30
30
  if @value != false
31
31
  @setStyleOfPart( 'offvalue', 'display', 'none' )
@@ -685,10 +685,12 @@ ELEM = HClass.extend
685
685
  _elem = document.createElement( _tagName )
686
686
  _id = @_add( _elem )
687
687
  @_initCache( _id )
688
- unless _options == undefined
688
+ if _options?
689
689
  if _options.attrs
690
690
  for _attr in _options.attrs
691
691
  @setAttr( _id, _attr[0], _attr[1], true )
692
+ if _options.styles
693
+ @setStyles( _id, _options.styles )
692
694
  @_elements[_targetId].appendChild(_elem)
693
695
  _id
694
696