mirror of
				https://github.com/nerzhul/ocsms.git
				synced 2025-10-31 10:27:42 +00:00 
			
		
		
		
	JS: initialPeerList is now generated by angular.js
This commit is contained in:
		
							parent
							
								
									13e3d47620
								
							
						
					
					
						commit
						c1f984b2de
					
				
							
								
								
									
										25
									
								
								js/script.js
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								js/script.js
									
									
									
									
									
								
							| @ -32,7 +32,17 @@ app.controller('OcSmsController', ['$scope', | |||||||
| 			$.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()}); | 			$.post(OC.generateUrl('/apps/ocsms/set/country'),{'country': $('select[name=intl_phone]').val()}); | ||||||
| 		}; | 		}; | ||||||
| 		$scope.loadConversation = function () { | 		$scope.loadConversation = function () { | ||||||
| 			alert('loadConversation'); | 			//@TODO
 | ||||||
|  | 		}; | ||||||
|  | 		$scope.replaceContacts = function (ctList) { | ||||||
|  | 			$scope.$apply(function () { | ||||||
|  | 				$scope.contacts = ctList; | ||||||
|  | 			}); | ||||||
|  | 		}; | ||||||
|  | 		$scope.addContact = function (ct) { | ||||||
|  | 			$scope.$apply(function () { | ||||||
|  | 				$scope.contacts.push(ct); | ||||||
|  | 			}); | ||||||
| 		}; | 		}; | ||||||
| 	} | 	} | ||||||
| ]); | ]); | ||||||
| @ -297,6 +307,8 @@ function fetchInitialPeerList(jsondata) { | |||||||
| 
 | 
 | ||||||
| 	var bufferedContacts = []; | 	var bufferedContacts = []; | ||||||
| 
 | 
 | ||||||
|  | 	var aScope = angular.element('[ng-controller="OcSmsController"]').scope(); | ||||||
|  | 
 | ||||||
| 	$.each(jsondata['phonelist'], function(id, val) { | 	$.each(jsondata['phonelist'], function(id, val) { | ||||||
| 		var fn, peerLabel, idxVal; | 		var fn, peerLabel, idxVal; | ||||||
| 		idxVal = id.replace(/\//g,' '); | 		idxVal = id.replace(/\//g,' '); | ||||||
| @ -310,21 +322,12 @@ function fetchInitialPeerList(jsondata) { | |||||||
| 			peerLabel = fn; | 			peerLabel = fn; | ||||||
| 		} | 		} | ||||||
| 		if ($.inArray(peerLabel, bufferedContacts) == -1) { | 		if ($.inArray(peerLabel, bufferedContacts) == -1) { | ||||||
| 			peerListBuf += '<li peer-label="' + peerLabel + '"><div class="ocsms-plavatar"'; | 			aScope.addContact({'label': peerLabel, 'nav': idxVal2, 'avatar': jsondata['photos'][peerLabel]}); | ||||||
| 			if (typeof jsondata['photos'][peerLabel] != 'undefined') { |  | ||||||
| 				peerListBuf += 'style="background-image: url(' + jsondata['photos'][peerLabel] + ');"'; |  | ||||||
| 			} |  | ||||||
| 			peerListBuf += '></div><a href="#" ng-click="loadConversation();" mailbox-navigation="' + idxVal2 + '" mailbox-label="' + peerLabel + '">' + peerLabel + '</a></li>'; |  | ||||||
| 			bufferedContacts.push(peerLabel); | 			bufferedContacts.push(peerLabel); | ||||||
| 		} | 		} | ||||||
| 	}); | 	}); | ||||||
| 
 | 
 | ||||||
| 	lastMsgDate = jsondata["lastRead"]; | 	lastMsgDate = jsondata["lastRead"]; | ||||||
| 
 |  | ||||||
| 	// Only modify peerList if there is peers
 |  | ||||||
| 	if (peerListBuf != '') { |  | ||||||
| 		$('#app-mailbox-peers ul').html(peerListBuf); |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function initDesktopNotifies() { | function initDesktopNotifies() { | ||||||
|  | |||||||
| @ -10,8 +10,8 @@ use \OCA\OcSms\Lib\CountryCodes; | |||||||
| <div class="ng-scope" id="app" ng-app="OcSms" ng-controller="OcSmsController"> | <div class="ng-scope" id="app" ng-app="OcSms" ng-controller="OcSmsController"> | ||||||
| 	<div id="app-mailbox-peers"> | 	<div id="app-mailbox-peers"> | ||||||
| 		<ul> | 		<ul> | ||||||
| 			<li ng-repeat="contact in contacts"> | 			<li ng-repeat="contact in contacts" peer-label="{{ contact.label }}"> | ||||||
| 				<div class="ocsms-plavatar"></div> | 				<div class="ocsms-plavatar" style="background-image: url('{{ contact.avatar }}');"></div> | ||||||
| 				<a mailbox-label="{{ contact.label }}" mailbox-navigation="{{ contact.nav }}" ng-click="loadConversation();" href="#">{{ contact.label }}</a> | 				<a mailbox-label="{{ contact.label }}" mailbox-navigation="{{ contact.nav }}" ng-click="loadConversation();" href="#">{{ contact.label }}</a> | ||||||
| 			</li> | 			</li> | ||||||
| 		</ul> | 		</ul> | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user