Skip to content
This repository
Browse code

Removed old javascript files, updated build scripts for python

  • Loading branch information...
commit b9c363f8df90fc98599428f4d46341097818216c 1 parent 285a5ae
Chris Cotter authored August 31, 2012

Showing 31 changed files with 18 additions and 5,449 deletions. Show diff stats Hide diff stats

  1. 4  js/build/build.sh
  2. 51  js/lib/coweb/ConfigInitializer.js
  3. 538  js/lib/coweb/collab/UnmanagedHubCollab.js
  4. 77  js/lib/coweb/ext/CowebWrapper.js
  5. 158  js/lib/coweb/ext/SimpleLoader.js
  6. 191  js/lib/coweb/ext/attendance.js
  7. 76  js/lib/coweb/jsoe/ContextDifference.js
  8. 226  js/lib/coweb/jsoe/ContextVector.js
  9. 198  js/lib/coweb/jsoe/ContextVectorTable.js
  10. 83  js/lib/coweb/jsoe/DeleteOperation.js
  11. 179  js/lib/coweb/jsoe/HistoryBuffer.js
  12. 82  js/lib/coweb/jsoe/InsertOperation.js
  13. 296  js/lib/coweb/jsoe/Operation.js
  14. 438  js/lib/coweb/jsoe/OperationEngine.js
  15. 91  js/lib/coweb/jsoe/UpdateOperation.js
  16. 61  js/lib/coweb/jsoe/factory.js
  17. 759  js/lib/coweb/listener/UnmanagedHubListener.js
  18. 94  js/lib/coweb/main.js
  19. 492  js/lib/coweb/session/BayeuxSession.js
  20. 59  js/lib/coweb/session/bayeux/CowebExtension.js
  21. 568  js/lib/coweb/session/bayeux/ListenerBridge.js
  22. 364  js/lib/coweb/session/bayeux/SessionBridge.js
  23. 53  js/lib/coweb/session/bayeux/cometd.js
  24. 41  js/lib/coweb/topics.js
  25. 158  js/lib/coweb/util/Promise.js
  26. 24  js/lib/coweb/util/lang.js
  27. 84  js/lib/coweb/util/xhr.js
  28. 12  js/setup_js.sh
  29. 4  js/setup_python_js.sh
  30. 2  servers/python/coweb/__init__.py
  31. 4  servers/python/setup.py
4  js/build/build.sh
... ...
@@ -1,4 +1,8 @@
1 1
 #!/bin/bash
  2
+
  3
+echo "Don't run this outdated script - see coweb/js/setup_python_js.sh"
  4
+exit
  5
+
2 6
 rm -r ../release/coweb-latest
3 7
 ./requirejs-*/build/build.sh coweb.build.js
4 8
 VERSION=`grep VERSION ../lib/coweb/main.js`
