-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdropdown.js
139 lines (126 loc) · 3.98 KB
/
dropdown.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
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
var runtimePort = chrome.runtime.connect({
name: location.href.replace(/\/|:|#|\?|\$|\^|%|\.|~|!|\+|@|\[|\||]|\|*. /g, '').split('\n').join('').split('\r').join('')
});
runtimePort.onMessage.addListener(function(message) {
if (!message || !message.messageFromContentScript1234) {
return;
}
});
var isRecording = false;
chrome.storage.sync.get('isRecording', function(obj) {
document.getElementById('default-section').style.display = obj.isRecording === 'true' ? 'none' : 'block';
document.getElementById('stop-section').style.display = obj.isRecording === 'true' ? 'block' : 'none';
isRecording = obj.isRecording === 'true';
// auto-stop-recording
if (isRecording === true) {
document.getElementById('stop-recording').click();
chrome.tabs.query({}, function(tabs) {
var tabIds = [];
var url = 'chrome-extension://' + chrome.runtime.id + '/video.html';
for (var i = tabs.length - 1; i >= 0; i--) {
if (tabs[i].url === url) {
tabIds.push(tabs[i].id);
chrome.tabs.update(tabs[i].id, {
active: true,
url: url
});
break;
}
}
if (tabIds.length) {
chrome.tabs.remove(tabIds);
}
});
}
});
function saveTabUrl(){
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
var last_url = tabs[0].url;
chrome.storage.local.set({
last_url: last_url
}, function() {
console.log('{last_url:'+last_url);
}
);
})
};
document.getElementById('stop-recording').onclick = function() {
chrome.storage.sync.set({
isRecording: 'false'
}, function() {
runtimePort.postMessage({
messageFromContentScript1234: true,
stopRecording: true,
dropdown: true
});
window.close();
});
};
$('#full-screen').append(chrome.i18n.getMessage('full_screen'));
document.getElementById('full-screen').onclick = function() {
saveTabUrl();
chrome.storage.sync.set({
enableTabCaptureAPI: 'false',
enableTabCaptureAPIAudioOnly: 'false',
enableMicrophone: 'false',
enableCamera: 'false',
enableScreen: 'true',
isRecording: 'true',
enableSpeakers: 'false'
}, function() {
runtimePort.postMessage({
messageFromContentScript1234: true,
startRecording: true,
dropdown: true
});
window.close();
});
};
$('#selected-tab').append(chrome.i18n.getMessage('selected_tab'));
document.getElementById('selected-tab').onclick = function() {
saveTabUrl();
chrome.storage.sync.set({
enableTabCaptureAPI: 'true',
enableTabCaptureAPIAudioOnly: 'false',
enableMicrophone: 'false',
enableCamera: 'false',
enableScreen: 'false',
isRecording: 'true',
enableSpeakers: 'false'
}, function() {
runtimePort.postMessage({
messageFromContentScript1234: true,
startRecording: true,
dropdown: true
});
window.close();
});
};
$('#microphone-screen').append(chrome.i18n.getMessage('microphone_screen'));
document.getElementById('microphone-screen').onclick = function() {
saveTabUrl();
chrome.storage.sync.set({
enableTabCaptureAPI: 'false',
enableTabCaptureAPIAudioOnly: 'false',
enableMicrophone: 'true',
enableCamera: 'false',
enableScreen: 'true',
isRecording: 'true',
enableSpeakers: 'false'
}, function() {
runtimePort.postMessage({
messageFromContentScript1234: true,
startRecording: true,
dropdown: true
});
window.close();
});
};
document.getElementById('btn-options').onclick = function(e) {
e.preventDefault();
location.href = this.href;
};
$('#btn-redmine-opt').click(function(e) {
e.preventDefault();
location.href = this.href;
});