forked from Aberrant-Marble/Aberrant-Marble
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.html
139 lines (125 loc) · 5.05 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<!DOCTYPE html>
<html ng-app='languageApp'>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- inject:css -->
<link rel="stylesheet" href="./client/css/bower.css">
<!-- endinject -->
<script type='text/javascript' src='http://cdn.icecomm.io/icecomm.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- inject:js -->
<script src="./client/js/vendors.js"></script>
<script src="./client/js/app.js"></script>
<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script>
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
console.log('c.substring(name.length,c.length)', c.substring(name.length,c.length));
return c.substring(name.length,c.length);
}
}
return "";
}
window.myId = parseInt(getCookie('u_id'));
</script>
<!-- endinject -->
</head>
<body ng-controller='selectLanguageController'>
<div ui-view class="view"></div>
<div id="videos">
<div id='myVideo' class="inline">
<video id='localVideo' autoplay></video>
</div>
</div>
<form class="form-horizontal" id='chatApp' style="display: none">
<div class="form-group">
<textarea class="form-control" id='chatBox' readonly ng-model='convo'>.fgfsdfas</textarea><br>
<input class="form-control inline" id='chatMsg' type='text' ng-keypress='handleKeyPress($event)' ng-model='msg'>
<button class="btn btn-primary inline" ng-click='sendMsg()'>Send</button>
</div>
</form>
<div ng-include="'./client/footer.html'"></div>
<script src="/bower_components/angular-ui-router/release/angular-ui-router.js"></script>
<script src="/bower_components/angular-bootstrap/ui-bootstrap.js"></script>
<script>
var socket = io();
var comm = new Icecomm('aOeyDUCGOSgnxElKI9eHiq9SRh2afLql1l1lDyxzYMYEabvTF6');
window.comm = comm;
socket.on('session', function (data) {
window.sessionStorage.setItem('event.sid', data);
document.cookie = 'event.sid=s%3A' + data;
});
socket.on('close', function (data) {
console.log('END IN CLIENT');
$('#videos').remove();
$('#chatBox').remove();
$('.btn-warning').remove();
$('#chatApp').remove()
comm.close();
});
socket.on('joinRoom', function (data) {
comm.connect(data);
window.roomId = data;
comm.on('local', function (options) {
console.log(options.stream);
$('#localVideo').attr("src", options.stream);
});
// When two people are connected, display the video of the language partner
// and show the chat app
comm.on('connected', function (options) {
var foreignVidDiv = $('<div class="inline"></div>');
foreignVidDiv.append(options.video)
foreignVidDiv.children().addClass('foreignVideo');
$('#videos').prepend(foreignVidDiv);
$('#chatApp').css('display', 'block');
$('.btn-warning').css('display', 'block');
});
});
socket.on('connecting', function (data) {
comm.connect(data.room);
window.roomId = data.room;
socket.emit('roomRequest', data);
// Show video of the user
comm.on('local', function (options) {
console.log(options.stream);
$('#localVideo').attr("src", options.stream);
});
// When two people are connected, display the video of the language partner
// and show the chat app
comm.on('connected', function (options) {
var foreignVidDiv = $('<div class="inline"></div>');
foreignVidDiv.append(options.video)
foreignVidDiv.children().addClass('foreignVideo');
$('#videos').prepend(foreignVidDiv);
$('#chatApp').css('display', 'block');
});
// // When a chat message is received from the language partner,
// // translate the message using Google Translate and
// // display both the original message and the translated message
comm.on('data', function (options) {
console.log('options', options);
$('#chatBox').text('Them: ' + options.data + '\n');
// $scope.$apply(function(){
// Translate.translateMsg(options.data, $scope.language.native, $scope.language.desired)
// .then(function (translatedMsg) {
// console.log(translatedMsg);
// var translatedText = translatedMsg.data.translations[0].translatedText
// $scope.convo += 'Them: ' + options.data + '\n';
// $scope.convo += 'Them (translated): ' + translatedText + '\n';
// $scope.scrollBottom();
// })
// });
});
});
</script>
</body>
</html>