<commit_before><head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Esplanade</title>
    <meta name="viewport" content="width=device-width" />
    <!--[if lt IE 9]><script src="//static.jstree.com/3.2.1/assets/html5.js"></script><![endif]-->

    <meta name="robots" content="index,follow" />

    <script>window.$q=[];window.$=window.jQuery=function(a){window.$q.push(a);};</script>
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="/feed.xml" />
    <script>WR = "/";</script>
    <meta property="og:title" content="jstree" />
    <meta property="og:type" content="website" />
    <link rel="stylesheet" href="/css/main.css" />
</head>
<body>

    <form method="post" id="show-result" target="result" action="/build">

        <div id="wrapper">
            <header>
                <div style="color: blue; text-decoration: underline; cursor: pointer; cursor: hand;" id="buildandrun">Build and run</div>
                <div style="display: none; color: blue; text-decoration: underline; cursor: pointer; cursor: hand;" id="stoprunning">Stop running</div>
                <select name="fqbn" id="fqbn">
                    <option value="chibitronics:esplanade:code">Chibitronics Code</option>
                    <option value="arduino:avr:uno">Arduino Uno</option>
                    <option value="arduino:sam:arduino_due_x_dbg">Arduino Due (Programming Port)</option>
                    <option value="arduino:sam:arduino_due_x">Arduino Due (Native Port)</option>
                </select>
                <div id="buildoutput"></div>
                <div id="runprogressbar"></div>
                <canvas id="wavStrip" width=6000 height=100 style="border: 1px solid #ddd"></canvas>
                <div id="runprogresstxt"></div>
            </header>
            <div id="content">
                <div id="sidebar">
                    <div id="treething"></div>
                </div>

                <div id="editorthing">void setup() {
    // One-time setup stuff goes here
}

void loop() {
    // Loop code goes here
}</div>
            </div>

        </div>
    </form>

    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="/js/jquery-2.2.0.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="/css/style.min.css" />
    <script src="js/jstree.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/base64-binary.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/WAAPISim-master/waapisim.js" type="text/javascript" charset="utf-8"></script>

    <script src="js/modulate-controller.js"></script>
    <script src="js/modulate.js"></script>
    <script src="js/murmurhash3_gc.js"></script>
    <script src="js/afsk-encoder.js"></script>
    <script src="js/spark-md5.js"></script>

    <script type="text/javascript">
        var editor;
        var codeobj = new Object();
        var mod_controller;
        var totalSize;

        Number.prototype.toFixedDown = function(digits) {
            var re = new RegExp("(\\d+\\.\\d{" + digits + "})(\\d)"),
            m = this.toString().match(re);
            return m ? parseFloat(m[1]) : this.valueOf();
        };

        function updateProgress() {
            progress = mod_controller.progress() * 100;
            progress = 0;
            if (mod_controller.isRunning()) {
                $("#runprogresstxt").html("Loading " + totalSize + " bytes: " + progress.toFixedDown(2) + "%");
                $("#runprogressbar").progressbar({value: progress});
                window.setTimeout(updateProgress, 100);
            }
            else {
                $("#runprogresstxt").html("Done");
                $("#runprogressbar").progressbar({value: progress});
                $("#stoprunning").hide("slow");
                $("#buildandrun").show("slow");
            }
        }
        function buildResult(results, textStatus, jqXHR) {
            if (textStatus != "success") {
                console.log("Don't know what to do.  Backend failure?");
                return;
            }
            if (results.success) {
                $("#buildoutput").html("Build complete");

                totalSize = results.size;
                var data = atob(results.output);

                if (mod_controller)
                    mod_controller.stop();
                mod_controller = new ModulationController();
                mod_controller.sendData(data);
            }
            else {
                $("#buildoutput").html("<pre>" + results.message + "</pre>");
            }
        }

        $(document).ready(function () {
            $("#stoprunning").click(function() {
                if (mod_controller)
                    mod_controller.stop();
            });
            $("#buildandrun").click(function() {
                console.log("Building code...");
                $("#buildoutput").html("Building code...");
                if (mod_controller)
                    mod_controller.stop();
                fqbn_array = $("#fqbn").val().split(":");
                codeobj = {
                    "files": [
                        {
                            "filename": "project.ino",
                            "content": editor.getValue()
                        }
                    ],
                    "format": "binary",
                    "version": "167",
                    "libraries":[],
                    "fqbn": $("#fqbn").val()
                }
                console.log(JSON.stringify(codeobj));
                $.post("//cb-compile.xobs.io/app.php/mycoolkey/v2", JSON.stringify(codeobj), buildResult, "json");
            });
            editor = ace.edit("editorthing");
            editor.setTheme("ace/theme/monokai");
            editor.getSession().setMode("ace/mode/c_cpp");

            $('#treething').jstree({
              "core": {
                "animation": 0,
                "check_callback": true,
                "themes": { "stripes" : true },
                'data': {
                  'url': function (node) {
                return node.id === '#' ?
                  'items.json' : 'examples.json';
                  },
                  'data': function (node) {
                return { 'id' : node.id };
                  }
                }
              },
              "types": {
                "#": {
                  "max_children": 1,
                  "max_depth": 4,
                  "valid_children": ["root"]
                },
                "root": {
                  "icon": "/css/tree_icon.png",
                  "valid_children" : ["default"]
                },
                "default": {
                  "valid_children" : ["default", "file"]
                },
                "file": {
                  "icon" : "glyphicon glyphicon-file",
                  "valid_children" : []
                }
              },
              "plugins" : [
                "state", "types", "wholerow"
              ]
            })
            .on('changed.jstree', function (e, data) {
                if(data && data.selected && data.selected.length) {
                    console.log("Selected " + data.selected);

                    if (data.node.data) {
                        $.get(data.node.data, function (d) {
                            editor.setValue(d, -1);
                        });
                    }
                    else {
                        var ref = $('#treething').jstree(true);
                        ref.open_node(data.node);
                    }
                }
            });
        });
    </script>
