-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
315 lines (303 loc) · 9.81 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<!-- TODO: Image streaming over websockets, Dragging API and ChartJS in Unity Finance -->
<meta charset="utf-8">
<title>SPOTLIGHT Chat</title>
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/element-ui.css">
<link href="https://fonts.googleapis.com/css?family=Lora|Source+Code+Pro" rel="stylesheet">
<style>
.el-header {
background-color: #B3C0D1;
color: #333;
line-height: 60px;
}
.divider {
border:1px solid #9116ca;
height:100%;
position:absolute;
right:53%;
width: 1px;
}
.login-layout {
margin-right: 10px;
}
.register-layout {
margin-left: 10px;
}
.el-aside {
color: #333;
}
.intro-dialog {
/* background: linear-gradient(#6cf59f, #007bff) */
background-image: url(imgs/blurred-phone-bg.jpg);
background-size: cover;
background-repeat: no-repeat;
background-position: center;
opacity: 1;
/* filter: blur(8px);
-webkit-filter: blur(8px); */
}
.title {
font-size: 32px;
font-weight: bold;
color: black;
}
.subtitle {
color: white;
}
.el-dialog__header {
background: white;
font-family: 'Source Code Pro', monospace;;
}
</style>
</head>
<body>
<div id="app">
<!--<el-container style="height: 100vh; border: 1px solid #eee">
<el-aside width="200px" style="background-color: rgb(238, 241, 246)">
hello
</el-aside>
<el-container>
<el-header background-color="#545c64" text-color="#fff" active-text-color="#ffd04b" style="text-align: right; font-size: 12px">
<span>Tom</span>
</el-header>
<el-main style="">
<el-table :data="tableData">
<el-table-column prop="date" label="Date" width="140">
</el-table-column>
<el-table-column prop="name" label="Name" width="120">
</el-table-column>
<el-table-column prop="address" label="Address">
</el-table-column>
</el-table>
</el-main>
<el-row>
<el-button>Default</el-button>
<el-button type="primary" @click="loginDialog = true">Primary</el-button>
<el-button type="success">Success</el-button>
<el-button type="info">Info</el-button>
<el-button type="warning">Warning</el-button>
<el-button type="danger">Danger</el-button>
</el-row>
<el-input placeholder="Please input" v-model="text" class="input-with-select">
<el-button type="info" slot="append" icon="el-icon-search"></el-button>
</el-input>
</el-container>
</el-container>-->
<!--<el-dialog :show-close="false" :close-on-click-modal="false" :close-on-press-escape="false"
title="Warning"
:visible.sync="loginDialog"
center custom-class="intro-dialog">
<h4 slot="title" class="title">SPOTLIGHT CHAT</h4>
<el-row>
<el-col :span="11" class="login-layout">
<h4 class="subtitle">Login</h4>
<el-form ref="loginForm" :rules="validation" :model="auth.login">
<el-form-item prop="username">
<el-input ref="loginUsername" v-model="auth.login.username" autocomplete="off" placeholder="username"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input ref="loginPassword" type="password" v-model="auth.login.password" autocomplete="off" placeholder="password"></el-input>
</el-form-item>
<el-button :loading="auth.loading" type="warning" class="btn-block" @click.prevent="login">Login</el-button>
</el-form>
</el-col>
<el-col :span="1" class="divider"></el-col>
<el-col :span="12" class="register-layout">
<h4 class="subtitle">Register</h4>
<el-form ref="registerForm" :rules="validation" :model="auth.register">
<el-form-item prop="name">
<el-input v-model="auth.register.name" placeholder="name"></el-input>
</el-form-item>
<el-form-item prop="username">
<el-input v-model="auth.register.username" placeholder="username"></el-input>
</el-form-item>
<el-form-item prop="password">
<el-input type="password" v-model="auth.register.password" placeholder="password"></el-input>
</el-form-item>
<el-button :loading="auth.loading" type="primary" @click.prevent="register" class="btn-block">Register</el-button>
</el-form>
</el-col>
</el-row>
<span slot="footer" class="dialog-footer">
</span>
</el-dialog>-->
<div class="container">
<div class="row">
<div class="col-4">
<img alt="Stranger image" id="otherImage">
</div>
<div class="col-8">
<video autoplay="true" id="videoElement"></video>
<div class="row">
<div class="col-8">
</div>
<div class="col-4" style="top: 45px;" id="control">
<button type="button" class="btn btn-primary btn-snap">Snap</button>
<button type="button" class="btn btn-warning btn-save">Save</button>
</div>
</div>
<img id="image" style="background-color: cyan;">
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<!-- <script type="text/javascript" src="js/vue.js"></script> -->
<!-- <script type="text/javascript" src="js/element-ui.js"></script> -->
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/socket.io.js"></script>
<script type="text/javascript">
// Vue.config.devtools = true;
// let app = new Vue({
// el: '#app',
// data () {
// const item = {
// date: '2016-05-02',
// name: 'Tom',
// address: 'No. 189, Grove St, Los Angeles'
// };
// return {
// auth: {
// loading: false,
// login: {
// username: '',
// password: ''
// },
// register: {
// name: '',
// username: '',
// password: ''
// }
// },
// validation: {
// username: [
// { required: true, message: 'Please enter your username', trigger: ['change', 'blur'] },
// { min: 3, message: 'Please enter your username', trigger: ['change', 'blur'] },
// ],
// name: [
// { required: true, message: 'Please enter your name', trigger: ['change', 'blur'] },
// { min: 3, message: 'Please enter your name', trigger: ['change', 'blur'] },
// ],
// password: [
// { required: true, message: 'Please enter your password', trigger: ['change', 'blur'] },
// { min: 3, message: 'Please enter your password', trigger: ['change', 'blur'] },
// ]
// },
// text: '',
// loginDialog: true,
// socket: io('localhost:5000'),
// tableData: Array(10).fill(item)
// }
// },
// methods: {
// register() {
// this.$refs.registerForm.validate(valid => {
// if (valid) {
// this.socket.emit('register', this.auth.register);
// }
// });
// },
// login() {
// this.$refs.loginForm.validate(valid => {
// if (valid) {
// this.socket.emit('login', this.auth.login);
// }
// });
// }
// },
// mounted () {
// this.socket.on('new-user', function (data) {
// this.$notify({message: data.message, type: 'success'});
// });
// this.socket.on('login-success', (data) => {
// if (data.type == 'success') {
// this.$notify({
// message: data,
// type: 'success'
// });
// } else {
// this.$notify({
// message: data.message,
// type: 'error'
// });
// }
// return false;
// });
// this.socket.on('login-error', (data) => {
// if (data.type == 'error') {
// this.$notify({
// message: data.message,
// type: 'error'
// });
// } else {
// this.$notify({
// message: data.message,
// type: 'error'
// });
// }
// return false;
// });
// this.socket.on('registered', (data) => {
// this.$notify({
// message: data.message,
// type: 'success'
// });
// this.$refs.loginPassword.focus();
// this.$refs.registerForm.resetFields();
// this.auth.login.username = data.user.username;
// this.auth.login.password = data.user.password;
// });
// this.socket.on('new-registration', (data) => {
// this.$notify({
// title: data.type,
// message: data.message || 'This is a success message',
// type: 'success'
// });
// });
// this.socket.on('user-exists', (data) => {
// this.$notify({
// title: data.type,
// message: data.message || 'This is a warning message',
// type: 'warning'
// });
// });
// setTimeout(()=>{
// $(this.$refs.loginForm.fields[0].$el).focus();
// }, 1000)
// console.log('application mounted!');
// }
// });
const socket = io('localhost:5000');
const btnSnap = $('#control .btn-snap');
const btnSave = $('#control .btn-save');
const image = $('#image');
const otherImage = $('#otherImage');
const video = document.querySelector('#videoElement');
const canvas = document.createElement('canvas');
/* This 7 lines below gets an image and pushes it to express (line 299)
* as png when i click the snap button.
* Express then logs it to the console as png (check chat.js)
*/
$(btnSnap).click((evt) => {
canvas.height = video.videoHeight;
canvas.width = video.videoWidth;
canvas.getContext('2d').drawImage(video, 0, 0);
socket.emit('image', canvas.toDataURL('image/png'))
$(image).attr('src', canvas.toDataURL('image/png'));
});
if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({video: true})
.then(function (stream) {
console.log(stream);
video.srcObject = stream;
})
.catch(function (err) {
console.log(err);
});
}
</script>
</body>
</html>