/
sandbox.html
61 lines (46 loc) · 1.66 KB
/
sandbox.html
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
<!DOCTYPE html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<title>javascript sandbox console</title>
<!-- Stylesheet -->
<link href="sandbox.css" rel="stylesheet"/>
</head>
<body>
<!-- HTML -->
<div id="sandbox">sandbox console loading...</div>
<!-- Templates -->
<!-- The sandbox template: -->
<script type="text/template" id="tplSandbox">
<pre class="output"></pre>
<div class="input">
<textarea rows="1" placeholder="<%= placeholder %>"></textarea>
</div>
</script>
<!-- The command/result template (NB whitespace/line breaks matter inside <pre> tag): -->
<script type="text/template" id="tplCommand"><% if (! _hidden) { %><span class="command"><%= command %></span>
<span class="prefix"><%= this.resultPrefix %></span><span class="<%= _class %>"><%= result %></span>
<% } %></script>
<!-- Scripts -->
<!-- Underscore, Backbone, backbone-localStorage, jQuery -->
<script src="libs/underscore.min.js"></script>
<script src="libs/backbone.min.js"></script>
<script src="libs/backbone-localStorage.min.js"></script>
<script src="libs/jquery.min.js"></script>
<!-- The JS Sandbox Console script (requires underscore, backbone and jquery): -->
<script src="sandbox-console.js"></script>
<!-- When ready, create the model and view -->
<script type="text/javascript">
jQuery(document).ready(function($) {
// Create the sandbox:
window.sandbox = new Sandbox.View({
el : $('#sandbox'),
model : new Sandbox.Model({
iframe : true, // evaluate commands inside a hidden iframe (default: false)
fallback : true // use global eval if iframe isn't available (default: true)
})
});
});
</script>
</body>
</html>