<html>
<head>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="https://jsplumb.googlecode.com/svn-history/r859/trunk/js/lib/raphael-1.5.2-min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
</style>
</head>
<body>
</body>
</html>
var canvas = Raphael(10, 50, 1600, 1300);
canvas.canvas.style.backgroundColor = '#34495e';
var ModuleRect = function(x,y,data){
this.x = x || 0;
this.y = y|| 0;
this.width = 180;
this.height = 300;
this.title = data.title || 'notitle';
this.inject = data.inject || [];
this.export = data.export || {};
var self = this;
this.draw = function(){
var st = canvas.set();
var c = canvas.rect(self.x, self.y, self.width, self.height);
c.attr({'fill': '#34495e'});
st.push(c);
var t = canvas.text(self.x+100, self.y+10, self.title);
st.push(t);
var len = self.inject.length;
for (var i=0;i<len;i++){
var text = self.inject[i];
st.push(text);
var c = canvas.circle(self.x+self.width, self.y+i*20+10, 5).attr({'fill': 'white'});
var t = canvas.text(self.x+30, self.y+i*20+10, text).attr({'text-anchor': 'start'});
}
var n = 0;
for (var key in self.export){
var val = self.export[key];
var c = canvas.circle(self.x, self.y+n*20+150, 5).attr({'fill': 'white'});
var t = canvas.text(self.x+10, self.y+n*20+150, key+':'+val).attr({'text-anchor': 'start'});
n++;
}
var start = function () {
this.ox = this.attr("x");
this.oy = this.attr("y");
this.animate({ opacity: .25}, 500, ">");
},
move = function (dx, dy) {
this.attr({x: this.ox + dx, y: this.oy + dy});
},
up = function () {
this.animate({ opacity: .5}, 500, ">");
};
st.drag(move, start, up);
}
}
var data = {
title:'mover',
inject:["pubsub", "stage", "mover", "blocks", "assets"],
export:{
scene: 'THREE.Scene',
renderer: 'THREE.WebGLRenderer',
camera: 'THREE.PerspectiveCamera',
container: 'HTMLElement',
controls: 'THREE.OrbitControls',
walls: '[]',
room: '{}'
}
}
var m1 = new ModuleRect(100,100,data);
m1.draw();
var m2 = new ModuleRect(400,200,data);
m2.draw();
Output
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. |