-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodePlayer(IDE).html
More file actions
200 lines (147 loc) · 4.6 KB
/
CodePlayer(IDE).html
File metadata and controls
200 lines (147 loc) · 4.6 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
<!DOCTYPE html>
<html>
<head>
<title>IDE</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"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
#menuBar {
width: 100%;
background-color: #e0e0e0;
height: 40px;
border-bottom: 1px solid grey;
}
#logo {
padding: 5px 0 0 10px;
font-weight: bold;
font-style: italic;
font-size: 140%;
float: left;
}
#button {
float: right;
padding: 5px 10px 0 0;
}
#runButton {
font-size: 20px;
}
#htmlcssjsresult {
width: 189px;
margin: 0 auto;
border: 1px solid grey;
border-radius: 3px;
height: 27px;
padding: 0;
position: relative;
list-style: none;
top: 5px;
}
#htmlcssjsresult li {
float: left;
border-right: 1px solid #800304;
padding: 5px 7px;
}
.clear {
clear: both;
}
.codeContainer {
height: 100%;
width: 50%;
float: left;
position: relative;
}
.codeContainer textarea {
height: 100%;
width: 100%;
border: none;
border-right: 1px solid grey;
font-family: monotype, sans-serif;
font-size: 100%;
padding: 5px;
box-sizing: border-box;
}
.codeLabel {
position: absolute;
right: 17px;
top: 95%;
border: 1px solid grey;
border-radius: 2px;
}
#CSSContainer, #JSContainer {
display: none;
}
iframe {
height: 100%;
left: 20px;
position: relative;
border: none;
}
.selected {
background-color: gray;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="menuBar">
<div id="logo">CodePlayer</div>
<div id="button">
<button id="runButton"> Run</button>
</div>
<ul id="htmlcssjsresult">
<span style="cursor:default">
<li class="toggle selected">HTML</li>
<li class="toggle">CSS</li>
<li class="toggle">JS</li>
<li class="toggle selected" style="border: none">Result</li>
</span>
</ul>
</div>
<div class="clear"></div>
<div class="codeContainer" id="HTMLContainer">
<div class="codeLabel">HTML</div>
<textarea id="htmlCode"><div id="test"></div></textarea>
</div>
<div class="codeContainer" id="CSSContainer">
<div class="codeLabel">CSS</div>
<textarea id="cssCode">html {background-color:red}</textarea>
</div>
<div class="codeContainer" id="JSContainer">
<div class="codeLabel">Javascript</div>
<textarea id="jsCode">document.getElementById("test").innerHTML = "NEW TEXT";</textarea>
</div>
<div class="codeContainer" id="ResultContainer">
<div class="codeLabel">Result</div>
<iframe id="resultFrame"></iframe>
</div>
</div>
<script>
var windowHeight = $(window).height();
var menuHeight = $("#menuBar").height();
var divHeight = windowHeight - menuHeight;
$(".codeContainer").height(divHeight + "px");
$(".toggle").click(function () {
$(this).toggleClass("selected");
var activeDiv = $(this).html();
$("#" + activeDiv + "Container").toggle();
var showingDivs = $(".codeContainer").filter(function () {
return ($(this).css("display") != "none");
}).length;
var width = 100 / showingDivs;
$(".codeContainer").css("width", width + "%");
});
$("#runButton").click(function () {
$("iframe").contents().find('html').html('<style>' + $('#cssCode').val() + '</style>' + $("#htmlCode").val());
document.getElementById("resultFrame").contentWindow.eval($("#jsCode").val()); //.EVAL SASISHIA KOMPIUTERISTVIS
});
</script>
</body>
</html>