forked from hackthefuture/hackthefuture.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.html
More file actions
61 lines (58 loc) · 1.56 KB
/
Copy patheditor.html
File metadata and controls
61 lines (58 loc) · 1.56 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
<html>
<style type="text/css">
body {
/*overflow:hidden;*/
}
#editor {
width:100%;
height:100%;
resize:none;
border:0px;
font-family:Monaco, Consolas, monospace;
}
#rendered {
width:100%;
}
#editorDiv {
width:100%;
height:80%;
}
</style>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.js"></script>
<script type="text/javascript" src="http://www.hackthefuture.org/static/js/beautify-html.js"></script>
<body>
<div id="editorDiv">
<textarea id="editor"></textarea>
</div>
<button id="edit">Hack it!</button>
<div id="rendered"></div>
</body>
<script type="text/javascript">
$("#editor").keyup( function() {
$("#rendered").html('').html($(this).val());
});
$.ajax({
type: "get",
dataType: "html",
url: "http://www.hackthefuture.org/static/projects/chess/chess.html",
data: {},
success: function(response) {
var pretty = style_html(response);
$("#rendered").html('').html(pretty);
$("#editor").text(pretty);
},
error: function(response) {
}
});
var editButton = $("#edit");
$(function() {
$("#edit").live('click', function(event) {
$("#editorDiv").animate({ opacity: 'toggle', height: 'toggle' }, "fast");
editButton.text() == "Hack it!" ? editButton.text("See what changed!") : editButton.text("Hack it!");
$("#editor").val( style_html( $("#editor").val() ) );
return false;
});
});
$("#editorDiv").animate({ opacity: 'toggle', height: 'toggle' }, 1000);
</script>
</html>