Skip to content

Commit 8ab12b5

Browse files
author
dfounderliu
committed
Merge remote-tracking branch 'origin/master'
# Conflicts: # package.json # serverless.js
2 parents 5b40aae + 88e4aca commit 8ab12b5

File tree

5 files changed

+5969
-516
lines changed

5 files changed

+5969
-516
lines changed
Lines changed: 142 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
$(function() {
22
if (!EVALEX_TRUSTED) {
3-
initPinBox();
3+
initPinBox()
44
}
55

66
/**
77
* if we are in console mode, show the console.
88
*/
99
if (CONSOLE_MODE && EVALEX) {
10-
openShell(null, $('div.console div.inner').empty(), 0);
10+
openShell(null, $('div.console div.inner').empty(), 0)
1111
}
1212

13-
$("div.detail").click(function() {
14-
$("div.traceback").get(0).scrollIntoView(false);
15-
});
13+
$('div.detail').click(function() {
14+
$('div.traceback')
15+
.get(0)
16+
.scrollIntoView(false)
17+
})
1618

1719
$('div.traceback div.frame').each(function() {
18-
var
19-
target = $('pre', this),
20+
var target = $('pre', this),
2021
consoleNode = null,
21-
frameID = this.id.substring(6);
22+
frameID = this.id.substring(6)
2223

2324
target.click(function() {
24-
$(this).parent().toggleClass('expanded');
25-
});
25+
$(this)
26+
.parent()
27+
.toggleClass('expanded')
28+
})
2629

2730
/**
2831
* Add an interactive console to the frames
@@ -31,180 +34,197 @@ $(function() {
3134
$('<img src="?__debugger__=yes&cmd=resource&f=console.png">')
3235
.attr('title', 'Open an interactive python shell in this frame')
3336
.click(function() {
34-
consoleNode = openShell(consoleNode, target, frameID);
35-
return false;
37+
consoleNode = openShell(consoleNode, target, frameID)
38+
return false
3639
})
37-
.prependTo(target);
40+
.prependTo(target)
3841
}
39-
});
42+
})
4043

4144
/**
4245
* toggle traceback types on click.
4346
*/
44-
$('h2.traceback').click(function() {
45-
$(this).next().slideToggle('fast');
46-
$('div.plain').slideToggle('fast');
47-
}).css('cursor', 'pointer');
48-
$('div.plain').hide();
47+
$('h2.traceback')
48+
.click(function() {
49+
$(this)
50+
.next()
51+
.slideToggle('fast')
52+
$('div.plain').slideToggle('fast')
53+
})
54+
.css('cursor', 'pointer')
55+
$('div.plain').hide()
4956

5057
/**
5158
* Add extra info (this is here so that only users with JavaScript
5259
* enabled see it.)
5360
*/
5461
$('span.nojavascript')
5562
.removeClass('nojavascript')
56-
.html('<p>To switch between the interactive traceback and the plaintext ' +
57-
'one, you can click on the "Traceback" headline. From the text ' +
58-
'traceback you can also create a paste of it. ' + (!EVALEX ? '' :
59-
'For code execution mouse-over the frame you want to debug and ' +
60-
'click on the console icon on the right side.' +
61-
'<p>You can execute arbitrary Python code in the stack frames and ' +
62-
'there are some extra helpers available for introspection:' +
63-
'<ul><li><code>dump()</code> shows all variables in the frame' +
64-
'<li><code>dump(obj)</code> dumps all that\'s known about the object</ul>'));
63+
.html(
64+
'<p>To switch between the interactive traceback and the plaintext ' +
65+
'one, you can click on the "Traceback" headline. From the text ' +
66+
'traceback you can also create a paste of it. ' +
67+
(!EVALEX
68+
? ''
69+
: 'For code execution mouse-over the frame you want to debug and ' +
70+
'click on the console icon on the right side.' +
71+
'<p>You can execute arbitrary Python code in the stack frames and ' +
72+
'there are some extra helpers available for introspection:' +
73+
'<ul><li><code>dump()</code> shows all variables in the frame' +
74+
"<li><code>dump(obj)</code> dumps all that's known about the object</ul>")
75+
)
6576

6677
/**
6778
* Add the pastebin feature
6879
*/
69-
$('div.plain form')
70-
.submit(function() {
71-
var label = $('input[type="submit"]', this);
72-
var old_val = label.val();
73-
label.val('submitting...');
74-
$.ajax({
75-
dataType: 'json',
76-
url: document.location.pathname,
77-
data: {__debugger__: 'yes', tb: TRACEBACK, cmd: 'paste',
78-
s: SECRET},
79-
success: function(data) {
80-
$('div.plain span.pastemessage')
81-
.removeClass('pastemessage')
82-
.text('Paste created: ')
83-
.append($('<a>#' + data.id + '</a>').attr('href', data.url));
84-
},
85-
error: function() {
86-
alert('Error: Could not submit paste. No network connection?');
87-
label.val(old_val);
88-
}
89-
});
90-
return false;
91-
});
80+
$('div.plain form').submit(function() {
81+
var label = $('input[type="submit"]', this)
82+
var old_val = label.val()
83+
label.val('submitting...')
84+
$.ajax({
85+
dataType: 'json',
86+
url: document.location.pathname,
87+
data: { __debugger__: 'yes', tb: TRACEBACK, cmd: 'paste', s: SECRET },
88+
success: function(data) {
89+
$('div.plain span.pastemessage')
90+
.removeClass('pastemessage')
91+
.text('Paste created: ')
92+
.append($('<a>#' + data.id + '</a>').attr('href', data.url))
93+
},
94+
error: function() {
95+
alert('Error: Could not submit paste. No network connection?')
96+
label.val(old_val)
97+
}
98+
})
99+
return false
100+
})
92101

93102
// if we have javascript we submit by ajax anyways, so no need for the
94103
// not scaling textarea.
95-
var plainTraceback = $('div.plain textarea');
96-
plainTraceback.replaceWith($('<pre>').text(plainTraceback.text()));
97-
});
104+
var plainTraceback = $('div.plain textarea')
105+
plainTraceback.replaceWith($('<pre>').text(plainTraceback.text()))
106+
})
98107

