<html>
<head>
<title>Project 04</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
</head>
<body>
<div id="topbar">
<h2>Code Runner</h2>
<div id="control">
<a href="#" class="option opactive">HTML</a>
<a href="#" class="option opactive">CSS</a>
<a href="#" class="option opactive">JavaScript</a>
<a href="#" class="option opactive">Output</a>
</div>
</div>
<div id="codebox">
<div id="HTML" class="content active">
<div class="contentbox">
<div class="contentheader">HTML</div>
<div class="editbox" id="HTMLeditbox">
<textarea id="HTMLcode" class="textareabox"></textarea>
</div>
</div>
</div>
<div class="resize active" id="1"style="left: 25%" ondrag="dragging(event)"></div>
<div id="CSS" class="content active">
<div class="contentbox">
<div class="contentheader">CSS</div>
<div class="editbox" id="CSSeditbox">
<textarea id="CSScode" class="textareabox"></textarea>
</div>
</div>
</div>
<div class="resize active" id="2"style="left: 50%" ondrag="dragging(event)"></div>
<div id="JavaScript" class="content active">
<div class="contentbox">
<div class="contentheader">JavaScript</div>
<div class="editbox" id="JavaScripteditbox">
<textarea id="JavaScriptcode" class="textareabox"></textarea>
</div>
</div>
</div>
<div class="resize active" id="3"style="left: 75%" ondrag="dragging(event)"></div>
<div id="Output" class="content active">
<div class="contentbox">
<div class="contentheader">Output</div>
<div class="editbox" id="Outputbox">
<iframe id="Outputframe" class="textareabox"></iframe>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="jscript.js"></script>
</body>
</html>
body{
margin: 0;
padding: 0;
overflow-y: hidden;
overflow-x: hidden;
background: #F7F7F7;
font-family: Arial;
}
#topbar{
margin: 0;
padding: 0;
width: 100%;
height: 35px;
background: #EEEEEE;
position: relative;
}
h2{
margin: 2px 0 0 0;
padding: 0;
float: left;
position: absolute;
}
#control{
width: 100%;
margin: 8px 0 0 0;
padding: 0;
position: absolute;
text-align: center;
}
.option{
margin: 0 -5px 0 0;
padding: 5px 10px 5px 10px;
text-align: center;
border-top: 1px solid #CCC;
border-bottom: 1px solid #CCC;
border-left: 1px solid #CCC;
text-decoration: none;
font-size: 0.9em;
color: black;
}
.option:first-child{
border-bottom-left-radius: 5px;
border-top-left-radius: 5px;
}
.option:last-child{
border-right: 1px solid #CCC;
border-bottom-right-radius: 5px;
border-top-right-radius: 5px;
}
.option:hover{
background: #dee5e5;
}
.opactive{
background: #EBF3FF;
}
.opinactive{
background: 0;
}
.active{
display: block;
}
.inactive{
display: none;
}
#codebox{
margin: 0;
padding: 0
width: 100%;
position: static;
top: 35px;
background: white;
}
.content{
margin: 0;
padding: 0;
min-width: 10%;
max-width: 100%;
position: absolute;
float: left;
color: #6DCAFC;
background: #F7F7F7;
overflow: hidden;
}
.resize{
top: 35px;
bottom: 0px;
width: 1px;
margin-left: 0;
height: 100%;
right: auto;
opacity: 0;
position: absolute;
cursor: ew-resize;
border-left-width: 1px;
border-left-style: solid;
border-left-color: rgba(218, 218, 218, 0.498039);
z-index: 99999;
background: #666;
}
.contentheader{
margin: 0;
padding: 0;
background: transparent;
position: relative;
}
.selectedcontent{
background: white;
}
.contentbox{
width: 100%;
height: 100%;
background: transparent;
position: relative;
box-sizing: border-box;
border-right: 1px solid darkgrey;
overflow: hidden;
}
.editbox{
width: 100%;
height: 100%;
background: transparent;
overflow: hidden;
}
.textareabox{
background: transparent;
min-width: 100%;
max-width: 100%;
min-height: 100%;
max-height: 100%;
border: none;
outline: none;
resize: none;
}
var activeCount = 4;
var selectedContent = "";
var $htmlcode, $csscode, $javascriptcode = "";
var consoleindex = 0;
resize();
$(".option").click(function(){
var $name = $("#" + $(this).html());
var $resize = $($name.next(".resize"));
if($name.hasClass("active")){
$(this).removeClass("opactive");
$(this).addClass("opinactive");
$name.removeClass("active");
$name.addClass("inactive");
$resize.removeClass("active");
$resize.addClass("inactive");
activeCount--;
}
else{
$(this).removeClass("opinactive");
$(this).addClass("opactive");
$name.removeClass("inactive");
$name.addClass("active");
$resize.removeClass("inactive");
$resize.addClass("active");
activeCount++;
}
// console.log($name.next(".resize"));
resize();
});
$(".content").click(function(){
// if(selectedContent != null)
$("#" + selectedContent).removeClass("selectedcontent");
$(this).addClass("selectedcontent");
selectedContent = $(this).attr("id");
// iframeupdate();
});
$(".textareabox").keyup(function(){
iframeupdate();
});
function resize(){
var $content = $(".content");
var $boxWidth = $("#codebox").width();
var boxcodename = ["#HTML", "#CSS", "#JavaScript", "#Output"];
var boxname = [];
for(var index = 0; index <= 3; index++){
if($(boxcodename[index]).hasClass("active")){
boxname.push(boxcodename[index]);
console.log(boxname);
}
}
for(var index = 0; index < activeCount; index ++){
if(index == 0){
$(boxname[index]).css("left", "0");
}
else{
$(boxname[index]).css("left", $(boxname[index]).prevAll(".active").css("left"));
}
if(index == activeCount-1){
$(boxname[index]).css("right", "0");
}
else{
$(boxname[index]).css("right", (($(window).width() - $(boxname[index]).next(".resize, .active").offset().left) +"px"));
}
}
$("#codebox").height($(window).height() - $("#topbar").height() + "px");
$content.height($("#codebox").height());
$(".editbox").height($content.height() - $(".contentheader").height());
}
function iframeupdate(){
$("#Outputframe").contents().find("html").html(
"<style>" + $("#CSScode").val() + "</style>"
+ $("#HTMLcode").val()
);
document.getElementById("Outputframe").contentWindow.eval($("#JavaScriptcode").val() );
}
$(".resize").draggable({axis: "x", containment: "parent"});
function dragging(event) {
resize();
}
Output
This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account
Dismiss xKeyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |