aboutsummaryrefslogtreecommitdiffstats
path: root/alias-angular/app/js/controllers.js
diff options
context:
space:
mode:
Diffstat (limited to 'alias-angular/app/js/controllers.js')
-rw-r--r--alias-angular/app/js/controllers.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/alias-angular/app/js/controllers.js b/alias-angular/app/js/controllers.js
index 1eb53e7..8768915 100644
--- a/alias-angular/app/js/controllers.js
+++ b/alias-angular/app/js/controllers.js
@@ -36,7 +36,7 @@ function ConnectCtl($scope, StropheSrv, $log, $rootScope) {
ConnectCtl.$inject = ['$scope', 'StropheSrv', '$log', '$rootScope'];
-function RosterCtl($scope, StropheSrv, $log) {
+function RosterCtl($scope, StropheSrv, $log, $rootScope) {
$scope.contacts = {};
$scope.get_contacts = function() {
return _.toArray($scope.contacts);
@@ -82,10 +82,26 @@ function RosterCtl($scope, StropheSrv, $log) {
$scope.getRoster();
});
- $scope.getRoster = function () {
+ $scope.getRoster = function() {
var query = $iq({type : 'get'}).c('query', {xmlns : Strophe.NS.ROSTER});
StropheSrv.sendIQ(query, onRoster);
};
+
+ $scope.chatWith = function(contact) {
+ $rootScope.$broadcast('msgrequest', {jid: contact.jid, name:contact.name});
+ };
}
-RosterCtl.$inject = ['$scope','StropheSrv','$log'];
+RosterCtl.$inject = ['$scope','StropheSrv','$log', '$rootScope'];
+
+function MsgCtl($scope, $log) {
+ $scope.conversations = [];
+ $scope.$on('msgrequest', function(event, contact){
+ $log.log(contact);
+ if (_.indexOf($scope.conversations, contact)) {
+ $scope.conversations.push(contact);
+ }
+ });
+}
+
+MsgCtl.$inject = ['$scope','$log']; \ No newline at end of file