-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpanel.js
66 lines (54 loc) · 1.91 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
63
64
65
66
$(function() {
var localStorage;
// The "Block sites from setting any data" option prevents the extension
// from accessing the localStorage. Any attempt to access window.localStorage
// will raise a security exception.
try {
localStorage = window.localStorage;
}
catch (e) {
localStorage = {};
}
function resizeLeftPanel(width) {
$('#request-list').width(width);
$('.split-view-resizer').css('left', width);
}
resizeLeftPanel(localStorage.sidePanelWidth || 200);
function resizerDragMove(event) {
resizeLeftPanel(event.pageX);
event.preventDefault();
}
function resizerDragEnd(event) {
resizeLeftPanel(event.pageX);
localStorage.sidePanelWidth = event.pageX + 'px';
$(document).off('mousemove', resizerDragMove);
$(document).off('mouseup', resizerDragEnd);
}
$('.split-view-resizer').on('mousedown', function() {
$(document).on('mousemove', resizerDragMove);
$(document).on('mouseup', resizerDragEnd);
});
});
function buildRequestEl(requestUrl, debugDataUrl) {
var url = decodeURIComponent(requestUrl),
anchor = document.createElement('a'),
path;
anchor.href = url;
path = decodeURIComponent(anchor.pathname + anchor.search);
return $('<div class="request"></div>')
.text(path)
.attr('title', url)
.on('click', function() {
$('.selected').removeClass('selected');
$(this).addClass('selected');
$('#debug-toolbar-panel').attr('src', debugDataUrl);
});
}
chrome.devtools.network.onRequestFinished.addListener(function(entry) {
$.each(entry.response.headers, function(i, header) {
if (header.name.toLowerCase() === 'x-debug-data-url') {
$('#request-list').append(buildRequestEl(entry.request.url, header.value));
return false;
}
});
});