-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCode-Player.html
executable file
·157 lines (138 loc) · 4.26 KB
/
Code-Player.html
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
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Code-on-Code</title>
<link rel="stylesheet" href="jquery-ui/jquery-ui.css">
<link rel="shortcut icon" href="favicon.ico">
<script src="jquery-ui/external/jquery/jquery.js"></script>
<script src="jquery-ui/jquery-ui.js"></script>
<style>
body, html {
width: 100%;
height: 100%;
overflow-x: hidden;
background-color: #cce0ff;
}
@font-face {
font-family: 'Yanone Kaffeesatz';
src: url('Fonts/YanoneKaffeesatz-Regular.ttf');
}
#main-toolbar {
width: 95%;
height: 60px;
margin: 0 auto;
background-color: #DBF0F4;
border-radius: 2%;
padding-top: 10px !important;
padding: 4px;
}
#main-toolbar h1 {
font-family: 'Yanone Kaffeesatz', sans-serif;
font-size: 50px;
margin: 7px 5px;
float: left;
}
#button-container {
margin: 10px auto;
width: 520px;
height: 30px;
}
.toggle-button {
width: 130px;
background-color: white;
float: left;
padding-top: 5px;
border: 1px solid gray;
border-radius: 4px;
font-size: 35px;
font-family: 'Yanone Kaffeesatz', sans-serif;
transition-duration: 0.4s;
outline: none;
}
.toggle-button:hover {
background-color: #E4E4E4;
cursor: pointer;
}
#main-display {
padding-top: 0px !important;
padding: 4px;
width: 95%;
margin: 0 auto;
/*background-color: #F8FCDA;*/
border-radius: 1%;
}
.active {
background-color: #E8F2FF;
}
textarea {
font-size: 20px;
resize: none;
border-top: none;
border-left: none;
border-bottom: none;
border-color: grey;
outline-color: red;
}
.panel {
float: left;
width: 50%;
border-radius: 1%;
background-color: white;
}
.hidden {
display: none;
}
iframe {
border: none;
background-color: white;
padding-left: 5px;
}
</style>
<script type="text/javascript">
$(document).ready(function() {
function updateOutput() {
$("iframe").contents().find("html").html("<html><head><style type='text/css'>"
+ $("#css-panel").val() + "</style></head><body>" + $("#html-panel").val()
+ "</body></html>");
document.getElementById("output-panel").contentWindow.eval($("#javascript-panel").val());
};
$(".panel").height($(window).height() - $("#main-toolbar").height() - 30);
$("#main-display").height($(".panel").height());
$(".panel").width(($("#main-display").width() / 2) - 5);
$(".toggle-button").click(function() {
$(this).toggleClass("active");
var panelId = $(this).attr("id") + "-panel";
$("#" + panelId).toggleClass("hidden");
var activePanels = 4 - $('.hidden').length;
$(".panel").width(($("#main-display").width() / activePanels) - 5);
});
updateOutput();
$("textarea").on('change keyup paste', function() {
updateOutput();
});
});
</script>
</head>
<body>
<div id="main-toolbar">
<h1>Code-on-Code</h1>
<div id="button-container">
<button class="toggle-button active" type="button" id="html">HTML</button>
<button class="toggle-button" type="button" id="css">CSS</button>
<button class="toggle-button" type="button" id="javascript">Javascript</button>
<button class="toggle-button active" type="button" id="output">Output</button>
</div>
</div>
<div id="main-display">
<textarea id="html-panel" class="panel" spellcheck="false"><div id="para">Hello World!</div></textarea>
<textarea id="css-panel" class="panel hidden" spellcheck="false">#para {
color: grey;
font-size: 25px;
font-family: Courier;
}</textarea>
<textarea id="javascript-panel" class="panel hidden" spellcheck="false">document.getElementById("para").innerHTML = "Hello There!";</textarea>
<iframe id="output-panel" class="panel" spellcheck="false"></iframe>
</div>
</body>
</html>