-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
96 lines (56 loc) · 1.86 KB
/
Copy pathindex.html
File metadata and controls
96 lines (56 loc) · 1.86 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!doctype html>
<html>
<head>
<title>CodePlayer</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<div id="wrapper">
<div id="topbar">
<h1>CodePlayer</h1>
<ul id="toggles">
<li class="toggle selected">HTML</li>
<li class="toggle">CSS</li>
<li class="toggle selected" style="border:none">Result</li>
</ul>
<button id="run">Run</button>
</div>
<div class="clear"></div> <!-- Breaks floats -->
<div class="code" id="HTML">
<div class="codeLabel">HTML</div>
<textarea id="htmlCode">Insert HTML here.</textarea>
</div>
<div class="code" id="CSS">
<div class="codeLabel">CSS</div>
<textarea id="cssCode">Insert CSS here.</textarea>
</div>
<div class="code" id="Result">
<div class="codeLabel">Result</div>
<iframe id="resultFrame "></iframe>
</div>
</div> <!-- closes wrapper div -->
<script>
var windowHeight = $(window).height();
var topBarHeight = $("#topbar").height();
var codeHeight = windowHeight - topBarHeight;
$(".code").height(codeHeight+"px");
$(".toggle").click(function() {
$(this).toggleClass("selected");
var activeDiv=$(this).html();
$("#"+activeDiv).toggle();
var showingDivs=$(".code").filter(function() {
return($(this).css("display")!="none");
}).length;
var width=100/showingDivs;
$(".code").width(width+"%");
});
$("#run").click(function() {
$("iframe").contents().find("html").html('<style>'+$("#cssCode").val()+'</style>'+$("#htmlCode").val());
});
</script>
</body>
</html>