-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
130 lines (113 loc) · 3.22 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<title>A.S. Code Player </title>
<script type="text/javascript" src="jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery.min.js"></script>
<style type="text/css">
body{
font-family: sans-serif;
padding: 0;
margin: 0;
}
#header{
width: 100%;
background-color: #EEEEEE;
padding: 5px;
height: 30px;
}
#logo{
float: left;
font-weight: bold;
font-size: 120%;
padding: 3px 5px;
}
#button{
width: 233px;
margin: 0 auto;
}
.toggleButton{
float: left;
border: 1px solid grey;
padding: 6px;
border-right: none;
font-size: 90%;
}
#html{
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
#output{
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
border-right: 1px solid grey;
}
.active{
background-color: #E8F2FF;
}
.highlightedButton{
background-color: grey;
}
textarea{
width: 50%;
resize: none;
border-color: grey;
}
.panel{
float: left;
width: 50%;
border-left: none;
}
iframe{
border: none;
}
.hidden{
display: none;
}
</style>
</head>
<body>
<div id="header">
<div id="logo">
A.S. CodePlayer
</div>
<div id="button">
<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 id="bodyContainer">
<textarea id="htmlPanel" class="panel"><h1>Hey!</h1><p id="para"></p></textarea>
<textarea id="cssPanel" class="panel hidden">p{color: green;}</textarea>
<textarea id="javascriptPanel" class="panel hidden">document.getElementById("para").innerHTML = "It is working";</textarea>
<iframe id="outputPanel" class="panel"></iframe>
</div>
<script type="text/javascript">
function updateOutput(){
$("iframe").contents().find("html").html("<html><head><style type='text/css'>" + $("#cssPanel").val() + "</style></head<body>" + $("#htmlPanel").val() + "</body></html>");
document.getElementById("outputPanel").contentWindow.eval($("#javascriptPanel").val());
}
$(".toggleButton").hover(function(){
$(this).addClass("highlightedButton");
}, function(){
$(this).removeClass("highlightedButton");
});
$(".toggleButton").click(function(){
$(this).toggleClass("active");
$(this).removeClass("highlightedButton");
var panelId = $(this).attr("id") + "Panel";
$("#" + panelId).toggleClass("hidden");
var numberOfActivePanels = 4 - $(".hidden").length;
$(".panel").width(($(window).width() /numberOfActivePanels) - 10);
});
$("textarea").height($(window).height() - $("#header").height() - 15);
$(".panel").width(($(window).width() /2) - 10);
updateOutput();
$("textarea").on("change keyup paste",function(){
updateOutput();
});
</script>
</body>
</html>