Repository navigation
Expand file tree
/
Copy pathcode_player.html
More file actions
145 lines (120 loc) · 4.39 KB
/
Copy pathcode_player.html
File metadata and controls
145 lines (120 loc) · 4.39 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
139
140
141
142
143
144
145
<html>
<head>
<title>Code Player</title>
<script src="jquery-3.6.1.min.js"></script>
<link rel="stylesheet" href="jquery-ui/jquery-ui.css">
<script src="jquery-ui/jquery-ui.js"></script>
</head>
<style>
body{
font-family:sans-serif;
padding: 0%;
margin: 0%;
}
#header{
width:100%;
height: 29px;
background-color:#EEEEEE;
padding: 8px;
}
#logo{
float: left;
font-weight: bold;
padding: 3px 5px;
font-size: 18px;
}
#buttonContainer{
width: 300px;
margin: 0 auto;
}
.toggleButton{
font-size:80%;
float: left;
border: 1px solid gray;
padding: 8px;
border-right: none;
}
#html{
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
#output{
border-right: 1px solid gray;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}
.active{
background-color: #E8F2FF;
}
.highlitedButton{
background-color: #e2e2e2;
}
#htmlpannel{
resize: none;
border-top: none;
border-bottom: none;
border-color:#8C8C8C;
}
.pannel{
float: left;
width: 50%;
border-left: none;
resize: none;
border-top: none;
border-bottom: none;
}
#outputpannel{
border: none;
}
.hide{
display: none;
}
</style>
<body>
<div id="header">
<div id="logo">
Code Player</div>
<div id="buttonContainer">
<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" id="console">Console </div>
<div class="toggleButton active" id="output">Output </div>
</div>
</div>
<div id="bodyContainer">
<textarea id="htmlpannel" class="pannel"><p id="para">helloworld</p></textarea>
<textarea id="csspannel" class="pannel hide">p{color:green}</textarea>
<textarea id="javascriptpannel" class="pannel hide">document.getElementById("para").innerHTML="Hey Ashu";</textarea>
<iframe class="pannel " id="outputpannel"></iframe>
</div>
</body>
<script>
function updateOutPut(){
$("iframe").contents().find("html").html("<html><head><style type='text/css'>"+$("#csspannel").val()+"</style></head><body>"+$("#htmlpannel").val()+"</body></html>");
document.getElementById("outputpannel").contentWindow.eval($("#javascriptpannel").val());
}
$(".toggleButton").hover(function(){
$(this).addClass("highlitedButton")
},function(){
$(this).removeClass("highlitedButton");
});
$(".toggleButton").click(function(){
$(this).toggleClass("active");
$(this).removeClass("highlitedButton");
var pannelid=$(this).attr("id")+"pannel";
$("#"+pannelid).toggle();
var active=4-$(".hidden").length;
$(".pannel").width(($(window).width()/active)-10);
});
$(".pannel").height($(window).height()-$("#header").height()-14);
$(".pannel").width(($(window).width()/2)-10);
// $("iframe").contents().find("html").html($("#htmlpannel").val())
updateOutPut();
$("textarea").on("change keyup paste",function(){
//$("iframe").contents().find("html").html($("#htmlpannel").val())
//$("iframe").contents().find("html").html("<html><head><style type='text/css'>"+$("#csspannel").val()+"</style></head><body>"+$("#htmlpannel").val()+"</body></html>");
updateOutPut();
})
</script>
</html>