aboutsummaryrefslogtreecommitdiffstats
path: root/app/js
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@gmail.com>2012-04-02 02:13:32 -0400
committerGuillaume Horel <guillaume.horel@gmail.com>2012-04-02 02:13:32 -0400
commit9b142c6dc7d5736acc45142a5d42c4511fc49edc (patch)
treec236e9ec0dcc67e6809bd7addad012e41d5bf9b7 /app/js
parenta5edfb4b0a960307cdabcfab87d8bdae94f06b74 (diff)
downloadalias-9b142c6dc7d5736acc45142a5d42c4511fc49edc.tar.gz
new angular branch
Diffstat (limited to 'app/js')
-rw-r--r--app/js/app.js10
-rw-r--r--app/js/controllers.js21
-rw-r--r--app/js/directives.js10
-rw-r--r--app/js/filters.js9
-rw-r--r--app/js/services.js23
5 files changed, 73 insertions, 0 deletions
diff --git a/app/js/app.js b/app/js/app.js
new file mode 100644
index 0000000..795f1db
--- /dev/null
+++ b/app/js/app.js
@@ -0,0 +1,10 @@
+'use strict';
+
+
+// Declare app level module which depends on filters, and services
+angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives']).
+ config(['$routeProvider', function($routeProvider) {
+ $routeProvider.when('/view1', {template: 'partials/partial1.html', controller: MyCtrl1});
+ $routeProvider.when('/view2', {template: 'partials/partial2.html', controller: MyCtrl2});
+ $routeProvider.otherwise({redirectTo: '/view1'});
+ }]);
diff --git a/app/js/controllers.js b/app/js/controllers.js
new file mode 100644
index 0000000..4199c7f
--- /dev/null
+++ b/app/js/controllers.js
@@ -0,0 +1,21 @@
+'use strict';
+/* App Controllers */
+
+function RosterCtl($scope, connection) {
+ $scope.contacts = [];
+ $scope.init = function() {
+ var query = $iq({type : 'get'}).c('query', {xmlns : Strophe.NS.ROSTER});
+ connection.sendIQ(query, success);
+ };
+ $scope.onRoster = function(iq) {
+ var elems = iq.getElementsByTagName('query');
+ var query = elems[0];
+ Strophe.forEachChild(query, 'item', function(item){
+ var jid = item.getAttribute('jid');
+ var name = item.getAttribute('name') || jid;
+ $scope.contacts.push(name);
+ });
+ return true;
+ };
+};
+RosterCtl.$inject = ['$scope','connection']; \ No newline at end of file
diff --git a/app/js/directives.js b/app/js/directives.js
new file mode 100644
index 0000000..8ed47bb
--- /dev/null
+++ b/app/js/directives.js
@@ -0,0 +1,10 @@
+'use strict';
+/* http://docs-next.angularjs.org/api/angular.module.ng.$compileProvider.directive */
+
+
+angular.module('myApp.directives', []).
+ directive('appVersion', ['version', function(version) {
+ return function(scope, elm, attrs) {
+ elm.text(version);
+ };
+ }]);
diff --git a/app/js/filters.js b/app/js/filters.js
new file mode 100644
index 0000000..ef89b6b
--- /dev/null
+++ b/app/js/filters.js
@@ -0,0 +1,9 @@
+'use strict';
+/* http://docs-next.angularjs.org/api/angular.module.ng.$filter */
+
+angular.module('myApp.filters', []).
+ filter('interpolate', ['version', function(version) {
+ return function(text) {
+ return String(text).replace(/\%VERSION\%/mg, version);
+ }
+ }]);
diff --git a/app/js/services.js b/app/js/services.js
new file mode 100644
index 0000000..1b1882e
--- /dev/null
+++ b/app/js/services.js
@@ -0,0 +1,23 @@
+'use strict';
+
+angular.module('Alias.services', [], function($provide) {
+$provide.factory('connection',
+ ['$log', function($log) {
+ function connect_callback(status){
+ if ( status == Strophe.Status.CONNECTING ) {
+ $log('Strophe is connecting.');
+ } else if ( status == Strophe.Status.CONNFAIL ) {
+ $log('Strophe failed to connect.');
+ } else if ( status == Strophe.Status.DISCONNECTING ) {
+ $log('Strophe is disconnecting.');
+ } else if ( status == Strophe.Status.DISCONNECTED ) {
+ $dev.log('Strophe is disconnected.');
+ } else if ( status == Strophe.Status.CONNECTED ) {
+ $log('Strophe is connected.');
+ }
+ };
+ var connection = new Strophe.Connection(BOSH_SERVICE);
+ connection.connect(NAME, PASSWORD, connect_callback);
+ return connection;
+ }]);
+}); \ No newline at end of file