|
|
@ -20,21 +20,13 @@ |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
"use strict"; |
|
|
|
"use strict"; |
|
|
|
define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'webrtc.adapter'], function($, _, angular, BigScreen, moment, sjcl, Modernizr) { |
|
|
|
define(['jquery', 'underscore', 'bigscreen', 'moment', 'sjcl', 'modernizr', 'webrtc.adapter'], function($, _, BigScreen, moment, sjcl, Modernizr) { |
|
|
|
|
|
|
|
|
|
|
|
return ["$scope", "$rootScope", "$element", "$window", "$timeout", "safeDisplayName", "safeApply", "mediaStream", "appData", "playSound", "desktopNotify", "alertify", "toastr", "translation", "fileDownload", "localStorage", "screensharing", "userSettingsData", "localStatus", "dialogs", "rooms", "constraints", function($scope, $rootScope, $element, $window, $timeout, safeDisplayName, safeApply, mediaStream, appData, playSound, desktopNotify, alertify, toastr, translation, fileDownload, localStorage, screensharing, userSettingsData, localStatus, dialogs, rooms, constraints) { |
|
|
|
return ["$scope", "$rootScope", "$element", "$window", "$timeout", "safeDisplayName", "safeApply", "mediaStream", "appData", "playSound", "desktopNotify", "alertify", "toastr", "translation", "fileDownload", "localStorage", "screensharing", "localStatus", "dialogs", "rooms", "constraints", function($scope, $rootScope, $element, $window, $timeout, safeDisplayName, safeApply, mediaStream, appData, playSound, desktopNotify, alertify, toastr, translation, fileDownload, localStorage, screensharing, localStatus, dialogs, rooms, constraints) { |
|
|
|
|
|
|
|
|
|
|
|
/*console.log("route", $route, $routeParams, $location);*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Disable drag and drop.
|
|
|
|
|
|
|
|
$($window).on("dragover dragenter drop", function(event) { |
|
|
|
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Avoid accidential reloads or exits when in a call.
|
|
|
|
// Avoid accidential reloads or exits when in a call.
|
|
|
|
var manualUnload = false; |
|
|
|
|
|
|
|
$($window).on("beforeunload", function(event) { |
|
|
|
$($window).on("beforeunload", function(event) { |
|
|
|
if (manualUnload || !$scope.peer) { |
|
|
|
if (appData.flags.manualUnload || !$scope.peer) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
return translation._("Close this window and disconnect?"); |
|
|
|
return translation._("Close this window and disconnect?"); |
|
|
@ -93,8 +85,6 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder |
|
|
|
"prompt": "question1" |
|
|
|
"prompt": "question1" |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
appData.set($scope); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var displayName = safeDisplayName; |
|
|
|
var displayName = safeDisplayName; |
|
|
|
|
|
|
|
|
|
|
|
// Init STUN from server config.
|
|
|
|
// Init STUN from server config.
|
|
|
@ -112,7 +102,7 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder |
|
|
|
$scope.supported = { |
|
|
|
$scope.supported = { |
|
|
|
screensharing: screensharing.supported, |
|
|
|
screensharing: screensharing.supported, |
|
|
|
constraints: constraints.supported |
|
|
|
constraints: constraints.supported |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// Default scope data.
|
|
|
|
// Default scope data.
|
|
|
|
$scope.status = "initializing"; |
|
|
|
$scope.status = "initializing"; |
|
|
@ -132,50 +122,6 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder |
|
|
|
$scope.chatMessagesUnseen = 0; |
|
|
|
$scope.chatMessagesUnseen = 0; |
|
|
|
$scope.autoAccept = null; |
|
|
|
$scope.autoAccept = null; |
|
|
|
$scope.isCollapsed = true; |
|
|
|
$scope.isCollapsed = true; |
|
|
|
$scope.roomsHistory = []; |
|
|
|
|
|
|
|
$scope.defaults = { |
|
|
|
|
|
|
|
displayName: null, |
|
|
|
|
|
|
|
buddyPicture: null, |
|
|
|
|
|
|
|
message: null, |
|
|
|
|
|
|
|
settings: { |
|
|
|
|
|
|
|
videoQuality: "high", |
|
|
|
|
|
|
|
sendStereo: false, |
|
|
|
|
|
|
|
maxFrameRate: 20, |
|
|
|
|
|
|
|
defaultRoom: "", |
|
|
|
|
|
|
|
language: "", |
|
|
|
|
|
|
|
audioRenderToAssociatedSkin: true, |
|
|
|
|
|
|
|
videoCpuOveruseDetection: true, |
|
|
|
|
|
|
|
experimental: { |
|
|
|
|
|
|
|
enabled: false, |
|
|
|
|
|
|
|
audioEchoCancellation2: true, |
|
|
|
|
|
|
|
audioAutoGainControl2: true, |
|
|
|
|
|
|
|
audioNoiseSuppression2: true, |
|
|
|
|
|
|
|
audioTypingNoiseDetection: true, |
|
|
|
|
|
|
|
videoLeakyBucket: true, |
|
|
|
|
|
|
|
videoNoiseReduction: false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
$scope.master = angular.copy($scope.defaults); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Data voids.
|
|
|
|
|
|
|
|
var resurrect = null; |
|
|
|
|
|
|
|
var reconnecting = false; |
|
|
|
|
|
|
|
var connected = false; |
|
|
|
|
|
|
|
var autoreconnect = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.update = function(user) { |
|
|
|
|
|
|
|
$scope.master = angular.copy(user); |
|
|
|
|
|
|
|
if (connected) { |
|
|
|
|
|
|
|
$scope.updateStatus(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$scope.refreshWebrtcSettings(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.reset = function() { |
|
|
|
|
|
|
|
$scope.user = angular.copy($scope.master); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
$scope.reset(); // Call once for bootstrap.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.setStatus = function(status) { |
|
|
|
$scope.setStatus = function(status) { |
|
|
|
// This is the connection status to signaling server.
|
|
|
|
// This is the connection status to signaling server.
|
|
|
@ -230,34 +176,6 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$scope.manualReloadApp = function(url) { |
|
|
|
|
|
|
|
manualUnload = true; |
|
|
|
|
|
|
|
if (url) { |
|
|
|
|
|
|
|
$window.location.href = url; |
|
|
|
|
|
|
|
$timeout(function() { |
|
|
|
|
|
|
|
manualUnload = false; |
|
|
|
|
|
|
|
}, 0); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$window.location.reload(true); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.loadUserSettings = function() { |
|
|
|
|
|
|
|
$scope.master = angular.copy($scope.defaults); |
|
|
|
|
|
|
|
var storedUser = userSettingsData.load(); |
|
|
|
|
|
|
|
if (storedUser) { |
|
|
|
|
|
|
|
$scope.user = $.extend(true, {}, $scope.master, storedUser); |
|
|
|
|
|
|
|
$scope.user.settings = $.extend(true, {}, $scope.user.settings, $scope.master.settings, $scope.user.settings); |
|
|
|
|
|
|
|
$scope.update($scope.user); |
|
|
|
|
|
|
|
$scope.loadedUser = storedUser.displayName && true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$scope.loadedUser = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$scope.roomsHistory = []; |
|
|
|
|
|
|
|
appData.e.triggerHandler("userSettingsLoaded", [$scope.loadedUser, $scope.user]); |
|
|
|
|
|
|
|
$scope.reset(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$scope.toggleBuddylist = (function() { |
|
|
|
$scope.toggleBuddylist = (function() { |
|
|
|
var oldState = null; |
|
|
|
var oldState = null; |
|
|
|
return function(status, force) { |
|
|
|
return function(status, force) { |
|
|
@ -364,9 +282,9 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Support resurrection shrine.
|
|
|
|
// Support resurrection shrine.
|
|
|
|
if (resurrect) { |
|
|
|
if (appData.flags.resurrect) { |
|
|
|
var resurrection = resurrect; |
|
|
|
var resurrection = appData.flags.resurrect; |
|
|
|
resurrect = null; |
|
|
|
appData.flags.resurrect = null; |
|
|
|
$timeout(function() { |
|
|
|
$timeout(function() { |
|
|
|
if (resurrection.id === $scope.id) { |
|
|
|
if (resurrection.id === $scope.id) { |
|
|
|
console.log("Using resurrection shrine", resurrection); |
|
|
|
console.log("Using resurrection shrine", resurrection); |
|
|
@ -489,25 +407,32 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder |
|
|
|
alertify.dialog.alert(translation._("Oops") + "<br/>" + message); |
|
|
|
alertify.dialog.alert(translation._("Oops") + "<br/>" + message); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
appData.flags.autoreconnect = true; |
|
|
|
|
|
|
|
appData.flags.autoreconnectDelay = 0; |
|
|
|
|
|
|
|
|
|
|
|
var reconnect = function() { |
|
|
|
var reconnect = function() { |
|
|
|
if (connected && autoreconnect) { |
|
|
|
if (appData.flags.connected && appData.flags.autoreconnect) { |
|
|
|
if (resurrect === null) { |
|
|
|
if (appData.flags.resurrect === null) { |
|
|
|
// Storage data at the resurrection shrine.
|
|
|
|
// Storage data at the resurrection shrine.
|
|
|
|
resurrect = { |
|
|
|
appData.flags.resurrect = { |
|
|
|
status: $scope.getStatus(), |
|
|
|
status: $scope.getStatus(), |
|
|
|
id: $scope.id |
|
|
|
id: $scope.id |
|
|
|
} |
|
|
|
} |
|
|
|
console.log("Stored data at the resurrection shrine", resurrect); |
|
|
|
console.log("Stored data at the resurrection shrine", appData.flags.resurrect); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!appData.flags.reconnecting) { |
|
|
|
|
|
|
|
var delay = appData.flags.autoreconnectDelay; |
|
|
|
|
|
|
|
if (delay < 10000) { |
|
|
|
|
|
|
|
appData.flags.autoreconnectDelay += 500; |
|
|
|
} |
|
|
|
} |
|
|
|
if (!reconnecting) { |
|
|
|
appData.flags.reconnecting = true; |
|
|
|
reconnecting = true; |
|
|
|
|
|
|
|
_.delay(function() { |
|
|
|
_.delay(function() { |
|
|
|
if (autoreconnect) { |
|
|
|
if (appData.flags.autoreconnect) { |
|
|
|
console.log("Requesting to reconnect ..."); |
|
|
|
console.log("Requesting to reconnect ..."); |
|
|
|
mediaStream.reconnect(); |
|
|
|
mediaStream.reconnect(); |
|
|
|
} |
|
|
|
} |
|
|
|
reconnecting = false; |
|
|
|
appData.flags.reconnecting = false; |
|
|
|
}, 500); |
|
|
|
}, delay); |
|
|
|
$scope.setStatus("reconnecting"); |
|
|
|
$scope.setStatus("reconnecting"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
console.warn("Already reconnecting ..."); |
|
|
|
console.warn("Already reconnecting ..."); |
|
|
@ -526,12 +451,13 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder |
|
|
|
$scope.userid = $scope.suserid = null; |
|
|
|
$scope.userid = $scope.suserid = null; |
|
|
|
switch (event.type) { |
|
|
|
switch (event.type) { |
|
|
|
case "open": |
|
|
|
case "open": |
|
|
|
connected = true; |
|
|
|
appData.flags.connected = true; |
|
|
|
|
|
|
|
appData.flags.autoreconnectDelay = 0; |
|
|
|
$scope.updateStatus(true); |
|
|
|
$scope.updateStatus(true); |
|
|
|
$scope.setStatus("waiting"); |
|
|
|
$scope.setStatus("waiting"); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case "error": |
|
|
|
case "error": |
|
|
|
if (connected) { |
|
|
|
if (appData.flags.connected) { |
|
|
|
reconnect(); |
|
|
|
reconnect(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$scope.setStatus(event.type); |
|
|
|
$scope.setStatus(event.type); |
|
|
@ -768,17 +694,6 @@ define(['jquery', 'underscore', 'angular', 'bigscreen', 'moment', 'sjcl', 'moder |
|
|
|
$scope.chatMessagesUnseen = $scope.chatMessagesUnseen - count; |
|
|
|
$scope.chatMessagesUnseen = $scope.chatMessagesUnseen - count; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$scope.$on("room.joined", function(event, roomName) { |
|
|
|
|
|
|
|
if (roomName) { |
|
|
|
|
|
|
|
_.pull($scope.roomsHistory, roomName); |
|
|
|
|
|
|
|
$scope.roomsHistory.unshift(roomName); |
|
|
|
|
|
|
|
if ($scope.roomsHistory.length > 15) { |
|
|
|
|
|
|
|
// Limit the history.
|
|
|
|
|
|
|
|
$scope.roomsHistory = $scope.roomsHistory.splice(0, 15); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_.defer(function() { |
|
|
|
_.defer(function() { |
|
|
|
if (!Modernizr.websockets) { |
|
|
|
if (!Modernizr.websockets) { |
|
|
|
alertify.dialog.alert(translation._("Your browser is not supported. Please upgrade to a current version.")); |
|
|
|
alertify.dialog.alert(translation._("Your browser is not supported. Please upgrade to a current version.")); |
|
|
|