</body>
</html>
<commit_msg>index: pass the canvas to the controller<commit_after><head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Esplanade</title>
    <meta name="viewport" content="width=device-width" />
    <!--[if lt IE 9]><script src="//static.jstree.com/3.2.1/assets/html5.js"></script><![endif]-->

    <meta name="robots" content="index,follow" />

    <script>window.$q=[];window.$=window.jQuery=function(a){window.$q.push(a);};</script>
    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="/feed.xml" />
    <script>WR = "/";</script>
    <meta property="og:title" content="jstree" />
    <meta property="og:type" content="website" />
    <link rel="stylesheet" href="/css/main.css" />
</head>
<body>

    <form method="post" id="show-result" target="result" action="/build">

        <div id="wrapper">
            <header>
                <div style="color: blue; text-decoration: underline; cursor: pointer; cursor: hand;" id="buildandrun">Build and run</div>
                <div style="display: none; color: blue; text-decoration: underline; cursor: pointer; cursor: hand;" id="stoprunning">Stop running</div>
                <select name="fqbn" id="fqbn">
                    <option value="chibitronics:esplanade:code">Chibitronics Code</option>
                    <option value="arduino:avr:uno">Arduino Uno</option>
                    <option value="arduino:sam:arduino_due_x_dbg">Arduino Due (Programming Port)</option>
                    <option value="arduino:sam:arduino_due_x">Arduino Due (Native Port)</option>
                </select>
                <div id="buildoutput"></div>
                <div id="runprogressbar"></div>
                <canvas id="wavStrip" width=6000 height=100 style="border: 1px solid #ddd"></canvas>
                <div id="runprogresstxt"></div>
            </header>
            <div id="content">
                <div id="sidebar">
                    <div id="treething"></div>
                </div>

                <div id="editorthing">void setup() {
    // One-time setup stuff goes here
}

