You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2010/10/07 17:54:40 UTC
svn commit: r1005506 [39/45] - in /shindig/branches/2.0.x: ./
content/editor/ content/editor/CodeMirror-0.8/
content/editor/CodeMirror-0.8/css/ content/editor/CodeMirror-0.8/js/
content/samplecontainer/examples/media/ etc/ etc/checkstyle/ extras/src/ma...
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/jsevalcontext.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/jsevalcontext.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/jsevalcontext.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/jsevalcontext.js Thu Oct 7 15:54:09 2010
@@ -39,7 +39,7 @@ var VAR_loop = '$loop';
/**
* The name of the global variable which holds the value to be returned if
- * context evaluation results in an error.
+ * context evaluation results in an error.
* Use JsEvalContext.setGlobal(GLOB_default, value) to set this.
*/
var GLOB_default = '$default';
@@ -75,6 +75,7 @@ function JsEvalContext(opt_data, opt_par
* variables are inherited. Normally the context object of the parent
* context is the object whose property the parent object is. Null for the
* context of the root object.
+ * @private
*/
JsEvalContext.prototype.constructor_ = function(opt_data, opt_parent) {
var me = this;
@@ -108,7 +109,7 @@ JsEvalContext.prototype.constructor_ = f
/**
* The current context object is assigned to the special variable
* $this so it is possible to use it in expressions.
- * @type Object
+ * @type {Object}
*/
me.vars_[VAR_this] = opt_data;
@@ -129,7 +130,7 @@ JsEvalContext.prototype.constructor_ = f
* above, but for the expression context we replace null and
* undefined by the empty string.
*
- * @type {Object|null}
+ * @type {?Object}
*/
me.data_ = getDefaultObject(opt_data, STRING_empty);
@@ -145,7 +146,8 @@ JsEvalContext.prototype.constructor_ = f
/**
* A map of globally defined symbols. Every instance of JsExprContext
* inherits them in its vars_.
- * @type Object
+ * @type {Object}
+ * @private
*/
JsEvalContext.globals_ = {};
@@ -158,7 +160,7 @@ JsEvalContext.globals_ = {};
* global variables in general apply also here. (Hence the name
* "global", and not "global var".)
* @param {string} name
- * @param {Object|null} value
+ * @param {?Object} value
*/
JsEvalContext.setGlobal = function(name, value) {
JsEvalContext.globals_[name] = value;
@@ -166,8 +168,8 @@ JsEvalContext.setGlobal = function(name,
/**
- * Set the default value to be returned if context evaluation results in an
- * error. (This can occur if a non-existent value was requested).
+ * Set the default value to be returned if context evaluation results in an
+ * error. (This can occur if a non-existent value was requested).
*/
JsEvalContext.setGlobal(GLOB_default, null);
@@ -175,7 +177,8 @@ JsEvalContext.setGlobal(GLOB_default, nu
/**
* A cache to reuse JsEvalContext instances. (IE6 perf)
*
- * @type Array.<JsEvalContext>
+ * @type {Array.<JsEvalContext>}
+ * @private
*/
JsEvalContext.recycledInstances_ = [];
@@ -224,7 +227,7 @@ JsEvalContext.recycle = function(instanc
*
* @param {Element} template DOM node of the template.
*
- * @return {Object|null} The value of the expression from which
+ * @return {?Object} The value of the expression from which
* exprFunction was created in the current js expression context and
* the context of template.
*/
@@ -249,10 +252,10 @@ JsEvalContext.prototype.jsexec = functio
* @param {Object} data The new context object.
*
* @param {number} index Position of the new context when multiply
- * instantiated. (See implementation of jstSelect().)
- *
+ * instantiated. (See implementation of jstSelect().).
+ *
* @param {number} count The total number of contexts that were multiply
- * instantiated. (See implementation of jstSelect().)
+ * instantiated. (See implementation of jstSelect().).
*
* @return {JsEvalContext}
*/
@@ -290,7 +293,7 @@ JsEvalContext.prototype.setVariable = fu
*
* @param {string} name
*
- * @return {?Object} value
+ * @return {?Object} value.
*/
JsEvalContext.prototype.getVariable = function(name) {
return this.vars_[name];
@@ -301,10 +304,10 @@ JsEvalContext.prototype.getVariable = fu
* Evaluates a string expression within the scope of this context
* and returns the result.
*
- * @param {string} expr A javascript expression
- * @param {Element=} opt_template An optional node to serve as "this"
+ * @param {string} expr A javascript expression.
+ * @param {Element=} opt_template An optional node to serve as "this".
*
- * @return {?Object} value
+ * @return {?Object} value.
*/
JsEvalContext.prototype.evalExpression = function(expr, opt_template) {
var exprFunction = jsEvalToFunction(expr);
@@ -322,7 +325,8 @@ var STRING_with = 'with (a_) with (b_) r
/**
* Cache for jsEvalToFunction results.
- * @type Object
+ * @type {Object}
+ * @private
*/
JsEvalContext.evalToFunctionCache_ = {};
@@ -343,7 +347,7 @@ function jsEvalToFunction(expr) {
try {
// NOTE: The Function constructor is faster than eval().
JsEvalContext.evalToFunctionCache_[expr] =
- new Function(STRING_a, STRING_b, STRING_with + expr);
+ new Function(STRING_a, STRING_b, STRING_with + expr);
} catch (e) {
log('jsEvalToFunction (' + expr + ') EXCEPTION ' + e);
}
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/jstemplate.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/jstemplate.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/jstemplate.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/jstemplate.js Thu Oct 7 15:54:09 2010
@@ -113,7 +113,7 @@ function jstProcess(context, template, o
/**
* Caches the document of the template node, so we don't have to
* access it through ownerDocument.
- * @type Document
+ * @type {Document}
*/
processor.document_ = ownerDocument(template);
@@ -137,7 +137,8 @@ function JstProcessor() {
/**
* An array of logging messages. These are collected during processing
* and dumped to the console at the end.
- * @type Array.<string>
+ * @type {Array.<string>}
+ * @private
*/
this.logs_ = [];
}
@@ -150,14 +151,16 @@ function JstProcessor() {
* from the jstcache_. The id is stored in an attribute so it
* suvives cloneNode() and thus cloned template nodes can share the
* same cache entry.
- * @type number
+ * @type {number}
+ * @private
*/
JstProcessor.jstid_ = 0;
/**
* Map from jstid to processed js attributes.
- * @type Object
+ * @type {Object}
+ * @private
*/
JstProcessor.jstcache_ = {};
@@ -182,7 +185,8 @@ JstProcessor.jstcache_[0] = {};
* when a cached entry already exists for a given combination of attribute
* values. (For example when two different nodes in a template share the same
* JST attributes.)
- * @type Object
+ * @type {Object}
+ * @private
*/
JstProcessor.jstcacheattributes_ = {};
@@ -190,7 +194,8 @@ JstProcessor.jstcacheattributes_ = {};
/**
* Map for storing temporary attribute values in prepareNode_() so they don't
* have to be retrieved twice. (IE6 perf)
- * @type Object
+ * @type {Object}
+ * @private
*/
JstProcessor.attributeValues_ = {};
@@ -199,7 +204,8 @@ JstProcessor.attributeValues_ = {};
* A list for storing non-empty attributes found on a node in prepareNode_().
* The array is global since it can be reused - this way there is no need to
* construct a new array object for each invocation. (IE6 perf)
- * @type Array
+ * @type {Array}
+ * @private
*/
JstProcessor.attributeList_ = [];
@@ -208,6 +214,7 @@ JstProcessor.attributeList_ = [];
* Prepares the template: preprocesses all jstemplate attributes.
*
* @param {Element} template
+ * @private
*/
JstProcessor.prepareTemplate_ = function(template) {
if (!template[PROP_jstcache]) {
@@ -222,18 +229,18 @@ JstProcessor.prepareTemplate_ = function
* A list of attributes we use to specify jst processing instructions,
* and the functions used to parse their values.
*
- * @type Array.<Array>
+ * @type {Array.<Array>}
*/
var JST_ATTRIBUTES = [
- [ ATT_select, jsEvalToFunction ],
- [ ATT_display, jsEvalToFunction ],
- [ ATT_values, jsEvalToValues ],
- [ ATT_vars, jsEvalToValues ],
- [ ATT_eval, jsEvalToExpressions ],
- [ ATT_transclude, jsEvalToSelf ],
- [ ATT_content, jsEvalToFunction ],
- [ ATT_skip, jsEvalToFunction ],
- [ ATT_innerselect, jsEvalToFunction ]
+ [ATT_select, jsEvalToFunction],
+ [ATT_display, jsEvalToFunction],
+ [ATT_values, jsEvalToValues],
+ [ATT_vars, jsEvalToValues],
+ [ATT_eval, jsEvalToExpressions],
+ [ATT_transclude, jsEvalToSelf],
+ [ATT_content, jsEvalToFunction],
+ [ATT_skip, jsEvalToFunction],
+ [ATT_innerselect, jsEvalToFunction]
];
@@ -247,6 +254,7 @@ var JST_ATTRIBUTES = [
* @return {Object} The jstcache entry. The processed jst attributes
* are properties of this object. If the node has no jst attributes,
* returns an object with no properties (the jscache_[0] entry).
+ * @private
*/
JstProcessor.prepareNode_ = function(node) {
// If the node already has a cache property, return it.
@@ -277,7 +285,7 @@ JstProcessor.prepareNode_ = function(nod
var value = domGetAttribute(node, name);
attributeValues[name] = value;
if (value != null) {
- attributeList.push(name + "=" + value);
+ attributeList.push(name + '=' + value);
}
}
@@ -338,6 +346,7 @@ JstProcessor.prepareNode_ = function(nod
* (which will be called serially), typically due to a loop structure.
*
* @param {Function} f The first function to run.
+ * @private
*/
JstProcessor.prototype.run_ = function(f) {
var me = this;
@@ -351,7 +360,7 @@ JstProcessor.prototype.run_ = function(f
*
* The outer array is a stack of such queues.
*
- * @type Array.<Array>
+ * @type {Array.<Array>}
*/
var calls = me.calls_ = [];
@@ -360,13 +369,13 @@ JstProcessor.prototype.run_ = function(f
* be to maintain the queues in reverse order (popping off of the
* end) but the repeated calls to .pop() consumed 90% of this
* function's execution time.
- * @type Array.<number>
+ * @type {Array.<number>}
*/
var queueIndices = me.queueIndices_ = [];
/**
* A pool of empty arrays. Minimizes object allocation for IE6's benefit.
- * @type Array.<Array>
+ * @type {Array.<Array>}
*/
var arrayPool = me.arrayPool_ = [];
@@ -400,7 +409,8 @@ JstProcessor.prototype.run_ = function(f
* This method takes ownership of the given array!
*
* @param {Array} args Array of method calls structured as
- * [ method, arg1, arg2, method, arg1, arg2, ... ]
+ * [ method, arg1, arg2, method, arg1, arg2, ... ].
+ * @private
*/
JstProcessor.prototype.push_ = function(args) {
this.calls_.push(args);
@@ -410,7 +420,7 @@ JstProcessor.prototype.push_ = function(
/**
* Enable/disable debugging.
- * @param {boolean} debugging New state
+ * @param {boolean} debugging New state.
*/
JstProcessor.prototype.setDebugging = function(debugging) {
if (MAPS_DEBUG) {
@@ -418,7 +428,9 @@ JstProcessor.prototype.setDebugging = fu
}
};
-
+/**
+ * @private
+ */
JstProcessor.prototype.createArray_ = function() {
if (this.arrayPool_.length) {
return this.arrayPool_.pop();
@@ -428,6 +440,9 @@ JstProcessor.prototype.createArray_ = fu
};
+/**
+ * @private
+ */
JstProcessor.prototype.recycleArray_ = function(array) {
arrayClear(array);
this.arrayPool_.push(array);
@@ -447,6 +462,7 @@ JstProcessor.prototype.recycleArray_ = f
* @param {JsEvalContext} context
*
* @param {Element} template
+ * @private
*/
JstProcessor.prototype.jstProcessOuter_ = function(context, template) {
var me = this;
@@ -490,6 +506,7 @@ JstProcessor.prototype.jstProcessOuter_
* @param {JsEvalContext} context
*
* @param {Element} template
+ * @private
*/
JstProcessor.prototype.jstProcessInner_ = function(context, template) {
var me = this;
@@ -572,7 +589,7 @@ JstProcessor.prototype.jstProcessInner_
if (c.nodeType == DOM_ELEMENT_NODE) {
// Construct a new context if needed, lazily.
if (!ctx) {
- ctx = context;
+ ctx = context;
var selectInner = jstAttributes[ATT_innerselect];
if (selectInner && selectInner != VAR_this) {
ctx = context.clone(context.jsexec(selectInner, template), 0, 0);
@@ -604,6 +621,7 @@ JstProcessor.prototype.jstProcessInner_
*
* @notypecheck FIXME(hmitchell): See OCL6434950. instance and value need
* type checks.
+ * @private
*/
JstProcessor.prototype.jstSelect_ = function(context, template, select) {
var me = this;
@@ -621,7 +639,7 @@ JstProcessor.prototype.jstSelect_ = func
instance = parseInt10(instance.substr(1));
instanceLast = true;
} else {
- instance = parseInt10(/** @type string */(instance));
+ instance = parseInt10(/** @type {string} */(instance));
}
}
@@ -671,12 +689,12 @@ JstProcessor.prototype.jstSelect_ = func
var node = domCloneNode(template);
domInsertBefore(node, template);
- jstSetInstance(/** @type Element */(node), value, i);
+ jstSetInstance(/** @type {Element} */(node), value, i);
clone = context.clone(value[i], i, count);
queue.push(me.jstProcessInner_, clone, node,
JsEvalContext.recycle, clone, null);
-
+
}
// Push the originally present template instance last to keep
// the order aligned with the DOM order, because the newly
@@ -730,11 +748,12 @@ JstProcessor.prototype.jstSelect_ = func
* function that can be passed to jsexec() for evaluation in the
* current jscontext, and the first element is the variable name that
* the value returned by jsexec is assigned to.
+ * @private
*/
JstProcessor.prototype.jstVars_ = function(context, template, values) {
for (var i = 0, I = jsLength(values); i < I; i += 2) {
var label = values[i];
- var value = context.jsexec(values[i+1], template);
+ var value = context.jsexec(values[i + 1], template);
context.setVariable(label, value);
}
};
@@ -758,11 +777,12 @@ JstProcessor.prototype.jstVars_ = functi
* function that can be passed to jsexec() for evaluation in the
* current jscontext, and the first element is the label that
* determines where the value returned by jsexec is assigned to.
+ * @private
*/
JstProcessor.prototype.jstValues_ = function(context, template, values) {
for (var i = 0, I = jsLength(values); i < I; i += 2) {
var label = values[i];
- var value = context.jsexec(values[i+1], template);
+ var value = context.jsexec(values[i + 1], template);
if (label.charAt(0) == CHAR_dollar) {
// A jsvalues entry whose name starts with $ sets a local
@@ -819,6 +839,7 @@ JstProcessor.prototype.jstValues_ = func
*
* @param {Function} content Processed value of the jscontent
* attribute.
+ * @private
*/
JstProcessor.prototype.jstContent_ = function(context, template, content) {
// NOTE: Profiling shows that this method costs significant
@@ -848,6 +869,7 @@ JstProcessor.prototype.jstContent_ = fun
*
* @return {Object} A javascript object that has all js template
* processing attribute values of the node as properties.
+ * @private
*/
JstProcessor.prototype.jstAttributes_ = function(template) {
if (template[PROP_jstcache]) {
@@ -875,8 +897,8 @@ JstProcessor.prototype.jstAttributes_ =
* @param {Function=} opt_loadHtmlFn A function which, when called, will return
* HTML that contains an element whose ID is 'name'.
*
- * @return {Element|null} The DOM node of the template. (Only element nodes
- * can be found by ID, hence it's a Element.)
+ * @return {?Element} The DOM node of the template. (Only element nodes
+ * can be found by ID, hence it's a Element.).
*/
function jstGetTemplate(name, opt_loadHtmlFn) {
var doc = document;
@@ -905,12 +927,12 @@ function jstGetTemplate(name, opt_loadHt
* HTML that contains an element whose ID is 'name'.
*
* @return {Element} The DOM node of the template. (Only element nodes
- * can be found by ID, hence it's a Element.)
+ * can be found by ID, hence it's a Element.).
*/
function jstGetTemplateOrDie(name, opt_loadHtmlFn) {
var x = jstGetTemplate(name, opt_loadHtmlFn);
//check(x !== null);
- return /** @type Element */(x);
+ return /** @type {Element} */(x);
}
@@ -925,7 +947,7 @@ function jstGetTemplateOrDie(name, opt_l
* @param {string=} opt_target The id of a DOM object under which to attach the
* HTML once it's inserted. An object with this id is created if it does not
* exist.
- * @return {Element} The node whose id is 'name'
+ * @return {Element} The node whose id is 'name'.
*/
function jstLoadTemplateIfNotPresent(doc, name, loadHtmlFn, opt_target) {
var section = domGetElementById(doc, name);
@@ -936,10 +958,10 @@ function jstLoadTemplateIfNotPresent(doc
jstLoadTemplate_(doc, loadHtmlFn(), opt_target || STRING_jsts);
var section = domGetElementById(doc, name);
if (!section) {
- log("Error: jstGetTemplate was provided with opt_loadHtmlFn, " +
+ log('Error: jstGetTemplate was provided with opt_loadHtmlFn, ' +
"but that function did not provide the id '" + name + "'.");
}
- return /** @type Element */(section);
+ return /** @type {Element} */(section);
}
@@ -1001,6 +1023,7 @@ function jstSetInstance(template, values
* @param {string} caller An identifier for the caller of .log_.
* @param {Element} template The template node being processed.
* @param {Object} jstAttributeValues The jst attributes of the template node.
+ * @private
*/
JstProcessor.prototype.logState_ = function(
caller, template, jstAttributeValues) {
@@ -1016,7 +1039,7 @@ JstProcessor.prototype.logState_ = funct
}
if (jstAttributeValues) {
msg += '<tr><td>' + 'attr:' +
- '</td><td>' + /*jsToSource*/(jstAttributeValues) + '</td></tr>';
+ '</td><td>' + /*jsToSource*/(jstAttributeValues) + '</td></tr>';
}
msg += '</tbody></table><br/>';
this.logs_.push(msg);
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/util.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/util.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/util.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/jsTemplate/util.js Thu Oct 7 15:54:09 2010
@@ -51,7 +51,7 @@ var TYPE_undefined = 'undefined';
* code and returns null if the eval throws an exception.
*
* @param {string} expr
- * @return {Object|null}
+ * @return {?Object}
*/
function jsEval(expr) {
try {
@@ -94,11 +94,11 @@ function copyProperties(to, from) {
* @param {Object|null|undefined} value The possible value to use.
* @param {Object} defaultValue The default if the value is not set.
* @return {Object} The value, if it is
- * defined and not null; otherwise the default
+ * defined and not null; otherwise the default.
*/
function getDefaultObject(value, defaultValue) {
if (typeof value != TYPE_undefined && value != null) {
- return /** @type Object */(value);
+ return /** @type {Object} */(value);
} else {
return defaultValue;
}
@@ -108,7 +108,7 @@ function getDefaultObject(value, default
* Detect if an object looks like an Array.
* Note that instanceof Array is not robust; for example an Array
* created in another iframe fails instanceof Array.
- * @param {Object|null} value Object to interrogate
+ * @param {?Object} value Object to interrogate.
* @return {boolean} Is the object an array?
*/
function isArray(value) {
@@ -163,12 +163,12 @@ function arrayClear(array) {
/**
- * Prebinds "this" within the given method to an object, but ignores all
+ * Prebinds "this" within the given method to an object, but ignores all
* arguments passed to the resulting function.
* I.e. var_args are all the arguments that method is invoked with when
* invoking the bound function.
*
- * @param {Object|null} object The object that the method call targets.
+ * @param {?Object} object The object that the method call targets.
* @param {Function} method The target method.
* @return {Function} Method with the target object bound to it and curried by
* the provided arguments.
@@ -224,15 +224,16 @@ function DomTraverser(callback) {
*/
DomTraverser.prototype.run = function(root) {
var me = this;
- me.queue_ = [ root ];
+ me.queue_ = [root];
while (jsLength(me.queue_)) {
me.process_(me.queue_.shift());
}
-}
+};
/**
* Processes a single node.
* @param {Element} node The current node of the traversal.
+ * @private
*/
DomTraverser.prototype.process_ = function(node) {
var me = this;
@@ -244,14 +245,14 @@ DomTraverser.prototype.process_ = functi
me.queue_.push(c);
}
}
-}
+};
/**
* Get an attribute from the DOM. Simple redirect, exists to compress code.
*
* @param {Element} node Element to interrogate.
* @param {string} name Name of parameter to extract.
- * @return {string|null} Resulting attribute.
+ * @return {?string} Resulting attribute.
*/
function domGetAttribute(node, name) {
return node.getAttribute(name);
@@ -313,13 +314,13 @@ function domCloneElement(element) {
* itself.
*
* @param {Node|null|undefined} node The node whose ownerDocument is required.
- * @returns {Document} The owner document or window.document if unsupported.
+ * @return {Document} The owner document or window.document if unsupported.
*/
function ownerDocument(node) {
if (!node) {
return document;
} else if (node.nodeType == DOM_DOCUMENT_NODE) {
- return /** @type Document */(node);
+ return /** @type {Document} */(node);
} else {
return node.ownerDocument || document;
}
@@ -442,7 +443,7 @@ function stringTrim(str) {
* @return {string} Trimmed string.
*/
function stringTrimLeft(str) {
- return str.replace(/^\s+/, "");
+ return str.replace(/^\s+/, '');
}
/**
@@ -454,5 +455,5 @@ function stringTrimLeft(str) {
* @return {string} Trimmed string.
*/
function stringTrimRight(str) {
- return str.replace(/\s+$/, "");
+ return str.replace(/\s+$/, '');
}
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/loader.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/loader.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/loader.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/loader.js Thu Oct 7 15:54:09 2010
@@ -53,6 +53,7 @@ os.Loader = {};
/**
* A map of URLs which were already loaded.
+ * @private
*/
os.Loader.loadedUrls_ = {};
@@ -63,7 +64,7 @@ os.Loader.loadedUrls_ = {};
* @param {Function} callback Function to call once loaded.
*/
os.Loader.loadUrl = function(url, callback) {
- if (typeof(window['gadgets']) != "undefined") {
+ if (typeof(window['gadgets']) != 'undefined') {
os.Loader.requestUrlGadgets_(url, callback);
} else {
os.Loader.requestUrlXHR_(url, callback);
@@ -76,6 +77,7 @@ os.Loader.loadUrl = function(url, callba
* the same URL twice.
* @param {string} url The URL of the Template Library.
* @param {Function} callback Function to call once loaded.
+ * @private
*/
os.Loader.requestUrlXHR_ = function(url, callback) {
if (os.Loader.loadedUrls_[url]) {
@@ -87,12 +89,12 @@ os.Loader.requestUrlXHR_ = function(url,
shindig.xhrwrapper &&
shindig.xhrwrapper.createXHR) {
req = shindig.xhrwrapper.createXHR();
- } else if (typeof XMLHttpRequest != "undefined") {
+ } else if (typeof XMLHttpRequest != 'undefined') {
req = new XMLHttpRequest();
} else {
- req = new ActiveXObject("MSXML2.XMLHTTP");
+ req = new ActiveXObject('MSXML2.XMLHTTP');
}
- req.open("GET", url, true);
+ req.open('GET', url, true);
req.onreadystatechange = function() {
if (req.readyState == 4) {
os.Loader.loadContent(req.responseText, url);
@@ -107,6 +109,7 @@ os.Loader.requestUrlXHR_ = function(url,
* @param {string} url The URL where the content is located.
* @param {Function} callback Function to call with the data from the URL
* once it is fetched.
+ * @private
*/
os.Loader.requestUrlGadgets_ = function(url, callback) {
var params = {};
@@ -154,7 +157,8 @@ os.Loader.loadContent = function(xmlStri
/**
* Gets the function that should be used for processing a tag.
* @param {string} tagName Name of the tag.
- * @return {Function|null} The function for processing such tags.
+ * @return {?Function} The function for processing such tags.
+ * @private
*/
os.Loader.getProcessorFunction_ = function(tagName) {
// TODO(levik): This won't work once compiler does name mangling.
@@ -165,7 +169,12 @@ os.Loader.getProcessorFunction_ = functi
* Processes the <Templates> node.
*/
os.Loader.processTemplatesNode = function(node) {
- for (var child = node.firstChild; child; child = child.nextSibling) {
+ // since the ie domparse does not return a general parent element
+ // we check here if firstChild is really present
+ if (node.firstChild) {
+ node = node.firstChild;
+ }
+ for (var child = node; child; child = child.nextSibling) {
if (child.nodeType == DOM_ELEMENT_NODE) {
var handler = os.Loader.getProcessorFunction_(child.tagName);
if (handler) {
@@ -179,8 +188,8 @@ os.Loader.processTemplatesNode = functio
* Processes the <Namespace> node.
*/
os.Loader.processNamespaceNode = function(node) {
- var prefix = node.getAttribute("prefix");
- var url = node.getAttribute("url");
+ var prefix = node.getAttribute('prefix');
+ var url = node.getAttribute('url');
os.createNamespace(prefix, url);
};
@@ -188,8 +197,8 @@ os.Loader.processNamespaceNode = functio
* Processes the <TemplateDef> node
*/
os.Loader.processTemplateDefNode = function(node) {
- var tag = node.getAttribute("tag");
- var name = node.getAttribute("name");
+ var tag = node.getAttribute('tag');
+ var name = node.getAttribute('name');
for (var child = node.firstChild; child; child = child.nextSibling) {
if (child.nodeType == DOM_ELEMENT_NODE) {
// TODO(levik): This won't work once compiler does name mangling.
@@ -205,17 +214,17 @@ os.Loader.processTemplateDefNode = funct
* Processes the <Template> node
*/
os.Loader.processTemplateNode = function(node, opt_tag, opt_name) {
- var tag = opt_tag || node.getAttribute("tag");
- var name = opt_name || node.getAttribute("name");
+ var tag = opt_tag || node.getAttribute('tag');
+ var name = opt_name || node.getAttribute('name');
if (tag) {
- var tagParts = tag.split(":");
+ var tagParts = tag.split(':');
if (tagParts.length != 2) {
- throw Error("Invalid tag name: " + tag);
+ throw Error('Invalid tag name: ' + tag);
}
var nsObj = os.getNamespace(tagParts[0]);
if (!nsObj) {
- throw Error("Namespace not registered: " + tagParts[0] +
- " while trying to define " + tag);
+ throw Error('Namespace not registered: ' + tagParts[0] +
+ ' while trying to define ' + tag);
}
var template = os.compileXMLNode(node);
nsObj[tagParts[1]] = os.createTemplateCustomTag(template);
@@ -273,25 +282,25 @@ os.Loader.injectJavaScript = function(js
os.Loader.injectStyle = function(cssCode) {
var sheet;
if (document.styleSheets.length == 0) {
- document.getElementsByTagName("head")[0].appendChild(
- document.createElement("style"));
+ document.getElementsByTagName('head')[0].appendChild(
+ document.createElement('style'));
}
sheet = document.styleSheets[0];
- var rules = cssCode.split("}");
+ var rules = cssCode.split('}');
for (var i = 0; i < rules.length; i++) {
- var rule = rules[i].replace(/\n/g, "").replace(/\s+/g, " ");
+ var rule = rules[i].replace(/\n/g, '').replace(/\s+/g, ' ');
try {
if (rule.length > 2) {
if (sheet.insertRule) {
- rule = rule + "}";
- sheet.insertRule(rule, sheet.cssRules.length);
+ rule = rule + '}';
+ sheet.insertRule(rule, sheet.cssRules.length);
} else {
- var ruleParts = rule.split("{");
+ var ruleParts = rule.split('{');
sheet.addRule(ruleParts[0], ruleParts[1]);
}
}
} catch (err) {
- gadgets.error("Error in stylesheet: " + rule + " - " + e.name + " - " + e.message);
+ gadgets.error('Error in stylesheet: ' + rule + ' - ' + err.name + ' - ' + err.message);
}
}
};
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/namespaces.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/namespaces.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/namespaces.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/namespaces.js Thu Oct 7 15:54:09 2010
@@ -58,11 +58,11 @@ os.createNamespace = function(ns, url) {
tags = {};
os.nsmap_[ns] = tags;
opensocial.xmlutil.NSMAP[ns] = url;
- } else if (opensocial.xmlutil.NSMAP[ns] == null ) {
+ } else if (opensocial.xmlutil.NSMAP[ns] == null) {
// Lazily register an auto-created namespace.
opensocial.xmlutil.NSMAP[ns] = url;
} else if (opensocial.xmlutil.NSMAP[ns] != url) {
- throw("Namespace " + ns + " already defined with url " +
+ throw ('Namespace ' + ns + ' already defined with url ' +
opensocial.xmlutil.NSMAP[ns]);
}
return tags;
@@ -99,4 +99,4 @@ os.getCustomTag = function(ns, tag) {
} else {
return nsObj[tag];
}
-};
\ No newline at end of file
+};
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/os.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/os.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/os.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/os.js Thu Oct 7 15:54:09 2010
@@ -25,8 +25,8 @@
* Define 'os:Render' and 'os:Html' tags and the @onAttach attribute
*/
os.defineBuiltinTags = function() {
- var osn = os.getNamespace("os") ||
- os.createNamespace("os", "http://ns.opensocial.org/2008/markup");
+ var osn = os.getNamespace('os') ||
+ os.createNamespace('os', 'http://ns.opensocial.org/2008/markup');
/**
* <os:Render> custom tag renders the specified child nodes of the current
@@ -34,11 +34,11 @@ os.defineBuiltinTags = function() {
*/
osn.Render = function(node, data, context) {
var parent = context.getVariable(os.VAR_parentnode);
- var exp = node.getAttribute("content") || "*";
+ var exp = node.getAttribute('content') || '*';
var result = os.getValueFromNode_(parent, exp);
if (!result) {
- return "";
- } else if (typeof(result) == "string") {
+ return '';
+ } else if (typeof(result) == 'string') {
var textNode = document.createTextNode(result);
result = [];
result.push(textNode);
@@ -48,7 +48,7 @@ os.defineBuiltinTags = function() {
resultArray.push(result.childNodes[i]);
}
result = resultArray;
- } else if (exp != "*" && result.length == 1 &&
+ } else if (exp != '*' && result.length == 1 &&
result[0].nodeType == DOM_ELEMENT_NODE) {
// When we call <os:renderAll content="tag"/>, render the inner content
// of the tag returned, not the tag itself.
@@ -85,7 +85,7 @@ os.defineBuiltinTags = function() {
* rather than the text of the markup.
*/
osn.Html = function(node) {
- var html = node.code ? "" + node.code : node.getAttribute("code") || "";
+ var html = node.code ? '' + node.code : node.getAttribute('code') || '';
// TODO(levik): Sanitize the HTML here to avoid script injection issues.
// Perhaps use the gadgets sanitizer if available.
return html;
@@ -110,11 +110,11 @@ os.defineBuiltinTags = function() {
var func = new Function(code);
callbacks.push(createClosure(node, func));
}
- os.registerAttribute_("onAttach", processOnAttach);
- os.registerAttribute_("onCreate", processOnAttach);
- os.registerAttribute_("oncreate", processOnAttach);
- os.registerAttribute_("x-oncreate", processOnAttach);
- os.registerAttribute_("x-onCreate", processOnAttach);
+ os.registerAttribute_('onAttach', processOnAttach);
+ os.registerAttribute_('onCreate', processOnAttach);
+ os.registerAttribute_('oncreate', processOnAttach);
+ os.registerAttribute_('x-oncreate', processOnAttach);
+ os.registerAttribute_('x-onCreate', processOnAttach);
};
os.defineBuiltinTags();
@@ -131,11 +131,11 @@ os.defineBuiltinTags();
* @param {Object} object The object in the scope of which to get a named
* property.
* @param {string} name The name of the property to get.
- * @return {Object?|undefined} The property requested.
+ * @return {Object?} The property requested.
*/
os.resolveOpenSocialIdentifier = function(object, name) {
// Simple property from object.
- if (typeof(object[name]) != "undefined") {
+ if (typeof(object[name]) != 'undefined') {
return object[name];
}
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/template.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/template.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/template.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/template.js Thu Oct 7 15:54:09 2010
@@ -54,10 +54,10 @@ os.getContextDefaults_ = function() {
os.contextDefaults_ = {};
os.contextDefaults_[os.VAR_emptyArray] = os.EMPTY_ARRAY;
os.contextDefaults_[os.VAR_identifierresolver] = os.getFromContext;
- if (window["JSON"] && JSON.parse) {
- os.contextDefaults_["osx:parseJson"] = JSON.parse;
- } else if (window["gadgets"] && gadgets.json && gadgets.json.parse) {
- os.contextDefaults_["osx:parseJson"] = gadgets.json.parse;
+ if (window['JSON'] && JSON.parse) {
+ os.contextDefaults_['osx:parseJson'] = JSON.parse;
+ } else if (window['gadgets'] && gadgets.json && gadgets.json.parse) {
+ os.contextDefaults_['osx:parseJson'] = gadgets.json.parse;
}
}
return os.contextDefaults_;
@@ -65,11 +65,11 @@ os.getContextDefaults_ = function() {
/**
* A renderable compiled Template. A template can contain one or more
- * compiled nodes pre-processed for JST operation.
+ * compiled nodes pre-processed for JST operation.
* @constructor
*/
os.Template = function(opt_id) {
- this.templateRoot_ = document.createElement("span");
+ this.templateRoot_ = document.createElement('span');
this.id = opt_id || ('template_' + os.Template.idCounter_++);
};
@@ -83,7 +83,7 @@ os.Template.idCounter_ = 0;
/**
* A Map of registered templates by keyed ID.
* @type {Object.<string, os.Template>}
- * @private
+ * @private
*/
os.registeredTemplates_ = {};
@@ -115,6 +115,7 @@ os.getTemplate = function(templateId) {
/**
* Sets a single compiled node into this template.
* @param {Element} node - A compiled node.
+ * @private
*/
os.Template.prototype.setCompiledNode_ = function(node) {
os.removeChildren(this.templateRoot_);
@@ -124,6 +125,7 @@ os.Template.prototype.setCompiledNode_ =
/**
* Sets a list of compiled nodes into this template.
* @param {Array.<Element>} nodes An array of compiled nodes.
+ * @private
*/
os.Template.prototype.setCompiledNodes_ = function(nodes) {
os.removeChildren(this.templateRoot_);
@@ -135,13 +137,13 @@ os.Template.prototype.setCompiledNodes_
/**
* Renders the template and returns the result.
* Does not fire callbacks.
- * @return {Element} a DOM element containing the result of template processing
+ * @return {Element} a DOM element containing the result of template processing.
*/
os.Template.prototype.render = function(opt_data, opt_context) {
if (!opt_context) {
opt_context = os.createContext(opt_data);
}
- return os.renderTemplateNode_(this.templateRoot_, opt_context);
+ return os.renderTemplateNode_(this.templateRoot_, opt_context);
};
/**
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/util.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/util.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/util.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/opensocial-templates/util.js Thu Oct 7 15:54:09 2010
@@ -27,12 +27,12 @@
* @return {string} Input with leading and trailing whitespace removed.
*/
os.trim = function(string) {
- return string.replace(/^\s+|\s+$/g, '');
+ return string.replace(/^\s+|\s+$/g, '');
};
/**
- * Checks whether or not a given character is alpha-numeric. *
+ * Checks whether or not a given character is alpha-numeric. *
* @param {string} ch Character to check.
* @return {boolean} This character is alpha-numeric.
*/
@@ -67,7 +67,7 @@ os.appendChildren = function(sourceNode,
};
/**
- * Given a property name (e.g. 'foo') will create a JavaBean-style getter
+ * Given a property name (e.g. 'foo') will create a JavaBean-style getter
* (e.g. 'getFoo').
* @param {string} propertyName Name of the property.
* @return {string} The name of the getter function.
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/osapi/batch.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/osapi/batch.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/osapi/batch.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/osapi/batch.js Thu Oct 7 15:54:09 2010
@@ -42,16 +42,16 @@
/**
* Create a new request in the batch
- * @param {string} key id for the request
+ * @param {string} key id for the request.
* @param {Object} request the opensocial request object which is of the form
* { method : <service-method>
* rpc : <request>
* transport : <rpc dispatcher>
- * }
+ * }.
*/
var add = function(key, request) {
if (request && key) {
- keyedRequests.push({"key" : key, "request" : request});
+ keyedRequests.push({'key' : key, 'request' : request});
}
return that;
};
@@ -61,7 +61,7 @@
* @param {Object} request
*/
var toJsonRpc = function(request) {
- var jsonRpc = {method : request.request.method, id : request.key};
+ var jsonRpc = {method: request.request.method, id: request.key};
if (request.request.rpc) {
jsonRpc.params = request.request.rpc;
}
@@ -75,7 +75,7 @@
*
* @param {function(Object)} userCallback the callback to the gadget where results are passed.
*/
- var execute = function(userCallback) {
+ var execute = function(userCallback) {
var batchResult = {};
var perTransportBatch = {};
@@ -133,7 +133,7 @@
// Force the callback to occur asynchronously even if there were no actual calls
if (latchCount == 0) {
- window.setTimeout(function(){userCallback(batchResult)}, 0);
+ window.setTimeout(function() {userCallback(batchResult)}, 0);
}
};
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/osapi/gadgetsrpctransport.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/osapi/gadgetsrpctransport.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/osapi/gadgetsrpctransport.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/osapi/gadgetsrpctransport.js Thu Oct 7 15:54:09 2010
@@ -28,15 +28,15 @@ if (gadgets && gadgets.rpc) { //Dont bin
* Execute the JSON-RPC batch of gadgets.rpc. The container is expected to implement
* the method osapi._handleGadgetRpcMethod(<JSON-RPC batch>)
*
- * @param {Object} requests the opensocial JSON-RPC request batch
+ * @param {Object} requests the opensocial JSON-RPC request batch.
* @param {function(Object)} callback to the osapi batch with either an error response or
- * a JSON-RPC batch result
+ * a JSON-RPC batch result.
* @private
*/
function execute(requests, callback) {
- var rpcCallback = function(response) {
+ var rpcCallback = function(response) {
if (!response) {
- callback({ code : 500, message : 'Container refused the request' });
+ callback({ code: 500, message: 'Container refused the request' });
} else if (response.error) {
callback(response);
} else {
@@ -52,15 +52,15 @@ if (gadgets && gadgets.rpc) { //Dont bin
}
function init(config) {
- var transport = { name : "gadgets.rpc", "execute" : execute };
- var services = config["osapi.services"];
+ var transport = { name: 'gadgets.rpc', 'execute' : execute };
+ var services = config['osapi.services'];
if (services) {
// Iterate over the defined services, extract the gadget.rpc endpoint and
// bind to it
for (var endpointName in services) if (services.hasOwnProperty(endpointName)) {
- if (endpointName === "gadgets.rpc") {
+ if (endpointName === 'gadgets.rpc') {
var methods = services[endpointName];
- for (var i=0; i < methods.length; i++) {
+ for (var i = 0; i < methods.length; i++) {
osapi._registerMethod(methods[i], transport);
}
}
@@ -96,7 +96,7 @@ if (gadgets && gadgets.rpc) { //Dont bin
if (!response.error) {
for (var i = 0; i < response.length; i++) {
// do not rebind container.listMethods implementation
- if (response[i] != "container.listMethods") {
+ if (response[i] != 'container.listMethods') {
osapi._registerMethod(response[i], transport);
}
}
@@ -114,7 +114,7 @@ if (gadgets && gadgets.rpc) { //Dont bin
// Do not run this in container mode.
if (gadgets.config && gadgets.config.isGadget) {
- gadgets.config.register("osapi.services", null, init);
+ gadgets.config.register('osapi.services', null, init);
}
})();
}
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/osapi/jsonrpctransport.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/osapi/jsonrpctransport.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/osapi/jsonrpctransport.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/osapi/jsonrpctransport.js Thu Oct 7 15:54:09 2010
@@ -33,9 +33,9 @@
// Convert an XHR failure to a JSON-RPC error
if (response.errors[0]) {
callback({
- error : {
- code : response.rc,
- message : response.text
+ error: {
+ code: response.rc,
+ message: response.text
}
});
} else {
@@ -53,34 +53,34 @@
}
var request = {
- "POST_DATA" : gadgets.json.stringify(requests),
- "CONTENT_TYPE" : "JSON",
- "METHOD" : "POST",
- "AUTHORIZATION" : "SIGNED"
+ 'POST_DATA' : gadgets.json.stringify(requests),
+ 'CONTENT_TYPE' : 'JSON',
+ 'METHOD' : 'POST',
+ 'AUTHORIZATION' : 'SIGNED'
};
var url = this.name;
var token = shindig.auth.getSecurityToken();
if (token) {
- url += "?st=";
+ url += '?st=';
url += encodeURIComponent(token);
}
- gadgets.io.makeNonProxiedRequest(url, processResponse, request, "application/json");
+ gadgets.io.makeNonProxiedRequest(url, processResponse, request, 'application/json');
}
function init(config) {
- var services = config["osapi.services"];
+ var services = config['osapi.services'];
if (services) {
// Iterate over the defined services, extract the http endpoints and
// create a transport per-endpoint
for (var endpointName in services) if (services.hasOwnProperty(endpointName)) {
- if (endpointName.indexOf("http") == 0 ||
- endpointName.indexOf("//") == 0) {
+ if (endpointName.indexOf('http') == 0 ||
+ endpointName.indexOf('//') == 0) {
// Expand the host & append the security token
- var endpointUrl = endpointName.replace("%host%", document.location.host);
- var transport = { name : endpointUrl, "execute" : execute };
+ var endpointUrl = endpointName.replace('%host%', document.location.host);
+ var transport = { name: endpointUrl, 'execute' : execute };
var methods = services[endpointName];
- for (var i=0; i < methods.length; i++) {
+ for (var i = 0; i < methods.length; i++) {
osapi._registerMethod(methods[i], transport);
}
}
@@ -90,7 +90,7 @@
// We do run this in the container mode in the new common container
if (gadgets.config) {
- gadgets.config.register("osapi.services", null, init);
+ gadgets.config.register('osapi.services', null, init);
}
})();
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/osapi/osapi.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/osapi/osapi.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/osapi/osapi.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/osapi/osapi.js Thu Oct 7 15:54:09 2010
@@ -19,19 +19,19 @@
(function() {
/**
* Called by the transports for each service method that they expose
- * @param {string} method The method to expose e.g. "people.get"
- * @param {Object.<string,Object>} transport The transport used to execute a call for the method
+ * @param {string} method The method to expose e.g. "people.get".
+ * @param {Object.<string,Object>} transport The transport used to execute a call for the method.
*/
- osapi._registerMethod = function (method, transport) {
+ osapi._registerMethod = function(method, transport) {
var has___ = typeof ___ !== 'undefined';
// Skip registration of local newBatch implementation.
- if (method == "newBatch") {
- return;
+ if (method == 'newBatch') {
+ return;
}
// Lookup last method value.
- var parts = method.split(".");
+ var parts = method.split('.');
var last = osapi;
for (var i = 0; i < parts.length - 1; i++) {
last[parts[i]] = last[parts[i]] || {};
@@ -55,13 +55,13 @@
});
}
if (has___) {
- ___.markInnocent(boundCall.execute, 'execute');
+ ___.markInnocent(boundCall.execute, 'execute');
}
// TODO: This shouldnt really be necessary. The spec should be clear enough about
// defaults that we dont have to populate this.
rpc = rpc || {};
- rpc.userId = rpc.userId || "@viewer";
- rpc.groupId = rpc.groupId || "@self";
+ rpc.userId = rpc.userId || '@viewer';
+ rpc.groupId = rpc.groupId || '@self';
// Decorate the execute method with the information necessary for batching
boundCall.method = method;
@@ -75,7 +75,7 @@
}
if (last[parts[parts.length - 1]]) {
- gadgets.warn("Skipping duplicate osapi method definition " + method + " on transport " + transport.name);
+ gadgets.warn('Skipping duplicate osapi method definition ' + method + ' on transport ' + transport.name);
} else {
last[parts[parts.length - 1]] = apiMethod;
}
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/osapi/peoplehelpers.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/osapi/peoplehelpers.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/osapi/peoplehelpers.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/osapi/peoplehelpers.js Thu Oct 7 15:54:09 2010
@@ -30,62 +30,62 @@ gadgets.util.registerOnLoadHandler(funct
* Options specifies parameters to the call as outlined in the
* JSON RPC Opensocial Spec
* http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
- * @param {object.<JSON>} The JSON object of parameters for the specific request
+ * @param {object.<JSON>} The JSON object of parameters for the specific request.
*/
- /**
+ /**
* Function to get Viewer profile.
* Options specifies parameters to the call as outlined in the
* JSON RPC Opensocial Spec
* http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
- * @param {object.<JSON>} The JSON object of parameters for the specific request
+ * @param {object.<JSON>} The JSON object of parameters for the specific request.
*/
- osapi.people.getViewer = function(options) {
- options = options || {};
- options.userId = "@viewer";
- options.groupId = "@self";
- return osapi.people.get(options);
- };
+ osapi.people.getViewer = function(options) {
+ options = options || {};
+ options.userId = '@viewer';
+ options.groupId = '@self';
+ return osapi.people.get(options);
+ };
- /**
+ /**
* Function to get Viewer's friends' profiles.
* Options specifies parameters to the call as outlined in the
* JSON RPC Opensocial Spec
* http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
- * @param {object.<JSON>} The JSON object of parameters for the specific request
+ * @param {object.<JSON>} The JSON object of parameters for the specific request.
*/
- osapi.people.getViewerFriends = function(options) {
- options = options || {};
- options.userId = "@viewer";
- options.groupId = "@friends";
- return osapi.people.get(options);
- };
+ osapi.people.getViewerFriends = function(options) {
+ options = options || {};
+ options.userId = '@viewer';
+ options.groupId = '@friends';
+ return osapi.people.get(options);
+ };
- /**
+ /**
* Function to get Owner profile.
* Options specifies parameters to the call as outlined in the
* JSON RPC Opensocial Spec
* http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
- * @param {object.<JSON>} The JSON object of parameters for the specific request
+ * @param {object.<JSON>} The JSON object of parameters for the specific request.
*/
- osapi.people.getOwner = function(options) {
- options = options || {};
- options.userId = "@owner";
- options.groupId = "@self";
- return osapi.people.get(options);
- };
+ osapi.people.getOwner = function(options) {
+ options = options || {};
+ options.userId = '@owner';
+ options.groupId = '@self';
+ return osapi.people.get(options);
+ };
- /**
+ /**
* Function to get Owner's friends' profiles.
* Options specifies parameters to the call as outlined in the
* JSON RPC Opensocial Spec
* http://www.opensocial.org/Technical-Resources/opensocial-spec-v081/rpc-protocol
- * @param {object.<JSON>} The JSON object of parameters for the specific request
+ * @param {object.<JSON>} The JSON object of parameters for the specific request.
*/
- osapi.people.getOwnerFriends = function(options) {
- options = options || {};
- options.userId = "@owner";
- options.groupId = "@friends";
- return osapi.people.get(options);
- };
+ osapi.people.getOwnerFriends = function(options) {
+ options = options || {};
+ options.userId = '@owner';
+ options.groupId = '@friends';
+ return osapi.people.get(options);
+ };
}
});
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/osapi/taming.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/osapi/taming.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/osapi/taming.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/osapi/taming.js Thu Oct 7 15:54:09 2010
@@ -24,7 +24,7 @@
var tamings___ = tamings___ || [];
tamings___.push(function(imports) {
- ___.tamesTo(osapi.newBatch, ___.markFuncFreeze(function () {
+ ___.tamesTo(osapi.newBatch, ___.markFuncFreeze(function() {
var result = osapi.newBatch();
___.markInnocent(result['add'], 'add');
___.markInnocent(result['execute'], 'execute');
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/pubsub/pubsub-router.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/pubsub/pubsub-router.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/pubsub/pubsub-router.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/pubsub/pubsub-router.js Thu Oct 7 15:54:09 2010
@@ -38,38 +38,38 @@ gadgets.pubsubrouter = function() {
var sender = gadgetId === '..' ? 'container' : gadgetIdToSpecUrl(gadgetId);
if (sender) {
switch (command) {
- case 'subscribe':
- if (onSubscribe && onSubscribe(gadgetId, channel)) {
- break;
- }
- if (!subscribers[channel]) {
- subscribers[channel] = {};
- }
- subscribers[channel][gadgetId] = true;
- break;
- case 'unsubscribe':
- if (onUnsubscribe && onUnsubscribe(gadgetId, channel)) {
+ case 'subscribe':
+ if (onSubscribe && onSubscribe(gadgetId, channel)) {
+ break;
+ }
+ if (!subscribers[channel]) {
+ subscribers[channel] = {};
+ }
+ subscribers[channel][gadgetId] = true;
break;
- }
- if (subscribers[channel]) {
- delete subscribers[channel][gadgetId];
- }
- break;
- case 'publish':
- if (onPublish && onPublish(gadgetId, channel, message)) {
+ case 'unsubscribe':
+ if (onUnsubscribe && onUnsubscribe(gadgetId, channel)) {
+ break;
+ }
+ if (subscribers[channel]) {
+ delete subscribers[channel][gadgetId];
+ }
break;
- }
- var channelSubscribers = subscribers[channel];
- if (channelSubscribers) {
- for (var subscriber in channelSubscribers) {
- if (channelSubscribers.hasOwnProperty(subscriber)) {
- gadgets.rpc.call(subscriber, 'pubsub', null, channel, sender, message);
+ case 'publish':
+ if (onPublish && onPublish(gadgetId, channel, message)) {
+ break;
+ }
+ var channelSubscribers = subscribers[channel];
+ if (channelSubscribers) {
+ for (var subscriber in channelSubscribers) {
+ if (channelSubscribers.hasOwnProperty(subscriber)) {
+ gadgets.rpc.call(subscriber, 'pubsub', null, channel, sender, message);
+ }
}
}
- }
- break;
- default:
- throw new Error('Unknown pubsub command');
+ break;
+ default:
+ throw new Error('Unknown pubsub command');
}
}
}
@@ -79,7 +79,7 @@ gadgets.pubsubrouter = function() {
* Initializes the PubSub message router.
* @param {function(number)} gadgetIdToSpecUrlHandler Function that returns the full
* gadget spec URL of a given gadget id. For example:
- * function(id) { return idToUrlMap[id]; }
+ * function(id) { return idToUrlMap[id]; }.
* @param {Object=} opt_callbacks Optional event handlers. Supported handlers:
* opt_callbacks.onSubscribe: function(gadgetId, channel)
* Called when a gadget tries to subscribe to a channel.
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/pubsub/pubsub.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/pubsub/pubsub.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/pubsub/pubsub.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/pubsub/pubsub.js Thu Oct 7 15:54:09 2010
@@ -54,7 +54,7 @@ gadgets.pubsub = function() {
* if (isTrustedGadgetSpecUrl(sender)) {
* processMessage(message);
* }
- * }
+ * }.
*/
subscribe: function(channel, callback) {
listeners[channel] = callback;
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/rpc/fe.transport.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/rpc/fe.transport.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/rpc/fe.transport.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/rpc/fe.transport.js Thu Oct 7 15:54:09 2010
@@ -42,96 +42,96 @@ gadgets.rpctx = gadgets.rpctx || {};
*/
if (!gadgets.rpctx.frameElement) { // make lib resilient to double-inclusion
-gadgets.rpctx.frameElement = function() {
- // Consts for FrameElement.
- var FE_G2C_CHANNEL = '__g2c_rpc';
- var FE_C2G_CHANNEL = '__c2g_rpc';
- var process;
- var ready;
-
- function callFrameElement(targetId, from, rpc) {
- try {
- if (from !== '..') {
- // Call from gadget to the container.
- var fe = window.frameElement;
-
- if (typeof fe[FE_G2C_CHANNEL] === 'function') {
- // Complete the setup of the FE channel if need be.
- if (typeof fe[FE_G2C_CHANNEL][FE_C2G_CHANNEL] !== 'function') {
- fe[FE_G2C_CHANNEL][FE_C2G_CHANNEL] = function(args) {
- process(gadgets.json.parse(args));
- };
+ gadgets.rpctx.frameElement = function() {
+ // Consts for FrameElement.
+ var FE_G2C_CHANNEL = '__g2c_rpc';
+ var FE_C2G_CHANNEL = '__c2g_rpc';
+ var process;
+ var ready;
+
+ function callFrameElement(targetId, from, rpc) {
+ try {
+ if (from !== '..') {
+ // Call from gadget to the container.
+ var fe = window.frameElement;
+
+ if (typeof fe[FE_G2C_CHANNEL] === 'function') {
+ // Complete the setup of the FE channel if need be.
+ if (typeof fe[FE_G2C_CHANNEL][FE_C2G_CHANNEL] !== 'function') {
+ fe[FE_G2C_CHANNEL][FE_C2G_CHANNEL] = function(args) {
+ process(gadgets.json.parse(args));
+ };
+ }
+
+ // Conduct the RPC call.
+ fe[FE_G2C_CHANNEL](gadgets.json.stringify(rpc));
+ return true;
+ }
+ } else {
+ // Call from container to gadget[targetId].
+ var frame = document.getElementById(targetId);
+
+ if (typeof frame[FE_G2C_CHANNEL] === 'function' &&
+ typeof frame[FE_G2C_CHANNEL][FE_C2G_CHANNEL] === 'function') {
+
+ // Conduct the RPC call.
+ frame[FE_G2C_CHANNEL][FE_C2G_CHANNEL](gadgets.json.stringify(rpc));
+ return true;
}
-
- // Conduct the RPC call.
- fe[FE_G2C_CHANNEL](gadgets.json.stringify(rpc));
- return true;
- }
- } else {
- // Call from container to gadget[targetId].
- var frame = document.getElementById(targetId);
-
- if (typeof frame[FE_G2C_CHANNEL] === 'function' &&
- typeof frame[FE_G2C_CHANNEL][FE_C2G_CHANNEL] === 'function') {
-
- // Conduct the RPC call.
- frame[FE_G2C_CHANNEL][FE_C2G_CHANNEL](gadgets.json.stringify(rpc));
- return true;
}
+ } catch (e) {
}
- } catch (e) {
+ return false;
}
- return false;
- }
- return {
- getCode: function() {
- return 'fe';
- },
-
- isParentVerifiable: function() {
- return false;
- },
-
- init: function(processFn, readyFn) {
- // No global setup.
- process = processFn;
- ready = readyFn;
- return true;
- },
-
- setup: function(receiverId, token) {
- // Indicate OK to call to container. This will be true
- // by the end of this method.
- if (receiverId !== '..') {
- try {
- var frame = document.getElementById(receiverId);
- frame[FE_G2C_CHANNEL] = function(args) {
- process(gadgets.json.parse(args));
+ return {
+ getCode: function() {
+ return 'fe';
+ },
+
+ isParentVerifiable: function() {
+ return false;
+ },
+
+ init: function(processFn, readyFn) {
+ // No global setup.
+ process = processFn;
+ ready = readyFn;
+ return true;
+ },
+
+ setup: function(receiverId, token) {
+ // Indicate OK to call to container. This will be true
+ // by the end of this method.
+ if (receiverId !== '..') {
+ try {
+ var frame = document.getElementById(receiverId);
+ frame[FE_G2C_CHANNEL] = function(args) {
+ process(gadgets.json.parse(args));
+ };
+ } catch (e) {
+ return false;
+ }
+ }
+ if (receiverId === '..') {
+ ready('..', true);
+ var ackFn = function() {
+ window.setTimeout(function() {
+ gadgets.rpc.call(receiverId, gadgets.rpc.ACK);
+ }, 500);
};
- } catch (e) {
- return false;
+ // Setup to container always happens before onload.
+ // If it didn't, the correct fix would be in gadgets.util.
+ gadgets.util.registerOnLoadHandler(ackFn);
}
- }
- if (receiverId === '..') {
- ready('..', true);
- var ackFn = function() {
- window.setTimeout(function() {
- gadgets.rpc.call(receiverId, gadgets.rpc.ACK);
- }, 500);
- };
- // Setup to container always happens before onload.
- // If it didn't, the correct fix would be in gadgets.util.
- gadgets.util.registerOnLoadHandler(ackFn);
- }
- return true;
- },
+ return true;
+ },
- call: function(targetId, from, rpc) {
- return callFrameElement(targetId, from, rpc);
- }
+ call: function(targetId, from, rpc) {
+ return callFrameElement(targetId, from, rpc);
+ }
- };
-}();
+ };
+ }();
} // !end of double-inclusion guard
Modified: shindig/branches/2.0.x/features/src/main/javascript/features/rpc/ifpc.transport.js
URL: http://svn.apache.org/viewvc/shindig/branches/2.0.x/features/src/main/javascript/features/rpc/ifpc.transport.js?rev=1005506&r1=1005505&r2=1005506&view=diff
==============================================================================
--- shindig/branches/2.0.x/features/src/main/javascript/features/rpc/ifpc.transport.js (original)
+++ shindig/branches/2.0.x/features/src/main/javascript/features/rpc/ifpc.transport.js Thu Oct 7 15:54:09 2010
@@ -36,124 +36,124 @@ gadgets.rpctx = gadgets.rpctx || {};
*/
if (!gadgets.rpctx.ifpc) { // make lib resilient to double-inclusion
-gadgets.rpctx.ifpc = function() {
- var iframePool = [];
- var callId = 0;
- var ready;
+ gadgets.rpctx.ifpc = function() {
+ var iframePool = [];
+ var callId = 0;
+ var ready;
- /**
+ /**
* Encodes arguments for the legacy IFPC wire format.
*
* @param {Object} args
- * @return {string} the encoded args
+ * @return {string} the encoded args.
*/
- function encodeLegacyData(args) {
- var argsEscaped = [];
- for(var i = 0, j = args.length; i < j; ++i) {
- argsEscaped.push(encodeURIComponent(gadgets.json.stringify(args[i])));
+ function encodeLegacyData(args) {
+ var argsEscaped = [];
+ for (var i = 0, j = args.length; i < j; ++i) {
+ argsEscaped.push(encodeURIComponent(gadgets.json.stringify(args[i])));
+ }
+ return argsEscaped.join('&');
}
- return argsEscaped.join('&');
- }
- /**
+ /**
* Helper function to emit an invisible IFrame.
* @param {string} src SRC attribute of the IFrame to emit.
* @private
*/
- function emitInvisibleIframe(src) {
- var iframe;
- // Recycle IFrames
- for (var i = iframePool.length - 1; i >=0; --i) {
- var ifr = iframePool[i];
- try {
- if (ifr && (ifr.recyclable || ifr.readyState === 'complete')) {
- ifr.parentNode.removeChild(ifr);
- if (window.ActiveXObject) {
- // For MSIE, delete any iframes that are no longer being used. MSIE
- // cannot reuse the IFRAME because a navigational click sound will
- // be triggered when we set the SRC attribute.
- // Other browsers scan the pool for a free iframe to reuse.
- iframePool[i] = ifr = null;
- iframePool.splice(i, 1);
- } else {
- ifr.recyclable = false;
- iframe = ifr;
- break;
+ function emitInvisibleIframe(src) {
+ var iframe;
+ // Recycle IFrames
+ for (var i = iframePool.length - 1; i >= 0; --i) {
+ var ifr = iframePool[i];
+ try {
+ if (ifr && (ifr.recyclable || ifr.readyState === 'complete')) {
+ ifr.parentNode.removeChild(ifr);
+ if (window.ActiveXObject) {
+ // For MSIE, delete any iframes that are no longer being used. MSIE
+ // cannot reuse the IFRAME because a navigational click sound will
+ // be triggered when we set the SRC attribute.
+ // Other browsers scan the pool for a free iframe to reuse.
+ iframePool[i] = ifr = null;
+ iframePool.splice(i, 1);
+ } else {
+ ifr.recyclable = false;
+ iframe = ifr;
+ break;
+ }
}
+ } catch (e) {
+ // Ignore; IE7 throws an exception when trying to read readyState and
+ // readyState isn't set.
}
- } catch (e) {
- // Ignore; IE7 throws an exception when trying to read readyState and
- // readyState isn't set.
}
- }
- // Create IFrame if necessary
- if (!iframe) {
- iframe = document.createElement('iframe');
- iframe.style.border = iframe.style.width = iframe.style.height = '0px';
- iframe.style.visibility = 'hidden';
- iframe.style.position = 'absolute';
- iframe.onload = function() { this.recyclable = true; };
- iframePool.push(iframe);
- }
- iframe.src = src;
- window.setTimeout(function() { document.body.appendChild(iframe); }, 0);
- }
-
- return {
- getCode: function() {
- return 'ifpc';
- },
-
- isParentVerifiable: function() {
- return true;
- },
-
- init: function(processFn, readyFn) {
- // No global setup.
- ready = readyFn;
- ready('..', true); // Ready immediately.
- return true;
- },
-
- setup: function(receiverId, token) {
- // Indicate readiness to send to receiver.
- ready(receiverId, true);
- return true;
- },
-
- call: function(targetId, from, rpc) {
- // Retrieve the relay file used by IFPC. Note that
- // this must be set before the call, and so we conduct
- // an extra check to ensure it is not blank.
- var relay = gadgets.rpc.getRelayUrl(targetId);
- ++callId;
-
- if (!relay) {
- gadgets.warn('No relay file assigned for IFPC');
- return false;
+ // Create IFrame if necessary
+ if (!iframe) {
+ iframe = document.createElement('iframe');
+ iframe.style.border = iframe.style.width = iframe.style.height = '0px';
+ iframe.style.visibility = 'hidden';
+ iframe.style.position = 'absolute';
+ iframe.onload = function() { this.recyclable = true; };
+ iframePool.push(iframe);
}
+ iframe.src = src;
+ window.setTimeout(function() { document.body.appendChild(iframe); }, 0);
+ }
- // The RPC mechanism supports two formats for IFPC (legacy and current).
- var src = null;
- if (rpc.l) {
- // Use legacy protocol.
- // Format: #iframe_id&callId&num_packets&packet_num&block_of_data
- var callArgs = rpc.a;
- src = [relay, '#', encodeLegacyData([from, callId, 1, 0,
- encodeLegacyData([from, rpc.s, '', '', from].concat(
- callArgs))])].join('');
- } else {
- // Format: #targetId & sourceId@callId & packetNum & packetId & packetData
- src = [relay, '#', targetId, '&', from, '@', callId,
- '&1&0&', encodeURIComponent(gadgets.json.stringify(rpc))].join('');
- }
+ return {
+ getCode: function() {
+ return 'ifpc';
+ },
+
+ isParentVerifiable: function() {
+ return true;
+ },
+
+ init: function(processFn, readyFn) {
+ // No global setup.
+ ready = readyFn;
+ ready('..', true); // Ready immediately.
+ return true;
+ },
+
+ setup: function(receiverId, token) {
+ // Indicate readiness to send to receiver.
+ ready(receiverId, true);
+ return true;
+ },
+
+ call: function(targetId, from, rpc) {
+ // Retrieve the relay file used by IFPC. Note that
+ // this must be set before the call, and so we conduct
+ // an extra check to ensure it is not blank.
+ var relay = gadgets.rpc.getRelayUrl(targetId);
+ ++callId;
+
+ if (!relay) {
+ gadgets.warn('No relay file assigned for IFPC');
+ return false;
+ }
- // Conduct the IFPC call by creating the Iframe with
- // the relay URL and appended message.
- emitInvisibleIframe(src);
- return true;
- }
- };
-}();
+ // The RPC mechanism supports two formats for IFPC (legacy and current).
+ var src = null;
+ if (rpc.l) {
+ // Use legacy protocol.
+ // Format: #iframe_id&callId&num_packets&packet_num&block_of_data
+ var callArgs = rpc.a;
+ src = [relay, '#', encodeLegacyData([from, callId, 1, 0,
+ encodeLegacyData([from, rpc.s, '', '', from].concat(
+ callArgs))])].join('');
+ } else {
+ // Format: #targetId & sourceId@callId & packetNum & packetId & packetData
+ src = [relay, '#', targetId, '&', from, '@', callId,
+ '&1&0&', encodeURIComponent(gadgets.json.stringify(rpc))].join('');
+ }
+
+ // Conduct the IFPC call by creating the Iframe with
+ // the relay URL and appended message.
+ emitInvisibleIframe(src);
+ return true;
+ }
+ };
+ }();
} // !end of double inclusion guard