You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by li...@apache.org on 2008/02/11 21:48:57 UTC

svn commit: r620607 - /incubator/shindig/trunk/features/opensocial-reference/person.js

Author: lindner
Date: Mon Feb 11 12:48:48 2008
New Revision: 620607

URL: http://svn.apache.org/viewvc?rev=620607&view=rev
Log:
Simple fix for SHINDIG-59

Modified:
    incubator/shindig/trunk/features/opensocial-reference/person.js

Modified: incubator/shindig/trunk/features/opensocial-reference/person.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-reference/person.js?rev=620607&r1=620606&r2=620607&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-reference/person.js (original)
+++ incubator/shindig/trunk/features/opensocial-reference/person.js Mon Feb 11 12:48:48 2008
@@ -482,7 +482,27 @@
  * @return {String} The display name
  */
 opensocial.Person.prototype.getDisplayName = function() {
-  return this.getField(opensocial.Person.Field.NAME);
+  var name = '';
+  var s = '';
+
+  var name = this.getField(opensocial.Person.Field.NAME);
+  // Try unstructed field first
+  s = name.getField(opensocial.Name.Field.UNSTRUCTURED);
+
+  if (s) return(s);
+
+  // Next try to construct the name from the individual components
+  s = '';
+  for (var field in [name.getField(opensocial.Name.Field.HONORIFIC_PREFIX),
+                     name.getField(opensocial.Name.Field.GIVEN_NAME),
+                     name.getField(opensocial.Name.Field.FAMILY_NAME),
+                     name.getField(opensocial.Name.Field.HONORIFIC_SUFFIX),
+                     name.getField(opensocial.Name.Field.ADDITIONAL_NAME)]) {
+      if (name.getField(field)) {
+          s += name.getField(field) + ' ';
+      }
+  }
+  return s.replace(/^\s+|\s+$/g, '') ;
 };