void loop() {
    // Loop code goes here
}</div>
            </div>

        </div>
    </form>

    <link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
    <script src="/js/jquery-2.2.0.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
    <link rel="stylesheet" href="/css/style.min.css" />
    <script src="js/jstree.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="/src-noconflict/ace.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/base64-binary.js" type="text/javascript" charset="utf-8"></script>
    <script src="js/WAAPISim-master/waapisim.js" type="text/javascript" charset="utf-8"></script>

    <script src="js/modulate-controller.js"></script>
    <script src="js/modulate.js"></script>
    <script src="js/murmurhash3_gc.js"></script>
    <script src="js/afsk-encoder.js"></script>
    <script src="js/spark-md5.js"></script>

    <script type="text/javascript">
        var editor;
        var codeobj = new Object();
        var mod_controller;
        var totalSize;

        Number.prototype.toFixedDown = function(digits) {
            var re = new RegExp("(\\d+\\.\\d{" + digits + "})(\\d)"),
            m = this.toString().match(re);
            return m ? parseFloat(m[1]) : this.valueOf();
        };

        function updateProgress() {
            progress = mod_controller.progress() * 100;
            progress = 0;
            if (mod_controller.isRunning()) {
                $("#runprogresstxt").html("Loading " + totalSize + " bytes: " + progress.toFixedDown(2) + "%");
                $("#runprogressbar").progressbar({value: progress});
                window.setTimeout(updateProgress, 100);
            }
            else {
                $("#runprogresstxt").html("Done");
                $("#runprogressbar").progressbar({value: progress});
                $("#stoprunning").hide("slow");
                $("#buildandrun").show("slow");
            }
        }
        function buildResult(results, textStatus, jqXHR) {
            if (textStatus != "success") {
                console.log("Don't know what to do.  Backend failure?");
                return;
            }
            if (results.success) {
                $("#buildoutput").html("Build complete");

                totalSize = results.size;
                var data = atob(results.output);

                if (mod_controller)
                    mod_controller.stop();
                mod_controller = new ModulationController({
                    canvas: $("#wavStrip")
                });
                mod_controller.sendData(data);
            }
            else {
                $("#buildoutput").html("<pre>" + results.message + "</pre>");
            }
        }

        $(document).ready(function () {
            $("#stoprunning").click(function() {
                if (mod_controller)
                    mod_controller.stop();
            });
            $("#buildandrun").click(function() {
                console.log("Building code...");
                $("#buildoutput").html("Building code...");
                if (mod_controller)
                    mod_controller.stop();
                fqbn_array = $("#fqbn").val().split(":");
                codeobj = {
                    "files": [
                        {
                            "filename": "project.ino",
                            "content": editor.getValue()
                        }
                    ],
                    "format": "binary",
                    "version": "167",
                    "libraries":[],
                    "fqbn": $("#fqbn").val()
                }
                console.log(JSON.stringify(codeobj));
                $.post("//cb-compile.xobs.io/app.php/mycoolkey/v2", JSON.stringify(codeobj), buildResult, "json");
            });
            editor = ace.edit("editorthing");
            editor.setTheme("ace/theme/monokai");
            editor.getSession().setMode("ace/mode/c_cpp");

            $('#treething').jstree({
              "core": {
                "animation": 0,
                "check_callback": true,
                "themes": { "stripes" : true },
                'data': {
                  'url': function (node) {
                return node.id === '#' ?
                  'items.json' : 'examples.json';
                  },
                  'data': function (node) {
                return { 'id' : node.id };
                  }
                }
              },
              "types": {
                "#": {
                  "max_children": 1,
                  "max_depth": 4,
                  "valid_children": ["root"]
                },
                "root": {
                  "icon": "/css/tree_icon.png",
                  "valid_children" : ["default"]
                },
                "default": {
                  "valid_children" : ["default", "file"]
                },
                "file": {
                  "icon" : "glyphicon glyphicon-file",
                  "valid_children" : []
                }
              },
              "plugins" : [
                "state", "types", "wholerow"
              ]
            })
            .on('changed.jstree', function (e, data) {
                if(data && data.selected && data.selected.length) {
                    console.log("Selected " + data.selected);

                    if (data.node.data) {
                        $.get(data.node.data, function (d) {
                            editor.setValue(d, -1);
                        });
                    }
                    else {
                        var ref = $('#treething').jstree(true);
                        ref.open_node(data.node);
                    }
                }
            });
        });
    </script>
</body>
</html>

{'fraction_non_alphanumeric': 0.16596783278052443, 'fraction_numerical': 0.0067588710182114025, 'mean_word_length': 1.5205047318611988, 'pattern_counts': {'":': 42, '<': 177, '<?xml version=': 0, '>': 177, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2705796', 'n_tokens_mistral': 4640, 'n_tokens_neox': 4346, 'n_words': 732}