99108
function initPinBox() {
100109
$('.pin-prompt form').submit(function(evt) {
101-
evt.preventDefault();
102-
var pin = this.pin.value;
103-
var btn = this.btn;
104-
btn.disabled = true;
110+
evt.preventDefault()
111+
var pin = this.pin.value
112+
var btn = this.btn
113+
btn.disabled = true
105114
$.ajax({
106115
dataType: 'json',
107116
url: document.location.pathname,
108-
data: {__debugger__: 'yes', cmd: 'pinauth', pin: pin,
109-
s: SECRET},
117+
data: { __debugger__: 'yes', cmd: 'pinauth', pin: pin, s: SECRET },
110118
success: function(data) {
111-
btn.disabled = false;
119+
btn.disabled = false
112120
if (data.auth) {
113-
EVALEX_TRUSTED = true;
114-
$('.pin-prompt').fadeOut();
121+
EVALEX_TRUSTED = true
122+
$('.pin-prompt').fadeOut()
115123
} else {
116124
if (data.exhausted) {
117-
alert('Error: too many attempts. Restart server to retry.');
125+
alert('Error: too many attempts. Restart server to retry.')
118126
} else {
119-
alert('Error: incorrect pin');
127+
alert('Error: incorrect pin')
120128
}
121129
}
122-
console.log(data);
130+
console.log(data)
123131
},
124132
error: function() {
125-
btn.disabled = false;
126-
alert('Error: Could not verify PIN. Network error?');
133+
btn.disabled = false
134+
alert('Error: Could not verify PIN. Network error?')
127135
}
128-
});
129-
});
136+
})
137+
})
130138
}
131139

132140
function promptForPin() {
133141
if (!EVALEX_TRUSTED) {
134142
$.ajax({
135143
url: document.location.pathname,
136-
data: {__debugger__: 'yes', cmd: 'printpin', s: SECRET}
137-
});
144+
data: { __debugger__: 'yes', cmd: 'printpin', s: SECRET }
145+
})
138146
$('.pin-prompt').fadeIn(function() {
139-
$('.pin-prompt input[name="pin"]').focus();
140-
});
147+
$('.pin-prompt input[name="pin"]').focus()
148+
})
141149
}
142150
}
143151

