-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.dev.js
More file actions
executable file
·50 lines (39 loc) · 1007 Bytes
/
script.dev.js
File metadata and controls
executable file
·50 lines (39 loc) · 1007 Bytes
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
/* Author:
*/
var editor,evalError;
$(function(){
$('#expose-playground').click(exposePlayground);
$('#execute-playground').click(executePlayground);
editor = CodeMirror.fromTextArea(document.getElementById("javascript-playground"), {
mode: "text/javascript"
});
//setup error popup
$('.CodeMirror').popover({
title : 'Oops!',
content : showError,
trigger : 'manual',
placement : 'bottom'
});
setTimeout(showSocial,750);
});
function exposePlayground() {
$(this).fadeOut(250,function(){$('#execute-playground').fadeIn(250)});
$('#playground-container').animate({height:'100px'});
}
function showError() {
return evalError;
}
function executePlayground() {
var script = editor.getValue();
try {
eval(script);
$('.CodeMirror').popover('hide');
} catch(e) {
evalError = e.toString();
$('.CodeMirror').popover('show');
if (console) console.log(e.toString());
}
}
function showSocial() {
$('#social-buttons').fadeIn();
}