forked from muaz-khan/Chrome-Extensions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.js
103 lines (87 loc) · 3.04 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
chrome.storage.sync.get(null, function(items) {
if (items['resolutions']) {
document.getElementById('resolutions').value = items['resolutions'];
} else {
chrome.storage.sync.set({
resolutions: 'fit-screen'
}, function() {
document.getElementById('resolutions').value = 'fit-screen'
});
}
if (items['min_bandwidth']) {
document.getElementById('min_bandwidth').value = items['min_bandwidth'];
} else {
chrome.storage.sync.set({
min_bandwidth: 512
}, function() {});
}
if (items['max_bandwidth']) {
document.getElementById('max_bandwidth').value = items['max_bandwidth'];
} else {
chrome.storage.sync.set({
max_bandwidth: 1048
}, function() {});
}
if (items['room_password']) {
document.getElementById('room_password').value = items['room_password'];
}
if (items['room_id']) {
document.getElementById('room_id').value = items['room_id'];
}
});
document.getElementById('resolutions').onchange = function() {
this.disabled = true;
chrome.storage.sync.set({
resolutions: this.value
}, function() {
document.getElementById('resolutions').disabled = false;
});
};
document.getElementById('min_bandwidth').onblur = function() {
var maxValue = parseInt(document.getElementById('max_bandwidth').value);
var minValue = parseInt(document.getElementById('min_bandwidth').value);
if(maxValue < minValue) {
console.log('Min-Bandwidth must be lower than Max-Bandwidth.');
document.getElementById('max_bandwidth').value =
document.getElementById('min_bandwidth').value = this.value;
return;
}
this.disabled = true;
chrome.storage.sync.set({
min_bandwidth: this.value
}, function() {
document.getElementById('min_bandwidth').disabled = false;
});
};
document.getElementById('max_bandwidth').onblur = function() {
var maxValue = parseInt(document.getElementById('max_bandwidth').value);
var minValue = parseInt(document.getElementById('min_bandwidth').value);
if(maxValue < minValue) {
console.log('Min-Bandwidth must be lower than Max-Bandwidth.');
document.getElementById('max_bandwidth').value =
document.getElementById('min_bandwidth').value = this.value;
return;
}
this.disabled = true;
chrome.storage.sync.set({
max_bandwidth: this.value
}, function() {
document.getElementById('max_bandwidth').disabled = false;
});
};
document.getElementById('room_password').onblur = function() {
this.disabled = true;
chrome.storage.sync.set({
room_password: this.value
}, function() {
document.getElementById('room_password').disabled = false;
});
};
document.getElementById('room_id').onblur = function() {
this.disabled = true;
chrome.storage.sync.set({
room_id: this.value
}, function() {
document.getElementById('room_id').disabled = false;
});
};