51  js/lib/coweb/ConfigInitializer.js
... ...
@@ -1,51 +0,0 @@
1  
-//
2  
-// config initializer.
3  
-//
4  
-// Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
5  
-// Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
6  
-//
7  
-/*jslint white:false, bitwise:true, eqeqeq:true, immed:true, nomen:false, 
8  
-  onevar:false, plusplus:false, undef:true, browser:true, devel:true, 
9  
-  forin:false, sub:false*/
10  
-/*global define cowebConfig*/
11  
-
12  
-if(typeof cowebConfig === 'undefined') {
13  
-    cowebConfig = {};
14  
-}
15  
-
16  
-// mix defaults into coweb config where left undefined
17  
-cowebConfig = {
18  
-    sessionImpl : cowebConfig.sessionImpl || undefined,
19  
-    listenerImpl : cowebConfig.listenerImpl || undefined,
20  
-    collabImpl : cowebConfig.collabImpl || undefined,
21  
-    debug : cowebConfig.debug || false,
22  
-    baseUrl : cowebConfig.baseUrl || '',
23  
-    adminUrl : cowebConfig.adminUrl || '/admin',
24  
-    loginUrl : cowebConfig.loginUrl || '/login',
25  
-    logoutUrl : cowebConfig.logoutUrl || '/logout',
26  
-    cacheState : cowebConfig.cacheState || false
27  
-};
28  
-
29  
-(function () {
30  
-	// build up a list of dependencies dynamically
31  
-	var deps = [];
32  
-	// add require to be used to load configured implementation modules
33  
-	deps.push("require");
34  
-	if (cowebConfig.sessionImpl) {
35  
-		deps.push(cowebConfig.sessionImpl);
36  
-	}
37  
-	if (cowebConfig.listenerImpl) {
38  
-		deps.push(cowebConfig.listenerImpl);
39  
-	}
40  
-	if (cowebConfig.collabImpl) {
41  
-		deps.push(cowebConfig.collabImpl);
42  
-	}
43  
-	
44  
-	define(deps, function(req) {
45  
-		var sessionImpl = cowebConfig.sessionImpl ? req(cowebConfig.sessionImpl) : undefined;
46  
-		var listenerImpl = cowebConfig.listenerImpl ? req(cowebConfig.listenerImpl) : undefined;
47  
-		var collabImpl = cowebConfig.collabImpl ? req(cowebConfig.collabImpl) : undefined;
48  
-		return {sessionImpl: sessionImpl, listenerImpl: listenerImpl, collabImpl: collabImpl};
49  
-	});
50  
-
51  
-}());
538  js/lib/coweb/collab/UnmanagedHubCollab.js
... ...
@@ -1,538 +0,0 @@
1  
-//
2  
-// Unmanaged OpenAjax Hub implementation of the CollabInterface.
3  
-//
4  
-// Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
5  
-// Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
6  
-//
7  
-/*jslint white:false, bitwise:true, eqeqeq:true, immed:true, nomen:false, 
8  
-  onevar:false, plusplus:false, undef:true, browser:true, devel:true, 
9  
-  forin:false, sub:false*/
10  
-/*global define*/
11  
-define([
12  
-    'coweb/topics',
13  
-    'coweb/util/Promise',
14  
-    'org/OpenAjax'
15  
-], function(topics, Promise, OpenAjax) {
16  
-    /**
17  
-     * @constructor
18  
-     */
19  
-    var UnmanagedHubCollab = function() {
20  
-        this._mutex = false;
21  
-        this._serviceId = 0;
22  
-        this._tokens = {};
23  
-        this.id = undefined;
24  
-    };
25  
-    // save the finger joints
26  
-    var proto = UnmanagedHubCollab.prototype;
27  
-
28  
-    /**
29  
-     * Stores the collaboration instance ID.
30  
-     *
31  
-     * @param {String} params.id Unique identifier of this wrapper / widget
32  
-     */    
33  
-    proto.init = function(params) {
34  
-        if(!params || params.id === undefined) {
35  
-            throw new Error('collab id required');
36  
-        }
37  
-        this.id = params.id;
38  
-    };
39  
-    
40  
-    /**
41  
-     * Subscribes to session ready notifications coweb.site.ready.
42  
-     *
43  
-     * @param {Object|Function} context Context in which to invoke the callback
44  
-     * or the callback itself
45  
-     * @param {Function|String} callback Function to invoke if context
46  
-     * specified
47  
-     * @returns {Promise} Always notifies success because this impl is
48  
-     * synchronous
49  
-     */
50  
-    proto.subscribeReady = function(context, callback) {
51  
-        if(callback === undefined) {
52  
-            callback = context;
53  
-            context = this;
54  
-        }
55  
-        if(typeof callback !== 'function') {
56  
-            callback = context[callback];
57  
-            if(typeof callback !== 'function') {
58  
-                throw new Error('callback must be a function');
59  
-            }
60  
-        }
61  
-        var topic = topics.READY;
62  
-        var tok = OpenAjax.hub.subscribe(topic, function(topic, params) {
63  
-            callback.call(context, params);
64  
-        }, this);
65  
-        this._tokens[tok] = null;
66  
-        var def = new Promise();
67  
-        def._cowebToken = tok;
68  
-        def.resolve();
69  
-        return def;
70  
-    };
71  
-
72  
-    /**
73  
-     * Subscribes to session end notifications coweb.site.end.
74  
-     *
75  
-     * @param {Object|Function} context Context in which to invoke the callback
76  
-     * or the callback itself
77  
-     * @param {Function|String} callback Function to invoke if context
78  
-     * specified
79  
-     * @returns {Promise} Always notifies success because this impl is
80  
-     * synchronous
81  
-     */
82  
-    proto.subscribeEnd = function(context, callback) {
83  
-        if(callback === undefined) {
84  
-            callback = context;
85  
-            context = this;
86  
-        }
87  
-        if(typeof callback !== 'function') {
88  
-            callback = context[callback];
89  
-            if(typeof callback !== 'function') {
90  
-                throw new Error('callback must be a function');
91  
-            }
92  
-        }
93  
-        var topic = topics.END;
94  
-        var tok = OpenAjax.hub.subscribe(topic, function(topic, params) {
95  
-            callback.call(context, params);
96  
-        }, this);
97  
-        this._tokens[tok] = null;
98  
-        var def = new Promise();
99  
-        def._cowebToken = tok;
100  
-        def.resolve();
101  
-        return def;
102  
-    };
103  
-
104  
-    /**
105  
-     * Subscribes to site joining notifications coweb.site.join.
106  
-     *
107  
-     * @param {Object|Function} context Context in which to invoke the callback
108  
-     * or the callback itself
109  
-     * @param {Function|String} callback Function to invoke if context
110  
-     * specified
111  
-     * @returns {Promise} Always notifies success because this impl is
112  
-     * synchronous
113  
-     */
114  
-    proto.subscribeSiteJoin = function(context, callback) {
115  
-        if(callback === undefined) {
116  
-            callback = context;
117  
-            context = this;
118  
-        }
119  
-        if(typeof callback !== 'function') {
120  
-            callback = context[callback];
121  
-            if(typeof callback !== 'function') {
122  
-                throw new Error('callback must be a function');
123  
-            }
124  
-        }
125  
-        var topic = topics.SITE_JOIN;
126  
-        var tok = OpenAjax.hub.subscribe(topic, function(topic, params) {
127  
-            callback.call(context, params);
128  
-        }, this);
129  
-        this._tokens[tok] = null;
130  
-        var def = new Promise();
131  
-        def._cowebToken = tok;
132  
-        def.resolve();
133  
-        return def;
134  
-    };
135  
-
136  
-    /**
137  
-     * Subscribes to site leaving notifications coweb.site.leave.
138  
-     *
139  
-     * @param {Object|Function} context Context in which to invoke the callback
140  
-     * or the callback itself
141  
-     * @param {Function|String} callback Function to invoke if context
142  
-     * specified
143  
-     * @returns {Promise} Always notifies success because this impl is
144  
-     * synchronous
145  
-     */
146  
-    proto.subscribeSiteLeave = function(context, callback) {
147  
-        if(callback === undefined) {
148  
-            callback = context;
149  
-            context = this;
150  
-        }
151  
-        if(typeof callback !== 'function') {
152  
-            callback = context[callback];
153  
-            if(typeof callback !== 'function') {
154  
-                throw new Error('callback must be a function');
155  
-            }
156  
-        }
157  
-        var topic = topics.SITE_LEAVE;
158  
-        var tok = OpenAjax.hub.subscribe(topic, function(topic, params) {
159  
-            callback.call(context, params);
160  
-        }, this);
161  
-        this._tokens[tok] = null;
162  
-        var def = new Promise();
163  
-        def._cowebToken = tok;
164  
-        def.resolve();
165  
-        return def;
166  
-    };
167  
-
168  
-    /**
169  
-     * Sends an incremental state change event coweb.sync.<topic>.<id>.
170  
-     * Throws an exception if this instance is not initialized.
171  
-     *
172  
-     * @param {String} name Cooperative event name
173  
-     * @param {Object} value JSON-encodable value for the change
174  
-     * @param {String|null} [type='update'] Type of change or null
175  
-     * @param {Number} [position=0] Integer position of the change
176  
-     */
177  
-    proto.sendSync = function(name, value, type, position) {
178  
-        if(this.id === undefined) {
179  
-            throw new Error('call init() first');
180  
-        }
181  
-        if(type === undefined) {
182  
-            type = 'update';
183  
-        }
184  
-        if(position === undefined) {
185  
-            position = 0;
186  
-        }
187  
-        var topic = topics.SYNC+name+'.'+this.id;
188  
-        var params = {value: value, type: type, position:position};
189  
-        this._mutex = true;
190  
-        OpenAjax.hub.publish(topic, params);
191  
-        this._mutex = false;
192  
-    };
193  
-    
194  
-    /**
195  
-     * Subscribes to remote incremental state changes 
196  
-     * coweb.sync.<topic>.<id>. Throws an exception if this instance is 
197  
-     * not initialized.
198  
-     *
199  
-     * @param {String} name Cooperative event name
200  
-     * @param {Object|Function} context Context in which to invoke the callback
201  
-     * or the callback itself
202  
-     * @param {Function|String} callback Function to invoke if context
203  
-     * specified
204  
-     * @returns {Promise} Always notifies success because this impl is
205  
-     * synchronous
206  
-     */
207  
-    proto.subscribeSync = function(name, context, callback) {
208  
-        if(this.id === undefined) {
209  
-            throw new Error('call init() first');
210  
-        }
211  
-        if(!name) {
212  
-            throw new Error('valid sync name required');
213  
-        }
214  
-        if(callback === undefined) {
215  
-            callback = context;
216  
-            context = this;
217  
-        }
218  
-        if(typeof callback !== 'function') {
219  
-            callback = context[callback];
220  
-            if(typeof callback !== 'function') {
221  
-                throw new Error('callback must be a function');
222  
-            }
223  
-        }
224  
-        var topic = topics.SYNC+name+'.'+this.id;
225  
-        var ls = topics.SYNC.length,
226  
-            le = this.id.length+1;
227  
-        var tok = OpenAjax.hub.subscribe(topic, function(tp, params) {
228  
-            if(!this._mutex) {
229  
-                // compute the actual event name, not what was registered
230  
-                // because it may have had wildcards
231  
-                params.name = tp.substring(ls, tp.length-le);
232  
-                params.topic = tp;
233  
-                callback.call(context, params);
234  
-            }
235  
-        }, this);
236  
-        this._tokens[tok] = null;
237  
-        var def = new Promise();
238  
-        def._cowebToken = tok;
239  
-        def.resolve();
240  
-        return def;
241  
-    };
242  
-    
243  
-    /**
244  
-     * Subscribes to full state requests coweb.state.get.
245  
-     *
246  
-     * @param {Object|Function} context Context in which to invoke the callback
247  
-     * or the callback itself
248  
-     * @param {Function|String} callback Function to invoke if context
249  
-     * specified
250  
-     * @returns {Promise} Always notifies success because this impl is
251  
-     * synchronous
252  
-     */
253  
-    proto.subscribeStateRequest = function(context, callback) {
254  
-        if(callback === undefined) {
255  
-            callback = context;
256  
-            context = this;
257  
-        }
258  
-        if(typeof callback !== 'function') {
259  
-            callback = context[callback];
260  
-            if(typeof callback !== 'function') {
261  
-                throw new Error('callback must be a function');
262  
-            }
263  
-        }
264  
-        var topic = topics.GET_STATE;
265  
-        var tok = OpenAjax.hub.subscribe(topic, function(topic, params) {
266  
-            callback.call(context, params);
267  
-        }, this);
268  
-        this._tokens[tok] = null;
269  
-        var def = new Promise();
270  
-        def._cowebToken = tok;
271  
-        def.resolve();
272  
-        return def;
273  
-    };
274  
-    
275  
-    /**
276  
-     * Sends a response to a full state request coweb.state.set.<id>.
277  
-     * Throws an exception if this instance is not initialized.
278  
-     *
279  
-     * @param {Object} state JSON-encodable state data for the response
280  
-     * @param {String} token Opaque token from the original state request
281  
-     */
282  
-    proto.sendStateResponse = function(state, token) {
283  
-        if(this.id === undefined) {
284  
-            throw new Error('call init() first');
285  
-        }
286  
-        var params = {state : state, recipient : token};
287  
-        this._mutex = true;
288  
-        try {
289  
-            OpenAjax.hub.publish(topics.SET_STATE+this.id, params);
290  
-        } finally {
291  
-            this._mutex = false;
292  
-        }
293  
-    };
294  
-
295  
-    /**
296  
-     * Subscribes to remote full state responses coweb.state.set.<id>.
297  
-     * Throws an exception if this instance is not initialized.
298  
-     *
299  
-     * @param {Object|Function} context Context in which to invoke the callback
300  
-     * or the callback itself
301  
-     * @param {Function|String} callback Function to invoke if context
302  
-     * specified
303  
-     * @returns {Promise} Always notifies success because this impl is
304  
-     * synchronous
305  
-     */    
306  
-    proto.subscribeStateResponse = function(context, callback) {
307  
-        if(this.id === undefined) {
308  
-            throw new Error('call init() first');
309  
-        }
310  
-        if(callback === undefined) {
311  
-            callback = context;
312  
-            context = this;
313  
-        }
314  
-        if(typeof callback !== 'function') {
315  
-            callback = context[callback];
316  
-            if(typeof callback !== 'function') {
317  
-                throw new Error('callback must be a function');
318  
-            }
319  
-        }
320  
-        var topic = topics.SET_STATE+this.id;
321  
-        var tok = OpenAjax.hub.subscribe(topic, function(t, params) {
322  
-            if(!this._mutex) {
323  
-                callback.call(context, params);
324  
-            }
325  
-        }, this);
326  
-        this._tokens[tok] = null;
327  
-        var def = new Promise();
328  
-        def._cowebToken = tok;
329  
-        def.resolve();
330  
-        return def;
331  
-    };
332  
-
333  
-    /**
334  
-     * Subscribes to a service with coweb.service.sub.<service>
335  
-     * and responses coweb.service.set.<service>.
336  
-     * Throws an exception if this instance is not initialized.
337  
-     *
338  
-     * @param {String} service Name of the service
339  
-     * @param {Object|Function} context Context in which to invoke the callback
340  
-     * or the callback itself
341  
-     * @param {Function|String} callback Function to invoke if context
342  
-     * specified
343  
-     * @returns {Promise} Always notifies success because this impl is
344  
-     * synchronous
345  
-     */
346  
-    proto.subscribeService = function(service, context, callback) {
347  
-        if(callback === undefined) {
348  
-            callback = context;
349  
-            context = this;
350  
-        }
351  
-        if(typeof callback !== 'function') {
352  
-            callback = context[callback];
353  
-            if(typeof callback !== 'function') {
354  
-                throw new Error('callback must be a function');
355  
-            }
356  
-        }
357  
-        // build the service response topic
358  
-        var setTopic = topics.SET_SERVICE+service;
359  
-
360  
-        // register internal callback for service response
361  
-        var subData = {
362  
-            callback : callback, 
363  
-            context : context, 
364  
-            type : 'subscribe'
365  
-        };
366  
-        var hubToken = OpenAjax.hub.subscribe(setTopic, 
367  
-            '_cowebServiceResponse', this, subData);
368  
-
369  
-        // add metadata and data to the subscription request
370  
-        var msg = {topic : setTopic, service : service};
371  
-        // send subscription request
372  
-        var subTopic = topics.SUB_SERVICE+service;
373  
-        OpenAjax.hub.publish(subTopic, msg);
374  
-
375  
-        // save all info needed to unregister
376  
-        var cowebToken = {topic : setTopic, service : service, 
377  
-            hubToken : hubToken};
378  
-        this._tokens[hubToken] = cowebToken;
379  
-        
380  
-        var def = new Promise();
381  
-        def.resolve();
382  
-        def._cowebToken = cowebToken;
383  
-        return def;
384  
-    };
385  
-    
386  
-    /**
387  
-     * Requests a single service value with coweb.service.get.<service>
388  
-     * and response coweb.service.set.<service>_<request id>.<id>.
389  
-     * Throws an exception if this instance is not initialized.
390  
-     *
391  
-     * @param {String} service Name of the service
392  
-     * @param {Object} params JSON-encodable parameters to pass to the service
393  
-     * @param {Object|Function} context Context in which to invoke the callback
394  
-     * or the callback itself
395  
-     * @param {Function|String} callback Function to invoke if context
396  
-     * specified
397  
-     * @returns {Promise} Always notifies success because this impl is
398  
-     * synchronous
399  
-     */    
400  
-    proto.postService = function(service, params, context, callback) {
401  
-        if(this.id === undefined) {
402  
-            throw new Error('call init() first');
403  
-        }
404  
-        if(callback === undefined) {
405  
-            callback = context;
406  
-            context = this;
407  
-        }
408  
-        if(typeof callback !== 'function') {
409  
-            callback = context[callback];
410  
-            if(typeof callback !== 'function') {
411  
-                throw new Error('callback must be a function');
412  
-            }
413  
-        }
414  
-        // subscribe to response event
415  
-        var setTopic = topics.SET_SERVICE+service+'_'+this._serviceId+'.'+this.id;
416  
-        // use our callback so we can automatically unregister 
417  
-        var subData = {
418  
-            context : context,
419  
-            callback : callback, 
420  
-            type : 'get'
421  
-        };
422  
-        var hubToken = OpenAjax.hub.subscribe(setTopic, 
423  
-            '_cowebServiceResponse', this, subData);
424  
-        // track token for unsubscribeAll
425  
-        this._tokens[hubToken] = null;            
426  
-        // add the unsubscribe token to the subscriber data so we have it
427  
-        // when the callback is invoked
428  
-        subData.hubToken = hubToken;
429  
-        // add metadata and data to message
430  
-        var msg = {topic : setTopic, params : params, service : service};
431  
-        // send get request to listener
432  
-        var get_topic = topics.GET_SERVICE+service;
433  
-        OpenAjax.hub.publish(get_topic, msg);
434  
-        // make next request unique
435  
-        this._serviceId++;
436  
-        var def = new Promise();
437  
-        def.resolve();
438  
-        def._cowebToken = hubToken;
439  
-        return def;
440  
-    };
441  
-
442  
-    /**
443  
-     * Handles a service response. Unsubscribes a postService request after 
444  
-     * delivering data to its callback.
445  
-     *
446  
-     * @private
447  
-     * @param {String} topic Response topic coweb.service.set.**
448  
-     * @param {Object} params Cooperative event
449  
-     * @returns {Promise} Always notifies success because this impl is
450  
-     * synchronous
451  
-     */
452  
-    proto._cowebServiceResponse = function(topic, params, subData) {
453  
-        var hubToken = subData.hubToken;
454  
-        // invoke the real callback
455  
-        var args = {value : params.value, error: params.error};
456  
-        try {
457  
-            subData.callback.call(subData.context, args);
458  
-        } finally {
459  
-            if(subData.type === 'get') {
460  
-                // unsubscribe from hub
461  
-                OpenAjax.hub.unsubscribe(subData.hubToken);
462  
-                // stop tracking token
463  
-                delete this._tokens[hubToken];
464  
-            }
465  
-        }
466  
-    };
467  
-
468  
-    /**
469  
-     * Unsubscribes any subscription created via this interface.
470  
-     *
471  
-     * @param {Promise} def Promise returned by the method that created the
472  
-     * subscription
473  
-     */
474  
-    proto.unsubscribe = function(def) {
475  
-        var token, i;
476  
-        if(!def) { 
477  
-            return;
478  
-        } else if(def._cowebToken && def._cowebToken.hubToken) {
479  
-            token = def._cowebToken;
480  
-            // don't allow reuse of token
481  
-            delete def._cowebToken;
482  
-            // unsubscribe from local event
483  
-            OpenAjax.hub.unsubscribe(token.hubToken);
484  
-            // remove from tracked tokens
485  
-            delete this._tokens[token.hubToken];
486  
-            // send unsubscribe request to listener
487  
-            var topic = topics.UNSUB_SERVICE+token.service;
488  
-            // include original topic
489  
-            OpenAjax.hub.publish(topic, token);
490  
-        } else if(def._cowebToken) {        
491  
-            token = def._cowebToken;
492  
-            // don't allow reuse of token
493  
-            delete def._cowebToken;
494  
-            // remove from tracked tokens
495  
-            delete this._tokens[token];
496  
-            OpenAjax.hub.unsubscribe(token);
497  
-        }
498  
-    };
499  
-    
500  
-    /**
501  
-     * Removes all subscriptions created via this interface.
502  
-     */
503  
-    proto.unsubscribeAll = function() {
504  
-        for(var hubToken in this._tokens) {
505  
-            if(this._tokens.hasOwnProperty(hubToken)) {
506  
-                var cowebToken = this._tokens[hubToken];
507  
-                // unsubscribe
508  
-                OpenAjax.hub.unsubscribe(hubToken);
509  
-                // stop tracking
510  
-                delete this._tokens[hubToken];
511  
-                if(cowebToken) {
512  
-                    // unregister from service too
513  
-                    var topic = topics.UNSUB_SERVICE+cowebToken.service;
514  
-                    // include original topic
515  
-                    OpenAjax.hub.publish(topic, cowebToken);
516  
-                }
517  
-            }
518  
-        }
519  
-    };
520  
-
521  
-    /**
522  
-     * Pause the syncing of incoming operations. The application of any incoming
523  
-     * operations will be delayed until `resumeSync` is called.
524  
-     */
525  
-    proto.pauseSync = function() {
526  
-        OpenAjax.hub.publish(topics.PAUSE_TOPIC, true);
527  
-    };
528  
-
529  
-    /**
530  
-     * Resume syncing the incoming operations. Any incoming operations that were
531  
-     * delayed while the pause was in effect will now be applied.
532  
-     */
533  
-    proto.resumeSync = function() {
534  
-        OpenAjax.hub.publish(topics.RESUME_TOPIC, true);
535  
-    };
536  
-
537  
-    return UnmanagedHubCollab;
538  
-});
77  js/lib/coweb/ext/CowebWrapper.js
... ...
@@ -1,77 +0,0 @@
1  
-//
2  
-// A wrapper to assist in making application widgets cooperative. Subclass it
3  
-// or treat it as a template.
4  
-//
5  
-// Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
6  
-// Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
7  
-//
8  
-/*jslint white:false, bitwise:true, eqeqeq:true, immed:true, nomen:false, 
9  
-  onevar:false, plusplus:false, undef:true, browser:true, devel:true, 
10  
-  forin:false, sub:false*/
11  
-/*global define*/
12  
-define([
13  
-    'coweb/main'
14  
-], function(coweb) {
15  
-    /**
16  
-     * @constructor
17  
-     * @param {String} [args.id=args.widget.id] Unique identifier of this 
18  
-     * wrapper / widget
19  
-     * @param {Object} args.widget Widget to wrap
20  
-     */
21  
-    var CowebWrapper = function(args) {
22  
-        // widget to wrap
23  
-        this.widget = args.widget;
24  
-        // id of this instance
25  
-        this.id = args.id || this.widget.id;
26  
-        // init collab interface
27  
-        this.collab = coweb.initCollab({id : this.id});
28  
-        // listen to ready and full state events
29  
-        this.collab.subscribeReady(this, 'onReady');
30  
-        this.collab.subscribeStateRequest(this, 'onStateRequest');
31  
-        this.collab.subscribeStateResponse(this, 'onStateRequest');
32  
-    };
33  
-    var proto = CowebWrapper.prototype;
34  
-
35  
-    /**
36  
-     * Unsubscribes all callbacks from the CollabInterface instance. Should be
37  
-     * invoked on widget destruction.
38  
-     */
39  
-    proto.uninitialize = function() {
40  
-        // invoke this to unsubscribe on widget destruction
41  
-        this.collab.unsubscribeAll();
42  
-    };
43  
-    
44  
-    /**
45  
-     * Invoked when the CollabInterface reports the application is ready for
46  
-     * cooperation in the session.
47  
-     *
48  
-     * @param {Object} info Session information
49  
-     */
50  
-    proto.onReady = function(info) {
51  
-        // override to handle session ready
52  
-    };
53  
-    
54  
-    /**
55  
-     * Invoked when the CollabInterface receives a request for this widget's
56  
-     * full state. The implementation should invoke 
57  
-     * this.collab.sendStateResponse.
58  
-     *
59  
-     * @param {String} token Token to include in the state response call
60  
-     */
61  
-    proto.onStateRequest = function(token) {
62  
-        // override and invoke this.collab.sendStateResponse
63  
-    };
64  
-    
65  
-    /**
66  
-     * Invoked when the CollabInterface receives a copy of the shared state
67  
-     * state of this widget. The implementation should set the widget to this
68  
-     * state.
69  
-     *
70  
-     * @param {any} state Widget state
71  
-     */    
72  
-    proto.onStateResponse = function(state) {
73  
-        // override to apply state
74  
-    };
75  
-    
76  
-    return CowebWrapper;
77  
-});
158  js/lib/coweb/ext/SimpleLoader.js
... ...
@@ -1,158 +0,0 @@
1  
-//
2  
-// Wraps the use of the session API in a class with declarative options and
3  
-// callback methods to override. An alternative to using the promise-based
4  
-// API for those that prefer classes and callbacks.
5  
-//
6  
-// Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
7  
-// Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
8  
-//
9  
-/*jslint white:false, bitwise:true, eqeqeq:true, immed:true, nomen:false, 
10  
-  onevar:false, plusplus:false, undef:true, browser:true, devel:true, 
11  
-  forin:false, sub:false*/
12  
-/*global define*/
13  
-define([
14  
-    'require',
15  
-    'coweb/main'
16  
-], function(require, coweb) {
17  
-    /**
18  
-     * @constructor
19  
-     * @param {String} id Unique id to assign to the CollabInterface instance
20  
-     * in this loader
21  
-     */
22  
-    var SimpleLoader = function(id) {
23  
-        // hard coded conference key to use
24  
-        this.cowebKey = undefined;
25  
-        // is the conference collaborative or standalone (bots only)?
26  
-        this.cowebCollab = true;
27  
-
28  
-        // initialize session API
29  
-        this.sess = coweb.initSession();
30  
-        // initialize collab API
31  
-        this.collab = coweb.initCollab({id : id});
32  
-        this.collab.subscribeReady(this, 'onCollabReady');
33  
-        // place to hang onto the session metadata that comes back from server
34  
-        this.prepareMetadata = null;
35  
-    };
36  
-    var proto = SimpleLoader.prototype;
37  
-
38  
-    /**
39  
-     * Starts the loader sequence.
40  
-     */
41  
-    proto.run = function() {
42  
-        // invoke initial extension point
43  
-        this.onRun();
44  
-        // attempt to prepare immediately
45  
-        this.prepare();
46  
-    };
47  
-
48  
-    /**
49  
-     * Override to perform work when the loader starts running.
50  
-     */
51  
-    proto.onRun = function() {
52  
-        // extension point
53  
-    };
54  
-
55  
-    /**
56  
-     * Override to handle successful session preparation.
57  
-     *
58  
-     * @param {Object} info Session information from SessionInterface.prepare
59  
-     */
60  
-    proto.onSessionPrepared = function(info) {
61  
-        // extension point
62  
-    };
63  
-
64  
-    /**
65  
-     * Override to handle successful session joining.
66  
-     *
67  
-     * @param {Object} info Session information from SessionInterface.join
68  
-     */
69  
-    proto.onSessionJoined = function(info) {
70  
-        // extension point
71  
-    };
72  
-
73  
-    /**
74  
-     * Override to handle successful application updating within the session.
75  
-     *
76  
-     * @param {Object} info Session information from SessionInterface.update
77  
-     */
78  
-    proto.onSessionUpdated = function(info) {
79  
-        // extension point 
80  
-    };
81  
-
82  
-    /**
83  
-     * Override to handle any failure while preparing, joining, or updating
84  
-     * in the session.
85  
-     *
86  
-     * @param {Error} err Error object
87  
-     */
88  
-    proto.onSessionFailed = function(err) {
89  
-        // extension point
90  
-    };
91  
-    
92  
-    /**
93  
-     * Override to handle the CollaborationInterface.subscribeReady callback.
94  
-     *
95  
-     * @param {Object} info Roster info from the callback
96  
-     */
97  
-    proto.onCollabReady = function(info) {
98  
-        // extension point
99  
-    };
100  
-
101  
-    /**
102  
-     * Initiates the prepare, join, and update sequence with empty callbacks
103  
-     * subscribed to receive notification in each phase.
104  
-     */
105  
-    proto.prepare = function() {
106  
-        var params = {collab : !!this.cowebCollab};
107  
-        if(this.cowebKey) {
108  
-            params.key = String(this.cowebKey);
109  
-        }
110  
-        // loader will do the join and update to ensure all callbacks
111  
-        // are invoked
112  
-        params.autoJoin = false;
113  
-        params.autoUpdate = false;
114  
-        
115  
-        // invoke prepare chain
116  
-        this.sess.prepare(params)
117  
-        .then('_onSessionPrepared', null, this)
118  
-        .then('_onSessionJoined', null, this)
119  
-        .then('_onSessionUpdated', 'onSessionFailed', this);
120  
-    };
121  
-
122  
-    /**
123  
-     * Invokes onSessionPrepared and then SessionInterface.join. 
124  
-     *
125  
-     * @private
126  
-     */
127  
-    proto._onSessionPrepared = function(info) {
128  
-        // store metadata for later app access
129  
-        this.prepareMetadata = info;
130  
-        // notify the extension point; let exceptions bubble
131  
-        this.onSessionPrepared(info);
132  
-        // do the join
133  
-        return this.sess.join();
134  
-    };
135  
-
136  
-    /**
137  
-     * Invokes onSessionJoined and then SessionInterface.update. 
138  
-     *
139  
-     * @private
140  
-     */
141  
-    proto._onSessionJoined = function(info) {
142  
-        // notify the extension point; let exceptions bubble
143  
-        this.onSessionJoined(info);
144  
-        // do the update
145  
-        return this.sess.update();
146  
-    };
147  
-    
148  
-    /**
149  
-     * Invokes onSessionUpdated.
150  
-     * 
151  
-     * @private
152  
-     */
153  
-    proto._onSessionUpdated = function(info) {
154  
-        this.onSessionUpdated(info);
155  
-    };
156  
-    
157  
-    return SimpleLoader;
158  
-});
191  js/lib/coweb/ext/attendance.js
... ...
@@ -1,191 +0,0 @@
1  
-//
2  
-// Tracks session attendance by roster changes.
3  
-//
4  
-// Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
5  
-// Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
6  
-//
7  
-/*jslint white:false, bitwise:true, eqeqeq:true, immed:true, nomen:false, 
8  
-  onevar:false, plusplus:false, undef:true, browser:true, devel:true, 
9  
-  forin:false, sub:false*/
10  
-/*global define*/
11  
-define([
12  
-    'coweb/main',
13  
-    'coweb/util/Promise'
14  
-], function(coweb, Promise) {
15  
-    var attendance = {
16  
-        // all attendees, read-only externally
17  
-        users : {},
18  
-        // total attendee count, read-only externally
19  
-        count : 0,
20  
-        // subscriptions
21  
-        _subs : {},
22  
-        // next subscription id
23  
-        _subId : 0,
24  
-        
25  
-        /**
26  
-         * Subscribe for attendance changes.
27  
-         * @private
28  
-         */
29  
-        _subscribe : function(context, callback) {
30  
-            if(callback === undefined) {
31  
-                callback = context;
32  
-                context = this;
33  
-            }
34  
-            if(typeof callback !== 'function') {
35  
-                callback = context[callback];
36  
-                if(typeof callback !== 'function') {
37  
-                    throw new Error('callback must be a function');
38  
-                }
39  
-            }
40  
-            var id = this._subId;
41  
-            this._subs[id] = {
42  
-                context : context,
43  
-                callback : callback
44  
-            };
45  
-            this._subId++;
46  
-            return id;
47  
-        },
48  
-
49  
-        /**
50  
-         * Notifies subscribed listeners of a change.
51  
-         * @private
52  
-         */
53  
-        _notify : function(type, users, count) {
54  
-            var subs = this._subs;
55  
-            for(var id in subs) {
56  
-                if(subs.hasOwnProperty(id)) {
57  
-                    var s = subs[id];
58  
-                    // bundle to stay api consistent
59  
-                    var args = {type : type, users : users, count : count};
60  
-                    try {
61  
-                        s.callback.call(s.context, args);
62  
-                    } catch(e) {
63  
-                        console.error(e);
64  
-                    }
65  
-                }
66  
-            }
67  
-        },
68  
-
69  
-        /**
70  
-         * Subscribes to roster change events.
71  
-         *
72  
-         * @param {Object|Function} Context in which to invoke the callback or
73  
-         * the callback itself
74  
-         * @param {Function|String} callback Function to invoke if context
75  
-         * specified
76  
-         * @return Promise which always notifies success because this impl is
77  
-         * synchronous
78  
-         */
79  
-        subscribeChange: function(context, callback) {
80  
-            var tok = this._subscribe(context, callback);
81  
-            var promise = new Promise();
82  
-            promise._cowebToken = tok;
83  
-            promise.resolve();
84  
-            return promise;
85  
-        },
86  
-
87  
-        /**
88  
-         * Unsubscribes any subscription created via this interface.
89  
-         *
90  
-         * @param {Promise} promise Promise returned from subscribe method
91  
-         */
92  
-        unsubscribe: function(promise) {
93  
-            var tok = promise._cowebToken;
94  
-            if(tok) {
95  
-                delete this._subs[tok];
96  
-            }
97  
-        },
98  
-        
99  
-        /**
100  
-         * Unsubscribes all listeners.
101  
-         */
102  
-         unsubscribeAll: function() {
103  
-            for(var id in this._subs) {
104  
-                if(this._subs.hasOwnProperty(id)) {
105  
-                    delete this._subs[id];
106  
-                }
107  
-            }
108  
-         },
109  
-
110  
-        /**
111  
-         * Called when the local application is ready in the session.
112  
-         * @private
113  
-         */
114  
-        _onLocalJoin: function(params) {
115  
-            var users = [];
116  
-            for(var site in params.roster) {
117  
-                if(params.roster.hasOwnProperty(site)) {
118  
-                    var username = params.roster[site];
119  
-                    users.push(this._addUser(site, username, false));
120  
-                }
121  
-            }
122  
-            // notify about all existing users all at once
123  
-            this._notify('join', users, this.count);
124  
-
125  
-            var user = this._addUser(params.site, params.username, true);
126  
-            if(user) {
127  
-                // notify about local user
128  
-                this._notify('join', [user], this.count);
129  
-            }
130  
-        },
131  
-
132  
-        /**
133  
-         * Called when a remote application is ready in the session.
134  
-         * @private
135  
-         */
136  
-        _onRemoteJoin: function(params) {
137  
-            var user = this._addUser(params.site, params.username, false);
138  
-            if(user) {
139  
-                this._notify('join', [user], this.count);
140  
-            }
141  
-        },
142  
-    
143  
-        /**
144  
-         * Called when a remote application leaves the session.
145  
-         * @private
146  
-         */
147  
-        _onRemoteLeave: function(params) {
148  
-            var user = this._removeUser(params.site);
149  
-            if(user) {
150  
-                this._notify('leave', [user], this.count);
151  
-            }
152  
-        },
153  
-
154  
-        /**
155  
-         * Add a new user to track.
156  
-         * @private
157  
-         */
158  
-        _addUser: function(site, username, local) {
159  
-            var user = this.users[site];
160  
-            // don't increment count or construct a user
161  
-            if(user) { return; }
162  
-            ++this.count;
163  
-            // build a user object
164  
-            user = {site : Number(site), username : username, local : local};
165  
-            // store it
166  
-            this.users[site] = user;
167  
-            return user;
168  
-        },
169  
-
170  
-        /**
171  
-         * Stop tracking a user.
172  
-         * @private
173  
-         */
174  
-        _removeUser: function(site) {
175  
-            // get the user
176  
-            var user = this.users[site];
177  
-            // decrement count if user exists
178  
-            if(user) { --this.count; }
179  
-            // remove the stored user
180  
-            delete this.users[site];
181  
-            return user;
182  
-        }
183  
-    };
184  
-
185  
-    // connect to collab events
186  
-    var collab = coweb.initCollab({id : 'coweb-ext-attendance'});
187  
-    collab.subscribeReady(attendance, '_onLocalJoin');
188  
-    collab.subscribeSiteJoin(attendance, '_onRemoteJoin');
189  
-    collab.subscribeSiteLeave(attendance, '_onRemoteLeave');
190  
-    return attendance;
191  
-});
76  js/lib/coweb/jsoe/ContextDifference.js
... ...
@@ -1,76 +0,0 @@
1  
-//
2  
-// Difference between two contexts in terms of operations.
3  
-//
4  
-// Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
5  
-// Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
6  
-//
7  
-/*jslint white:false, bitwise:true, eqeqeq:true, immed:true, nomen:false, 
8  
-  onevar:false, plusplus:false, undef:true, browser:true, devel:true, 
9  
-  forin:false, sub:false*/
10  
-/*global define*/
11  
-define([
12  
-    'coweb/jsoe/factory'
13  
-], function(factory) {
14  
-    /**
15  
-     * Stores the difference in operations between two contexts in terms of 
16  
-     * site IDs and sequence numbers.
17  
-     *
18  
-     * @constructor
19  
-     */
20  
-    var ContextDifference = function() {
21  
-        this.sites = [];
22  
-        this.seqs = [];
23  
-    };
24  
-    
25  
-
26  
-    /**
27  
-     * Adds a range of operations to the difference.
28  
-     *
29  
-     * @param {Number} site Integer site ID
30  
-     * @param {Number} start First integer operation sequence number, inclusive
31  
-     * @param {Number} end Last integer operation sequence number, exclusive
32  
-     */
33  
-    ContextDifference.prototype.addRange = function(site, start, end) {
34  
-        for(var i=start; i < end; i++) {
35  
-            this.addSiteSeq(site, i);
36  
-        }
37  
-    };
38  
-
39  
-    /**
40  
-     * Adds a single operation to the difference.
41  
-     *
42  
-     * @param {Number} site Integer site ID
43  
-     * @param {Number} seq Integer sequence number
44  
-     */
45  
-    ContextDifference.prototype.addSiteSeq = function(site, seq) {
46  
-        this.sites.push(site);
47  
-        this.seqs.push(seq);        
48  
-    };
49  
-
50  
-    /**
51  
-     * Gets the histor buffer keys for all the operations represented in this
52  
-     * context difference.
53  
-     *
54  
-     * @return {String[]} Array of keys for HistoryBuffer lookups
55  
-     */
56  
-    ContextDifference.prototype.getHistoryBufferKeys = function() {
57  
-        var arr = [];
58  
-        for(var i=0, l=this.seqs.length; i < l; i++) {
59  
-            var key = factory.createHistoryKey(this.sites[i], 
60  
-                this.seqs[i]);
61  
-            arr.push(key);
62  
-        }
63  
-        return arr;
64  
-    };
65  
-
66  
-    /**
67  
-     * Converts the contents of this context difference to a string.
68  
-     *
69  
-     * @return {String} All keys in the difference (for debug)
70  
-     */
71  
-    ContextDifference.prototype.toString = function() {
72  
-        return this.getHistoryBufferKeys().toString();
73  
-    };
74  
-    
75  
-    return ContextDifference;
76  
-});
226  js/lib/coweb/jsoe/ContextVector.js
... ...
@@ -1,226 +0,0 @@
1  
-//
2  
-// Context vector representation of application state. Currently, just a state
3  
-// vector without undo support.
4  
-//
5  
-// Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
6  
-// Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
7  
-//