~mttronchetti/roshbot/logs

« back to all changes in this revision

Viewing changes to node/static/index.html

  • Committer: mttronchetti
  • Date: 2014-04-12 16:10:03 UTC
  • Revision ID: mttronchetti@gmail.com-20140412161003-edclhpiq61679w02
fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
612
612
        window.localStorage.latest = nodesToString();
613
613
}
614
614
 
615
 
function makePorts(){
616
 
        //reset ports
617
 
        nodes.forEach(function(n){
618
 
                n.inPoints.forEach(function(i){i.port = -1;i.el.title = "no port";});           
619
 
                n.outPoints.forEach(function(i){i.port = -1;i.el.title = "no port";});
620
 
        });
621
 
        //set ports
622
 
        nodes.forEach(function(n){
623
 
                n.connectTo.forEach(function(c){
624
 
                        //set port
625
 
                        if(n.outPoints[c.outIndex].port == -1){
626
 
                                n.outPoints[c.outIndex].port = parseInt(Math.random()*9000)+1000;
627
 
                                n.outPoints[c.outIndex].el.title = n.outPoints[c.outIndex].port;
628
 
                        }
629
 
                        nodes[c.inNode].inPoints[c.inIndex].port = n.outPoints[c.outIndex].port; 
630
 
                        nodes[c.inNode].inPoints[c.inIndex].el.title = n.outPoints[c.outIndex].port;
631
 
                        //inherit settings from parent
632
 
                        nodes[c.inNode].obj.parent.forEach(function(p){
633
 
                                function inherit(s){
634
 
                                        if(s.name == p.name){
635
 
                                                p.default = s.default;
636
 
                                                console.log("Inherited ",s.name," with value ",p.default);
637
 
                                                return;
638
 
                                        }
639
 
                                }
640
 
                                n.obj.fixed.forEach(inherit);
641
 
                                n.obj.settings.forEach(inherit);
642
 
                                n.obj.parent.forEach(inherit);
643
 
                        }); 
644
 
                });
645
 
        });
646
 
}
647
 
 
648
615
function getThumbnail(original) {
649
616
  var canvas = document.createElement("canvas");
650
617
 
739
706
 
740
707
}*/
741
708
 
742
 
function run(){
 
709
function makePorts(){
 
710
        //reset ports
 
711
        nodes.forEach(function(n){
 
712
                n.inPoints.forEach(function(i){i.port = -1;i.el.title = "no port";});           
 
713
                n.outPoints.forEach(function(i){i.port = -1;i.el.title = "no port";});
 
714
        });
 
715
        //set ports
 
716
        nodes.forEach(function(n){
 
717
                n.connectTo.forEach(function(c){
 
718
                        //set port
 
719
                        if(n.outPoints[c.outIndex].port == -1){
 
720
                                n.outPoints[c.outIndex].port = parseInt(Math.random()*9000)+1000;
 
721
                                n.outPoints[c.outIndex].el.title = n.outPoints[c.outIndex].port;
 
722
                        }
 
723
                        nodes[c.inNode].inPoints[c.inIndex].port = n.outPoints[c.outIndex].port; 
 
724
                        nodes[c.inNode].inPoints[c.inIndex].el.title = n.outPoints[c.outIndex].port;
 
725
                        //inherit settings from parent
 
726
                        nodes[c.inNode].obj.parent.forEach(function(p){
 
727
                                function inherit(s){
 
728
                                        if(s.name == p.name){
 
729
                                                p.default = s.default;
 
730
                                                console.log("Inherited ",s.name," with value ",p.default);
 
731
                                                return;
 
732
                                        }
 
733
                                }
 
734
                                n.obj.fixed.forEach(inherit);
 
735
                                if(n.obj.settings)n.obj.settings.forEach(inherit);
 
736
                                if(n.obj.parent)n.obj.parent.forEach(inherit);
 
737
                        }); 
 
738
                });
 
739
        });
 
740
}
 
741
 
 
742
function play(){
743
743
        console.log("run");
744
744
        makePorts();
745
745
        //create launch string
746
746
        res = "";
747
747
        nodes.forEach(function(n){
748
 
                res += "/"+n.obj.name+"/";
 
748
                res += "/"+encodeURIComponent(n.obj.name)+"/";
 
749
                tmp = "";
749
750
                n.inPoints.forEach(function(i){
750
 
                        res += String(i.port) + " "; 
 
751
                        tmp += String(i.port) + " "; 
751
752
                });
752
753
                n.outPoints.forEach(function(i){
753
 
                        res += String(i.port) + " "; 
754
 
                });
755
 
                n.obj.settings.forEach(function(i){
756
 
                        res += String(i.default) + " "; 
757
 
                });
758
 
                n.obj.parent.forEach(function(i){
759
 
                        res += String(i.default) + " "; 
 
754
                        tmp += String(i.port) + " "; 
 
755
                });
 
756
                if(n.obj.settings)n.obj.settings.forEach(function(i){
 
757
                        tmp += String(i.default) + " "; 
 
758
                });
 
759
                if(n.obj.parent)n.obj.parent.forEach(function(i){
 
760
                        tmp += String(i.default) + " "; 
760
761
                });             
761
 
                res = res.substr(0,res.length-1);
 
762
                res += encodeURIComponent(tmp.substr(0,tmp.length-1));
762
763
        });
763
 
        res = "/run" + res.replace(/ /g,"_");
 
764
        res = "/run" + res;//.replace(/ /g,"_");
764
765
        $get(res);
765
766
        return res;
766
767
}