From 4f475c7697722e946e39e42f38f3dd03a95d8765 Mon Sep 17 00:00:00 2001 From: "matrix.org" Date: Tue, 12 Aug 2014 15:10:52 +0100 Subject: Reference Matrix Home Server --- webclient/app.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 webclient/app.js (limited to 'webclient/app.js') diff --git a/webclient/app.js b/webclient/app.js new file mode 100644 index 0000000000..2a75560edd --- /dev/null +++ b/webclient/app.js @@ -0,0 +1,57 @@ +var matrixWebClient = angular.module('matrixWebClient', [ + 'ngRoute', + 'MatrixWebClientController', + 'LoginController', + 'RoomController', + 'RoomsController', + 'matrixService' +]); + +matrixWebClient.config(['$routeProvider', + function($routeProvider) { + $routeProvider. + when('/login', { + templateUrl: 'login/login.html', + controller: 'LoginController' + }). + when('/room/:room_id', { + templateUrl: 'room/room.html', + controller: 'RoomController' + }). + when('/rooms', { + templateUrl: 'rooms/rooms.html', + controller: 'RoomsController' + }). + otherwise({ + redirectTo: '/rooms' + }); + }]); + +matrixWebClient.run(['$location', 'matrixService' , function($location, matrixService) { + // If we have no persistent login information, go to the login page + var config = matrixService.config(); + if (!config || !config.access_token) { + $location.path("login"); + } +}]); + +matrixWebClient + .directive('ngEnter', function () { + return function (scope, element, attrs) { + element.bind("keydown keypress", function (event) { + if(event.which === 13) { + scope.$apply(function () { + scope.$eval(attrs.ngEnter); + }); + event.preventDefault(); + } + }); + }; + }) + .directive('ngFocus', ['$timeout', function($timeout) { + return { + link: function(scope, element, attr) { + $timeout(function() { element[0].focus() }, 0); + } + }; + }]); -- cgit 1.4.1