144-
145152
/**
146153
* Helper function for shell initialization
147154
*/
148155
function openShell(consoleNode, target, frameID) {
149-
promptForPin();
150-
if (consoleNode)
151-
return consoleNode.slideToggle('fast');
156+
promptForPin()
157+
if (consoleNode) {
158+
return consoleNode.slideToggle('fast')
159+
}
152160
consoleNode = $('<pre class="console">')
153161
.appendTo(target.parent())
154162
.hide()
155-
var historyPos = 0, history = [''];
156-
var output = $('<div class="output">[console ready]</div>')
157-
.appendTo(consoleNode);
163+
var historyPos = 0,
164+
history = ['']
165+
var output = $('<div class="output">[console ready]</div>').appendTo(consoleNode)
158166
var form = $('<form>&gt;&gt;&gt; </form>')
159167
.submit(function() {
160-
var cmd = command.val();
161-
$.get('', {
162-
__debugger__: 'yes', cmd: cmd, frm: frameID, s: SECRET}, function(data) {
163-
var tmp = $('<div>').html(data);
164-
$('span.extended', tmp).each(function() {
165-
var hidden = $(this).wrap('<span>').hide();
166-
hidden
167-
.parent()
168-
.append($('<a href="#" class="toggle">&nbsp;&nbsp;</a>')
169-
.click(function() {
170-
hidden.toggle();
168+
var cmd = command.val()
169+
$.get(
170+
'',
171+
{
172+
__debugger__: 'yes',
173+
cmd: cmd,
174+
frm: frameID,
175+
s: SECRET
176+
},
177+
function(data) {
178+
var tmp = $('<div>').html(data)
179+
$('span.extended', tmp).each(function() {
180+
var hidden = $(this)
181+
.wrap('<span>')
182+
.hide()
183+
hidden.parent().append(
184+
$('<a href="#" class="toggle">&nbsp;&nbsp;</a>').click(function() {
185+
hidden.toggle()
171186
$(this).toggleClass('open')
172-
return false;
173-
}));
174-
});
175-
output.append(tmp);
176-
command.focus();
177-
consoleNode.scrollTop(consoleNode.get(0).scrollHeight);
178-
var old = history.pop();
179-
history.push(cmd);
180-
if (typeof old != 'undefined')
181-
history.push(old);
182-
historyPos = history.length - 1;
183-
});
184-
command.val('');
185-
return false;
186-
}).
187-
appendTo(consoleNode);
187+
return false
188+
})
189+
)
190+
})
191+
output.append(tmp)
192+
command.focus()
193+
consoleNode.scrollTop(consoleNode.get(0).scrollHeight)
194+
var old = history.pop()
195+
history.push(cmd)
196+
if (typeof old != 'undefined') {
197+
history.push(old)
198+
}
199+
historyPos = history.length - 1
200+
}
201+
)
202+
command.val('')
203+
return false
204+
})
205+
.appendTo(consoleNode)
188206

189-
var command = $('<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">')
207+
var command = $(
208+
'<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">'
209+
)
190210
.appendTo(form)
191211
.keydown(function(e) {
192212
if (e.key == 'l' && e.ctrlKey) {
193-
output.text('--- screen cleared ---');
194-
return false;
195-
}
196-
else if (e.charCode == 0 && (e.keyCode == 38 || e.keyCode == 40)) {
213+
output.text('--- screen cleared ---')
214+
return false
215+
} else if (e.charCode == 0 && (e.keyCode == 38 || e.keyCode == 40)) {
197216
// handle up arrow and down arrow
198-
if (e.keyCode == 38 && historyPos > 0)
199-
historyPos--;
200-
else if (e.keyCode == 40 && historyPos < history.length)
201-
historyPos++;
202-
command.val(history[historyPos]);
203-
return false;
217+
if (e.keyCode == 38 && historyPos > 0) {
218+
historyPos--
219+
} else if (e.keyCode == 40 && historyPos < history.length) {
220+
historyPos++
221+
}
222+
command.val(history[historyPos])
223+
return false
204224
}
205-
});
225+
})
206226

207227
return consoleNode.slideDown('fast', function() {
208-
command.focus();
209-
});
228+
command.focus()
229+
})
210230
}

component/werkzeug/debug/shared/jquery.js

Lines changed: 5464 additions & 2 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)