Browse Source

Prepare refactoring.

pull/108/head
Simon Eisenmann 11 years ago
parent
commit
682be4df63
  1. 5
      static/js/controllers/mediastreamcontroller.js
  2. 6
      static/js/controllers/roomchangecontroller.js
  3. 4
      static/js/directives/roombar.js
  4. 32
      static/js/services/mediastream.js

5
static/js/controllers/mediastreamcontroller.js

@ -328,7 +328,10 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'webrtc.adapte @@ -328,7 +328,10 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'webrtc.adapte
$scope.update($scope.user);
$scope.loadedUser = storedUser.displayName && true;
// Add room definition to root to be availale on initial connect.
$rootScope.roomid = $scope.user.settings.defaultRoom || "";
//$rootScope.roomid = $scope.user.settings.defaultRoom || "";
/*if (!$rootScope.roomid && $scope.user.settings.defaultRoom) {
$rootScope.roomid = $scope.user.settings.defaultRoom;
}*/
} else {
$scope.loadedUser = false;
}

6
static/js/controllers/roomchangecontroller.js

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
define([], function() {
// RoomchangeController
return ["$scope", "$element", "$window", "$location", "mediaStream", "$http", "$timeout", function($scope, $element, $window, $location, mediaStream, $http, $timeout) {
return ["$scope", "$element", "$window", "mediaStream", "$http", "$timeout", function($scope, $element, $window, mediaStream, $http, $timeout) {
//console.log("Room change controller", $element, $scope.roomdata);
@ -49,9 +49,7 @@ define([], function() { @@ -49,9 +49,7 @@ define([], function() {
};
$scope.changeRoomToId = function(id) {
var roomid = $window.encodeURIComponent(id);
$location.path("/" + roomid);
return roomid;
return mediaStream.changeRoom(id);
};
$scope.refreshRoom = function() {

4
static/js/directives/roombar.js

@ -21,7 +21,7 @@ @@ -21,7 +21,7 @@
define(['underscore', 'text!partials/roombar.html'], function(_, template) {
// roomBar
return ["$window", "$rootScope", "$location", function($window, $rootScope, $location) {
return ["$window", "$rootScope", "mediaStream", function($window, $rootScope, mediaStream) {
var link = function($scope) {
@ -30,7 +30,7 @@ define(['underscore', 'text!partials/roombar.html'], function(_, template) { @@ -30,7 +30,7 @@ define(['underscore', 'text!partials/roombar.html'], function(_, template) {
$scope.hideRoomBar = true;
$scope.save = function() {
var roomid = $scope.changeRoomToId($scope.newroomid);
var roomid = mediaStream.changeRoom($scope.newroomid);
if (roomid !== $rootScope.roomid) {
$scope.roombarform.$setPristine();
}

32
static/js/services/mediastream.js

@ -30,7 +30,7 @@ define([ @@ -30,7 +30,7 @@ define([
], function($, _, uaparser, Modernizr, Connector, Api, WebRTC, tokens) {
return ["globalContext", "$route", "$location", "$window", "visibility", "alertify", "$http", "safeApply", "$timeout", "$sce", "localStorage", "continueConnector", function(context, $route, $location, $window, visibility, alertify, $http, safeApply, $timeout, $sce, localStorage, continueConnector) {
return ["globalContext", "$rootScope", "$route", "$location", "$window", "visibility", "alertify", "$http", "safeApply", "$timeout", "$sce", "localStorage", "continueConnector", function(context, $rootScope, $route, $location, $window, visibility, alertify, $http, safeApply, $timeout, $sce, localStorage, continueConnector) {
var url = (context.Ssl ? "wss" : "ws") + "://" + context.Host + (context.Cfg.B || "/") + "ws";
var version = context.Cfg.Version || "unknown";
@ -215,6 +215,16 @@ define([ @@ -215,6 +215,16 @@ define([
}
});
},
changeRoom: function(id, replace) {
id = $window.encodeURIComponent(id);
safeApply($rootScope, function(scope) {
$location.path("/" + id);
if (replace) {
$location.replace();
}
});
return id;
},
initialize: function($rootScope, translation) {
var cont = false;
@ -242,12 +252,6 @@ define([ @@ -242,12 +252,6 @@ define([
}
};
$window.changeRoom = function(room) {
$rootScope.$apply(function(scope) {
$location.path("/" + room).replace();
});
};
var title = (function(e) {
return {
element: e,
@ -257,8 +261,7 @@ define([ @@ -257,8 +261,7 @@ define([
// Room selector.
$rootScope.$on("$locationChangeSuccess", function(event) {
//console.log("location change", $route, $rootScope.roomid);
var defaultRoom, room;
/*var defaultRoom, room;
room = defaultRoom = $rootScope.roomid || "";
if ($route.current) {
room = $route.current.params.room;
@ -269,8 +272,14 @@ define([ @@ -269,8 +272,14 @@ define([
// First start.
$location.path("/" + defaultRoom).replace();
return;
}*/
var room;
if ($route.current) {
room = $route.current.params.room;
} else {
room = "";
}
console.info("Selected room is:", [room]);
console.info("Selected room is:", [room], ready, cont);
if (!ready || !cont) {
ready = true;
connector.roomid = room;
@ -378,6 +387,9 @@ define([ @@ -378,6 +387,9 @@ define([
}
};
// For debugging.
$window.changeRoom = mediaStream.changeRoom;
return mediaStream;
}];

Loading…
Cancel
Save