-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpanel.js
62 lines (52 loc) · 2.65 KB
/
panel.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
document.addEventListener('DOMContentLoaded', function () {
document.querySelector('#copy').addEventListener('click', function () {
var code = document.createRange();
code.selectNode(document.querySelector('code'));
window.getSelection().addRange(code);
try {
if (document.execCommand('copy'))
document.querySelector('#message').innerText = 'Copied to the clipboard on ' + (new Date()).toLocaleString();
else
document.querySelector('#message').innerText = 'Problem copying test script to the clipboard.';
}
catch (e) {
document.querySelector('#message').innerText = 'Problem copying test script to the clipboard.';
}
window.getSelection().removeAllRanges();
}, false);
document.querySelector('#clear').addEventListener('click', function () {
chrome.devtools.inspectedWindow.eval('(function () { window.protractor.logs = []; })()');
update([]);
document.querySelector('#message').innerText = '';
}, false);
document.querySelector('#nosync').addEventListener('change', function () {
if (document.querySelector('#nosync').checked)
chrome.devtools.inspectedWindow.eval('(function () { window.protractor.ignoreSynchronization = true; window.protractor.logs.push(\'browser.ignoreSynchronization = true;\'); })()');
else
chrome.devtools.inspectedWindow.eval('(function () { window.protractor.ignoreSynchronization = false; window.protractor.logs.push(\'browser.ignoreSynchronization = false; })()');
}, false);
document.querySelector('code').addEventListener('focus', function () {
editing = true;
}, false);
document.querySelector('code').addEventListener('blur', function () {
chrome.devtools.inspectedWindow.eval('(function () { window.protractor.logs = ' + JSON.stringify(document.querySelector('code').innerText.split('\n')) + '; })()');
editing = false;
}, false);
}, false);
var editing = false;
function update(logs) {
if (!editing) {
var code = document.querySelector('code');
if (code)
code.innerText = logs.join('\n');
Prism.highlightAll();
if (logs && logs.length > 0) {
document.querySelector('#copy').style.display = '';
document.querySelector('#clear').style.display = '';
}
else {
document.querySelector('#copy').style.display = 'none';
document.querySelector('#clear').style.display = 'none';
}
}
}