-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathoptions.js
83 lines (63 loc) · 2.44 KB
/
options.js
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
window.setTimeout(function () {
var init = function () {
var uriToSipid = function (uri) {
var ret = /sip:(.*)@/.exec(uri);
if (ret !== null && ret.length > 1) {
return ret[1];
} else {
return "";
}
};
chrome.storage.sync.get(["uri", "password"], function (config) {
$(document).ready(function () {
$('select').material_select();
});
document.getElementById("sipid").value = uriToSipid(config["uri"]);
document.getElementById("password").value = typeof config["password"] === "undefined" ? "" : config["password"];
document.getElementById("password").focus();
document.getElementById("domain").focus();
document.getElementById("sipid").focus();
});
};
init();
document.getElementById("saveSipCredentialsButton").onclick = function (e) {
var sipid = document.getElementById("sipid").value;
var password = document.getElementById("password").value;
var domain = document.getElementById("domain").value;
if (!domain) {
domain = "sipgate.de";
}
chrome.storage.sync.set({
'ws_servers': 'wss://tls01.sipgate.de:443',
uri: "sip:" + sipid + "@" + domain,
password: password
});
chrome.runtime.reload()
};
document.getElementById("requestGoogleAuthorizationButton").onclick = function (e) {
requestGoogleAuthorization(true);
e.preventDefault();
}
});
var showGoogleAuthorizationRequest = function (show) {
document.getElementById("requestGoogleAuthorization").style.display = show ? "block" : "none";
};
var requestGoogleAuthorization = function (interactive) {
console.log("sending request");
chrome.extension.sendMessage({request: "requestGoogleAuthorization", interactive: interactive}, function (response) {
console.log("response received");
console.log(response);
showGoogleAuthorizationRequest(interactive ? false : response.autherror);
});
};
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var constraints = {
audio: true,
video: false
};
var audio = document.querySelector('webrtcaudio');
navigator.getUserMedia(constraints, function () {
}, function () {
});
requestGoogleAuthorization(false);