<html>
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<div id="meh"></div>
</body>
</html>
var paper = Raphael("meh");
var rect = paper.rect(60,0,60,200).attr({
fill: '#000000',
opacity: '0.3'
});
var c1 = paper.circle(100,100,50).attr('fill','#eebbcc');
var c2 = paper.circle(80,80,45).attr('fill','#bbeecc');
var c3 = paper.circle(60,60,40).attr('fill','#ccbbee');
var c4 = paper.circle(130,130,40).attr('fill','#ddddaa');
function correctOrder()
{
for ( var i = 0; i < set1.length; i++)
{
var temp_circ = set1.pop();
temp_circ.toFront();
set1.splice(0, 0, temp_circ);
}
}
// Changing the order here changes the final stacking
// order after applying toFront() and toBack()
var set1 = paper.set().push(c3,c4,c2,c1);
set1.attr('stroke', false);
// This gets forgotten as soon as toFront() or
// toBack() are applied
c2.toFront();
var t1 = paper.text(90,220,"To back");
var t2 = paper.text(90,240,"To front");
var t3 = paper.text(90,260,"Insert after");
var t4 = paper.text(90,280,"Insert before");
var text=paper.set(t1,t2,t3,t4).attr({'font-size': '16px', cursor: 'pointer'});
t1.click(function(){set1.toBack();});
t2.click(function(){correctOrder();});
t3.click(function(){set1.insertAfter(rect);});
t4.click(function(){set1.insertBefore(rect);});
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard 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. |