Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
69 lines (60 sloc) 1.51 KB
/* This program is free software. It comes without any warranty, to
* the extent permitted by applicable law. You can redistribute it
* and/or modify it under the terms of the Do What The Fuck You Want
* To Public License, Version 2, as published by Sam Hocevar. See
* http://sam.zoy.org/wtfpl/COPYING for more details. */
BEGIN {
print("<html>
<body onresize=\"resize();\" onload=\"resize();\">
<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js\"></script>
<script src=\"springy.js\"></script>
<script src=\"springyui.js\"></script>
<script>
function resize() {
var canvas = document.getElementById(\"graph\");
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
}
");
string nodes;
string edges;
string color;
}
BEG_G {
print("var graph = new Graph();");
}
N {
string label = $.name;
color = getDflt($G,"N","color");
if(hasAttr($,"label")) {
label = aget($,"label");
}
if(hasAttr($,"color")) {
color = aget($,"color");
}
nodes = sprintf("%svar node%s = graph.newNode({label: '%s', color: '%s'});\n",nodes,$.name,label,color);
}
E {
if(hasAttr($,"color")) {
color = aget($,"color");
} else {
color = "#000000";
}
edges = sprintf("%sgraph.newEdge(node%s, node%s).data.color = '%s';\n",edges,$.tail.name,$.head.name,color);
}
END_G {
print(nodes);
print(edges);
printf("jQuery(function(){
var springy = jQuery('#graph').springy({
graph: graph
});
});\n");
}
END {
print("</script>
<canvas id=\"graph\" width=\"800\" height=\"600\" />\n
</body>
</html>
");
}