-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCode-Player.html
More file actions
138 lines (123 loc) · 3.41 KB
/
Copy pathCode-Player.html
File metadata and controls
138 lines (123 loc) · 3.41 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!doctype html>
<html>
<head>
<title>Code Player</title>
<script type="text/javascript" src="jquery.min.js"></script>
<link href="jquery-ui/jquery-ui.css" rel="stylesheet">
<script src="jquery-ui/jquery-ui.js"></script>
<style>
body{
margin:0;
padding:0;
font-family:sans-serif;
}
#topbar{
background-color:#EEEEEE;
width:100%;
height:35px;
}
#logo{
font-weight:bold;
font-size:120%;
float:left;
padding:7px 7px;
}
#elements{
width:325px;
margin:0 auto;
position:relative;
top:4px;
}
.togglebutton{
float:left;
border: 1px solid grey;
padding:3px;
border-right:none;
}
#html{
border-top-left-radius:3px;
border-bottom-left-radius:3px;
}
#output{
border-right:1px solid grey;
border-top-right-radius:3px;
border-bottom-right-radius:3px;
}
.active{
background-color:#E8F2FF;
}
.highlightedButton{
background-color:#bab0b0;
}
.clear{
clear:both;
}
textarea{
margin:0;
padding:5px;
float:left;
border-top:none;
border-color:grey;
border-left:none;
}
iframe{
border:none;
float:left;
overflow:hidden;
}
.hidden{
display:none;
}
.panel{
width:
}
</style>
</head>
<body>
<div id="topbar">
<div id="logo">Code Player</div>
<div id="elements">
<div class="togglebutton active" id="html">HTML</div>
<div class="togglebutton " id="css">CSS</div>
<div class="togglebutton " id="javascript">JavaScript</div>
<div class="togglebutton active" id="output">Output</div>
</div>
</div>
<div class="clear"></div>
<div id="bodycontainer">
<textarea id="htmlblock" class="panel" ></textarea>
<textarea id="cssblock" class="hidden panel"></textarea>
<textarea id="javascriptblock" class="hidden panel"></textarea>
<iframe id="outputblock" class="panel"></iframe>
</div>
<script type="text/javascript">
$(".togglebutton").hover(
function(){
$(this).addClass("highlightedButton");
},function(){
$(this).removeClass("highlightedButton");
}
);
$(".panel").width($(window).width()/2-10);
$( ".togglebutton" ).click(function() {
$( this ).toggleClass( "active" );
$(this).removeClass("highlightedButton");
var currentpressed=$(this).attr("id")+"block";
$("#"+currentpressed).toggle("hidden");
var noofblocks=$('.active').length;
$(".panel").width($(window).width()/noofblocks-50);
});
$("textarea").height($(window).height()-48);
$("iframe").height($(window).height()-48);
$("textarea").css('resize', 'none');
$("iframe").contents().find("html").html("<html><head><style type='text/css'>" + $("#cssblock").val() +
"</style></head><body>" + $("#htmlblock").val()+ "</body></html>");
document.getElementById("outputblock").contentWindow.eval($("#javascriptblock").val());
$("textarea").on('change keyup paste', function() {
$("iframe").contents().find("html").html("<html><head><style type='text/css'>" + $("#cssblock").val() +
"</style></head><body>" + $("#htmlblock").val()+ "</body></html>");
document.getElementById("outputblock").contentWindow.eval($("#javascriptblock").val());
});
</script>
</body>
</html>