neyric/wireit

View on GitHub
sandbox/wireit-layout/examples/dotparser/index.html

Summary

Maintainability
Test Coverage
<?xml version="1.0" encoding="UTF-8"?>
<html>
 <head>
  <title>WireIt Example, DOT parser prototype</title>
  
  
<!-- YUI -->
<link rel="stylesheet" href="https://yui-s.yahooapis.com/combo?3.6.0/build/cssreset/reset-min.css&3.6.0/build/cssfonts/fonts-min.css">
<script src="https://yui-s.yahooapis.com/3.6.0/build/yui/yui.js"></script>
  
<script type="text/javascript" src="../../../../lib/excanvas.js"></script>

<!-- WireIt -->
<script type="text/javascript" src="../../../../build/wireit-min.js"></script>
<!-- Animations plugin -->
<script type="text/javascript" src="../../../../js/Anim.js"></script>
<!-- Layout plugin -->
<script type="text/javascript" src="../../js/Layout.js"></script>

<script type='text/javascript' src='DotToJson.js'></script>

<link rel="stylesheet" type="text/css" href="../../../../assets/WireIt.css" />

<style>

div.WireIt-Terminal {
    background-image: none;
    width: 0px;
    height: 0px;
}

div.WireIt-Container {
    width: 90px
}

</style>

<script>


YUI_config.groups.wireit.base = '../src/';
YUI({filter: 'raw', combine: false}).use('wire', 'bezier-wire', 'terminal', function(Y) {
    
    YAHOO.util.Connect.asyncRequest('GET', 'sample.dot', {
        success: function(o) {
            var graph = DotParser.parse(o.responseText);
            run(graph);
        }
    })
    
});


run = function(graph) {
        
    layer = new Y.Layer({});
    for(var i = 0 ; i < graph.nodes.length ; i++) {
        layer.addContainer({
            terminals: [ { offsetPosition: {bottom: 34, left: 25}, editable: false }],
            title: graph.nodes[i],
            position: [ Math.floor(Math.random()*800)+30, Math.floor(Math.random()*300)+30 ],
            close: false
        });
    }
    for(var i = 0 ; i < graph.edges.length ; i++) {
        var edge = graph.edges[i];
        layer.addWire({
            src: {moduleId: graph.nodes.indexOf(edge.node1), terminalId: 0},
            tgt: {moduleId: graph.nodes.indexOf(edge.node2), terminalId: 0},
            xtype: "Y.Wire"
        });
    }    
    
    layer.startDynamicLayout();
};


</script>

 </head>
 <body>
 </body>
</html>