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 2009/10/24 10:48:50 UTC
svn commit: r829323 -
/incubator/shindig/trunk/features/src/main/javascript/features/views/views.js
Author: lindner
Date: Sat Oct 24 08:48:49 2009
New Revision: 829323
URL: http://svn.apache.org/viewvc?rev=829323&view=rev
Log:
SHINDIG-890 | Patch from Henning Schmiedehausen | Make URL Template example from opensocial spec actually work with shindig
Modified:
incubator/shindig/trunk/features/src/main/javascript/features/views/views.js
Modified: incubator/shindig/trunk/features/src/main/javascript/features/views/views.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/src/main/javascript/features/views/views.js?rev=829323&r1=829322&r2=829323&view=diff
==============================================================================
--- incubator/shindig/trunk/features/src/main/javascript/features/views/views.js (original)
+++ incubator/shindig/trunk/features/src/main/javascript/features/views/views.js Sat Oct 24 08:48:49 2009
@@ -185,6 +185,18 @@
return j;
}
+ function objectIsEmpty(v) {
+ if ((typeof v === 'object') || (typeof v === 'function')) {
+ for (i in v) {
+ if (v.hasOwnProperty(i)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
+ }
+
while ((group = expansionRE.exec(urlTemplate))) {
result.push(urlTemplate.substring(textStart, group.index));
textStart = expansionRE.lastIndex;
@@ -203,10 +215,11 @@
flag = 1;
case 'opt':
if (matchVars(vars, {flag: flag}, function(j, v) {
- if (typeof v !== 'undefined' && (typeof v !== 'object' || v.length)) {
+ if (typeof v !== 'undefined' && !objectIsEmpty(v)) {
j.flag = !j.flag;
return 1;
}
+ return 0;
}).flag) {
result.push(arg);
}
@@ -215,6 +228,12 @@
result.push(matchVars(vars, [], function(j, v, k) {
if (typeof v === 'string') {
j.push(k + '=' + v);
+ } else if (typeof v === 'object') {
+ for (i in v) {
+ if (v.hasOwnProperty(i)) {
+ j.push(i + '=' + v[i]);
+ }
+ }
}
}).join(arg));
break;