Author: nbelaevski
Date: 2009-09-18 11:41:43 -0400 (Fri, 18 Sep 2009)
New Revision: 15622
Modified:
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
Log:
Code review fixes for richfaces.js
Modified: root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js
===================================================================
---
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2009-09-18
13:25:36 UTC (rev 15621)
+++
root/framework/trunk/impl/src/main/resources/META-INF/resources/richfaces.js 2009-09-18
15:41:43 UTC (rev 15622)
@@ -48,7 +48,7 @@
this.each(function() { out += xs.serializeToString(this); });
} else if (this[0].xml !== undefined) {
this.each(function() { out += this.xml; });
- } else if (this.length > 0) { // PY: [if] not needed, was upper
+ } else {
this.each( function() { out += this; } );
}
}
@@ -123,7 +123,7 @@
var useBrowserConsole = false;
- var AM_PM = /(\s*(?:a|p)m)$/ig; // PY: [g] not needed when $ - end of string
+ var AM_PM = /(\s*(?:a|p)m)$/i;
var getMessagePrefix = function(level) {
var date = new Date();
@@ -234,10 +234,12 @@
return value || "";
};
+ var ALPHA_NUMERIC_MULTI_CHAR_REGEXP = /^\w+$/;
+
richfaces.interpolate = function (placeholders, context) {
var contextVarsArray = new Array();
for (var contextVar in context) {
- if (/^\w+$/.test(contextVar)) { // PY: define regexp before for
+ if (ALPHA_NUMERIC_MULTI_CHAR_REGEXP.test(contextVar)) {
//guarantees that no escaping for the below RegExp is necessary
contextVarsArray.push(contextVar);
}
@@ -263,7 +265,7 @@
richfaces.stopPush(pushId);
- pushTracker[pushId] = setTimeout(function() { // PY: may be define this function in
richfaces object to avoid definition every time when call startPush
+ pushTracker[pushId] = setTimeout(function() { // TODO: define this function in
richfaces object to avoid definition every time when call startPush
var ajaxOptions = {
type: "HEAD",
//TODO - encodeURIComponent; URL sessionId handling check
@@ -278,12 +280,10 @@
if (xhr.status == 200 && xhr.getResponseHeader("Ajax-Push-Status")
== "READY") {
var pushElement = document.getElementById(clientId);
- if (pushElement) {
- try {
- ondataavailable.call(pushElement);
- } catch (e) {
- // TODO: handle exception
- }
+ try {
+ ondataavailable.call(pushElement || window);
+ } catch (e) {
+ // TODO: handle exception
}
}
Show replies by date