-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpopup.html
More file actions
110 lines (102 loc) · 2.78 KB
/
popup.html
File metadata and controls
110 lines (102 loc) · 2.78 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
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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<script src="3rdparty/jquery.js"></script>
<style>
body, document, html {
margin:0;
padding:0;
}
body {
font-family: Tahoma, sans-serif;
font-size:10pt;
padding:0px;
display:none;
}
a {
display:block;
white-space:nowrap;
padding:0;
border-bottom: 1px #aac solid;
padding: 6px;
}
a:last-child {
border-bottom:none;
}
a:hover { background:#ddf }
</style>
<script>
function UpdateLinks(status) {
$('body').hide();
$('a').show(0);
if ( status == 1 ) {
// 1 = recording
$('#StartRecording').hide();
$('#ResumeRecording').hide();
} else if ( status == 2 ) {
// 2 = paused
$('#StartRecording').hide();
$('#PauseRecording').hide();
} else {
// 0 = stopped
$('#StopRecording').hide();
$('#PauseRecording').hide();
$('#ResumeRecording').hide();
$('#ExportTest').hide();
$('#RunTest').hide();
}
$('body').show();
}
function ExportTest() {
chrome.tabs.getSelected( null, function(tab) {
var request = { Method: 'GetRecording', TabID: tab.id };
chrome.extension.sendRequest( request, function( response ) {
if ( response ) {
alert( JSON.stringify( response ) );
}
ClosePopup();
});
});
}
function RunTest() {
chrome.tabs.getSelected( null, function(tab) {
var request = { Method: 'GetRecording', TabID: tab.id };
chrome.extension.sendRequest( request, function( response ) {
if ( response ) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://localhost:10001/RunTest",
data: JSON.stringify( response )
})
}
ClosePopup();
});
});
}
function ClosePopup() {
chrome.tabs.getSelected( null, function(tab) {
// selecting the current tab kills the popup reliably
chrome.tabs.update( tab.id, { selected: true } )
});
}
var GetStatus = function() {
chrome.extension.sendRequest({Method:'GetRecordingStatus'}, function(status) {
UpdateLinks( status );
});
};
$(document).ready( GetStatus );
chrome.tabs.onSelectionChanged.addListener( GetStatus );
</script>
</head>
<body>
<a id="StartRecording" href="javascript:chrome.extension.sendRequest({Method:'StartRecording'},function(){ClosePopup()});">Start recording</a>
<a id="ResumeRecording" href="javascript:chrome.extension.sendRequest({Method:'ResumeRecording'},function(){ClosePopup()});">Resume recording</a>
<a id="PauseRecording" href="javascript:chrome.extension.sendRequest({Method:'PauseRecording'},function(){ClosePopup()});">Pause recording</a>
<a id="StopRecording" href="javascript:chrome.extension.sendRequest({Method:'StopRecording'});ExportTest();">Stop recording</a>
<a id="ManageRecordings" href="manage.html" target="FAR_Manage">Manage recordings</a>
<a id="ExportTest" href="javascript:ExportTest();">Export test</a>
<a id="RunTest" href="javascript:RunTest();">Run test</a>
</body>
</html>