-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinitialize.js
More file actions
44 lines (38 loc) · 1.32 KB
/
Copy pathinitialize.js
File metadata and controls
44 lines (38 loc) · 1.32 KB
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
navigator.getUserMedia = (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
if (navigator.getUserMedia) {
navigator.getUserMedia(
{
video:false,
audio:true
},
// success callback if user approves
function(stream) {
// set local storage variable that records state of getUserMedia
localStorage.setItem('isGetUserMediaInitialized', "true");
// reset dispaly of options page
$("#info_blocked").hide();
$("#prevPageRedirectButton").hide();
// redirect tp previous page
goToPrevPage()
},
// failure callback if user denies
function(error) {
// set local storage variable that records state of getUserMedia
localStorage.setItem('isGetUserMediaInitialized', "false");
// alert the user that they must approve getUserMedia for Lucy to function
$("#info_blocked").show();
$("#prevPageRedirectButton").show();
});
}
else {
alert('Sorry, the browser you are using doesn\'t support getUserMedia');
}
// redirect to previous page using URL stored in local storage
function goToPrevPage() {
// get URL of previous page. if none, set default value to google.com
var currentURL = localStorage.getItem('currentURL') || "https://www.google.com/";
// redirect to previous URL so user can continue web browsing
chrome.tabs.update({
url: currentURL
});
}