You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@esme.apache.org by rh...@apache.org on 2011/02/21 09:25:18 UTC

svn commit: r1072878 - in /esme/trunk/server/src/main: scala/org/apache/esme/model/Message.scala webapp/scripts/display_messages_top.js webapp/scripts/display_single_message.js

Author: rhirsch
Date: Mon Feb 21 08:25:17 2011
New Revision: 1072878

URL: http://svn.apache.org/viewvc?rev=1072878&view=rev
Log:
[ESME-295] Tags appear in the main timeline twice

Modified:
    esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
    esme/trunk/server/src/main/webapp/scripts/display_messages_top.js
    esme/trunk/server/src/main/webapp/scripts/display_single_message.js

Modified: esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala
URL: http://svn.apache.org/viewvc/esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala?rev=1072878&r1=1072877&r2=1072878&view=diff
==============================================================================
--- esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala (original)
+++ esme/trunk/server/src/main/scala/org/apache/esme/model/Message.scala Mon Feb 21 08:25:17 2011
@@ -529,8 +529,7 @@ class Message extends LongKeyedMapper[Me
               case Emph(text) => <xml:group> <em text={text}>_{text}_</em></xml:group>
               case Strong(text) => <xml:group> <strong text={text}>*{text}*</strong></xml:group>
             }
-          }</body>
-        <tags>{
+          }</body><tags>{
             ((lst.flatMap{case HashTag(t) => Full(t) case _ => Empty})
              ::: tags).distinct.map(_.toXml)
           }</tags>{

Modified: esme/trunk/server/src/main/webapp/scripts/display_messages_top.js
URL: http://svn.apache.org/viewvc/esme/trunk/server/src/main/webapp/scripts/display_messages_top.js?rev=1072878&r1=1072877&r2=1072878&view=diff
==============================================================================
--- esme/trunk/server/src/main/webapp/scripts/display_messages_top.js (original)
+++ esme/trunk/server/src/main/webapp/scripts/display_messages_top.js Mon Feb 21 08:25:17 2011
@@ -127,6 +127,16 @@ function clearMessages(elementId) {
   jQuery('.updates-box').not("#message").remove(); 
 }
 
+function parseXml(xml) {
+    if (jQuery.browser.msie) {
+    	  var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
+          xmlDoc.loadXML(xml);
+           xml = xmlDoc;    
+      }       
+  return xml;
+}
+
+
 function displayMessages(msgArray, elementId)
 {
 	
@@ -159,7 +169,18 @@ function displayMessages(msgArray, eleme
     if (jQuery('#'+elementId+' #'+msgId).size() == 0)
     {
       var msgAuthor = cometMsg.author;
-      var msgBody = jQuery(cometMsg.text).find('body').html();
+      var msgBody = null;
+      
+      // Dealing with an IE bug when parsing XML with jQuery
+      
+      if (jQuery.browser.msie) {
+      	var msgBodyXML = parseXml(cometMsg.text);
+        var msgBodyBase = jQuery(msgBodyXML).find('body');
+        msgBody = msgBodyBase[0].xml.replaceAll ("<body>", "").replaceAll ("</body>", ""); 
+      }
+      else
+      	msgBody = jQuery(cometMsg.text).find('body').html();
+      	
       var msgDateObj = new Date(parseInt(cometMsg.when));
       
       if (!msgBody)
@@ -200,8 +221,7 @@ function displayMessages(msgArray, eleme
       if (top.location.pathName == "/") 
       	  newMsg.find('.author').attr('href',"/user/" + msgAuthor.nickname );
      else
-      	 newMsg.find('.author').attr('href', window.location.pathname + "user/" + msgAuthor.nickname ); 
-     
+      	 newMsg.find('.author').attr('href', window.location.pathname + "user/" + msgAuthor.nickname );    
      
      
            // Dealing with users with no avatars
@@ -252,16 +272,6 @@ function displayMessages(msgArray, eleme
       } else {
         conversation.css("display", "none");
       }
-      for (var tagIndex=0; tagIndex < msgTags.length; tagIndex++) {
-        var newTag = tagTemplate.clone(true).attr('id',msgTags[tagIndex]);
-        newTag.find('a')
-        .attr('href','tag/'+msgTags[tagIndex])
-        .text(msgTags[tagIndex]);
-        newTag.insertBefore(newMsg.find('#tag:first'));
-      }
-
-      // Remove any old tags from the template
-      newMsg.find('*[id=tag]').remove();
 
       // Insert the updated copy of the message into the page
       newMsg.prependTo(msgInsertPt).show();

Modified: esme/trunk/server/src/main/webapp/scripts/display_single_message.js
URL: http://svn.apache.org/viewvc/esme/trunk/server/src/main/webapp/scripts/display_single_message.js?rev=1072878&r1=1072877&r2=1072878&view=diff
==============================================================================
--- esme/trunk/server/src/main/webapp/scripts/display_single_message.js (original)
+++ esme/trunk/server/src/main/webapp/scripts/display_single_message.js Mon Feb 21 08:25:17 2011
@@ -22,6 +22,38 @@
  * displayMessages called by lift:comet, type="Timeline" and type="PublicTimeline"
  */
  
+  // Replaces all instances of the given substring.
+String.prototype.replaceAll = function( 
+	strTarget, // The substring you want to replace
+	strSubString // The string you want to replace in.
+	){
+	var strText = this;
+	var intIndexOfMatch = strText.indexOf( strTarget );
+	 
+	// Keep looping while an instance of the target string
+	// still exists in the string.
+	while (intIndexOfMatch != -1){
+		// Relace out the current instance.
+		strText = strText.replace( strTarget, strSubString )
+		 
+		// Get the index of any next matching substring.
+		intIndexOfMatch = strText.indexOf( strTarget );
+	}
+	 
+	// Return the updated string with ALL the target strings
+	// replaced out with the new substring.
+	return( strText );
+} 
+
+function parseXml(xml) {
+    if (jQuery.browser.msie) {
+    	  var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
+          xmlDoc.loadXML(xml);
+           xml = xmlDoc;    
+      }       
+  return xml;
+}
+ 
 
 function login()
 {
@@ -71,7 +103,18 @@ function displayMessages(msgArray, eleme
     {
       var msgAuthor = cometMsg.author;
       var msgText = cometMsg.text
-      var msgBody = jQuery(cometMsg.text).find("body").html();
+      // Dealing with an IE bug when parsing XML with jQuery
+      
+      if (jQuery.browser.msie) {
+      	var msgBodyXML = parseXml(cometMsg.text);
+        var msgBodyBase = jQuery(msgBodyXML).find('body');
+        msgBody = msgBodyBase[0].xml.replaceAll ("<body>", "").replaceAll ("</body>", ""); 
+      }
+      else
+      	msgBody = jQuery(cometMsg.text).find('body').html();
+      
+      if (!msgBody)
+      	msgBody = cometMsg.text;
       
       if (!msgBody)
       	msgBody = cometMsg.text;