mirror of
				https://github.com/nerzhul/ocsms.git
				synced 2025-10-28 00:49:11 +00:00 
			
		
		
		
	use a div for each message with a typed class
This commit is contained in:
		
							parent
							
								
									7fbfb93bfb
								
							
						
					
					
						commit
						5667cbdac1
					
				
							
								
								
									
										15
									
								
								js/script.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								js/script.js
									
									
									
									
									
								
							| @ -12,10 +12,23 @@ function fetchConversation(phoneNumber) { | |||||||
| 	$.getJSON(OC.generateUrl('/apps/ocsms/get/conversation'), | 	$.getJSON(OC.generateUrl('/apps/ocsms/get/conversation'), | ||||||
| 		{'phoneNumber': phoneNumber}, | 		{'phoneNumber': phoneNumber}, | ||||||
| 		function(jsondata, status) { | 		function(jsondata, status) { | ||||||
|  | 			// Improve jQuery performance
 | ||||||
| 			var conversationBuf = ""; | 			var conversationBuf = ""; | ||||||
|  | 			// Improve JS performance
 | ||||||
|  | 			var msgClass = ''; | ||||||
| 
 | 
 | ||||||
| 			$.each(jsondata["conversation"], function(id, vals) { | 			$.each(jsondata["conversation"], function(id, vals) { | ||||||
| 				conversationBuf += vals["msg"] + "<br />"; | 				if (vals["type"] == 1) { | ||||||
|  | 					msgClass = "msg-recv"; | ||||||
|  | 				} | ||||||
|  | 				else if (vals["type"] == 2) { | ||||||
|  | 					msgClass = "msg-sent"; | ||||||
|  | 				} | ||||||
|  | 				else { | ||||||
|  | 					msgClass = ''; | ||||||
|  | 				} | ||||||
|  | 
 | ||||||
|  | 				conversationBuf += '<div class="' + msgClass + '">' + vals["msg"] + '</div>'; | ||||||
| 			}); | 			}); | ||||||
| 
 | 
 | ||||||
| 			$('#app-content').html(conversationBuf); | 			$('#app-content').html(conversationBuf); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user