View self-loop link in directed layout
function layout() { | |
try { | |
var adjacencyList = eval('adjacencyList = ' + $('#adjacency-list').val()); | |
} catch (e) { alert(e); } | |
var cells = buildGraphFromAdjacencyList(adjacencyList); | |
graph.resetCells(cells); | |
joint.layout.DirectedGraph.layout(graph, { setLinkVertices: false }); |
View joint.layout.kieler.js
function layout(graph) { | |
var graphJSON = { id: 'root', children: [], edges: [] }; | |
_.each(graph.getElements(), function(el) { | |
graphJSON.children.push({ | |
id: el.id, | |
width: el.get('size').width, | |
height: el.get('size').height | |
}); | |
}); |
View Statechart require.js
var m = require('statechart-sync'); | |
m.count = 3; | |
m.done = function() { /* ... */ }; | |
var dispatch = function(err, doc) { m.dispatch(err ? 'error' : 'data', err || doc); | |
m.run(); | |
db.get('myID1', dispatch); | |
db.get('myID2', dispatch); |
View Statechart.js
var machine = _.extend({ | |
// slots | |
count: 1, | |
done: function() {}, | |
// logic | |
initialState: 'Init', | |
states: { |
View Promises.js
var deferredValue = promiseMe(); | |
deferredValue.then(function done(data) { /*...*/ }); |
View Continuation-passing style.js
function getData(callback) { | |
callAsync(function(data) { | |
callback(data); | |
}) | |
} | |
getData(function done() { /* ... */ }); |
View gist:1423315
var paper = Raphel('paper', 400, 300), | |
rect = paper.rect(50, 50, 100, 30), | |
circle = paper.circle(200, 100, 20); | |
rect.joint(circle); |