<commit_before>window.jermaine.util.namespace("window.ide", function (ns) {
    var Button = ns.models.Button;
    var DirectoryView = ns.views.DirectoryView;

    var IDEView = new window.jermaine.View (function () {
        var messageTimer,
            messageTimeout = 5000;

        this.hasA("directoryView").which.validatesWith(function (v) {
            return v instanceof DirectoryView;
        });

        this.respondsTo("toggleEditorAndDirectory", function () {
            var that = this;
            var direction = $("#ide").is(":visible")?"lr":"rl";
            var elementA = $("#ide").is(":visible")?$("#ide"):$("#IDE-directory");
            var elementB = $("#ide").is(":visible")?$("#IDE-directory"):$("#ide");

            $("#IDE-share").hide();

            
            elementA.flip({
                speed: 200,
                direction:direction,
                color:"#fff",
                onBefore: function () {
                    elementA.hide();
                    $("#IDE-title").unbind("click");
                },
                onEnd: function () {
                    elementB.show();
                    if ($("#empty_directory").size() === 0) {
                        $("#IDE-title").click(function () {
                            that.toggleEditorAndDirectory();
                        });
                    }
                    //this is a hack to force Ace to update when the editor
                    //becomes visible again
                    if ($("#ide").is(":visible")) {
                        that.instance().editor().setValue(that.instance().editor().getValue());
                        that.instance().editor().gotoLine(0,0);
                    }
                    
                }
            });
        });

        this.respondsTo("addButtons", function () {
            var that = this;

            this.instance().buttons().add(new Button("run", "ide/images/icons/run.png", function () {
                that.instance().messages().add("running program");
                return false;
            }));

            if ($("#ide").hasClass("server")) {
                this.instance().buttons().add(new Button("save", "ide/images/icons/save.png", function () {
                    if (that.instance().changedFlag() === false) {
                        that.instance().messages().add("no changes need to be saved");
                    } else {
                        that.instance().project().source(that.instance().editor().getSession().getValue());
                        that.instance().project().save(function (response) {
                            that.instance().messages().add(response);
                            that.instance().changedFlag(false);
                        });
                    }
                }));

                this.instance().buttons().add(new Button("share", "ide/images/icons/share.png", function () {
                    var project = that.instance().project(),
                        code = that.instance().editor().getSession().getValue(),
                        shareTemplate = Handlebars.compile($.trim($("#share-template").html()));
                        url = "http://"+window.location.host +
                              "/"+project.user()+"/" +
                              project.url().match(/sketches\/(.*).json/)[1] +
                              "/embed/";

                    var dims = code.match(/size\s*\(\s*(\d+)\s*,\s*(\d+)/);

                    if (dims !== null && dims.length === 3) {
                        width = dims[1];
                        height = dims[2];
                    } else {
                        width = 200;
                        height = 200;
                    }

                    $("#IDE-share #share_link").val(shareTemplate({"url":url, "width":width, "height":height}));
                    $("#IDE-share").slideToggle();
                }));

                this.instance().buttons().add(new Button("share", "images/icons/attach.png", function () {
                    $("#IDE-attach").slideToggle();
                }));


            }
        });

        this.respondsTo("setUpAttachButton", function () {
            var that = this;
            var validFile = function(filename)  {
                var validList = ['jpg','jpeg','gif','png','svg'];
                var i;
                if(filename.match(/\.(jpg|jpeg|gif|png|svg)$/))  {
                    return true;
                }  else  {
                    return false;
                }
            };

            $("#attach_submit_button").click(function(evt)  {
                var file = $("input#file_input").val();
                var postURL = that.instance().project().url().match(/(.*).json/)[1]+"/attach/"; 
                if(file === "")  {
                    alert("please select a file");
                } else if(!validFile(file))  {<commit_msg>fix broken link for attach button<commit_after>window.jermaine.util.namespace("window.ide", function (ns) {
    var Button = ns.models.Button;
    var DirectoryView = ns.views.DirectoryView;

    var IDEView = new window.jermaine.View (function () {
        var messageTimer,
            messageTimeout = 5000;

        this.hasA("directoryView").which.validatesWith(function (v) {
            return v instanceof DirectoryView;
        });

        this.respondsTo("toggleEditorAndDirectory", function () {
            var that = this;
            var direction = $("#ide").is(":visible")?"lr":"rl";
            var elementA = $("#ide").is(":visible")?$("#ide"):$("#IDE-directory");
            var elementB = $("#ide").is(":visible")?$("#IDE-directory"):$("#ide");

            $("#IDE-share").hide();

            
            elementA.flip({
                speed: 200,
                direction:direction,
                color:"#fff",
                onBefore: function () {
                    elementA.hide();
                    $("#IDE-title").unbind("click");
                },
                onEnd: function () {
                    elementB.show();
                    if ($("#empty_directory").size() === 0) {
                        $("#IDE-title").click(function () {
                            that.toggleEditorAndDirectory();
                        });
                    }
                    //this is a hack to force Ace to update when the editor
                    //becomes visible again
                    if ($("#ide").is(":visible")) {
                        that.instance().editor().setValue(that.instance().editor().getValue());
                        that.instance().editor().gotoLine(0,0);
                    }
                    
                }
            });
        });

        this.respondsTo("addButtons", function () {
            var that = this;

            this.instance().buttons().add(new Button("run", "ide/images/icons/run.png", function () {
                that.instance().messages().add("running program");
                return false;
            }));

            if ($("#ide").hasClass("server")) {
                this.instance().buttons().add(new Button("save", "ide/images/icons/save.png", function () {
                    if (that.instance().changedFlag() === false) {
                        that.instance().messages().add("no changes need to be saved");
                    } else {
                        that.instance().project().source(that.instance().editor().getSession().getValue());
                        that.instance().project().save(function (response) {
                            that.instance().messages().add(response);
                            that.instance().changedFlag(false);
                        });
                    }
                }));

                this.instance().buttons().add(new Button("share", "ide/images/icons/share.png", function () {
                    var project = that.instance().project(),
                        code = that.instance().editor().getSession().getValue(),
                        shareTemplate = Handlebars.compile($.trim($("#share-template").html()));
                        url = "http://"+window.location.host +
                              "/"+project.user()+"/" +
                              project.url().match(/sketches\/(.*).json/)[1] +
                              "/embed/";

                    var dims = code.match(/size\s*\(\s*(\d+)\s*,\s*(\d+)/);

                    if (dims !== null && dims.length === 3) {
                        width = dims[1];
                        height = dims[2];
                    } else {
                        width = 200;
                        height = 200;
                    }

                    $("#IDE-share #share_link").val(shareTemplate({"url":url, "width":width, "height":height}));
                    $("#IDE-share").slideToggle();
                }));

                this.instance().buttons().add(new Button("share", "ide/images/icons/attach.png", function () {
                    $("#IDE-attach").slideToggle();
                }));


            }
        });

        this.respondsTo("setUpAttachButton", function () {
            var that = this;
            var validFile = function(filename)  {
                var validList = ['jpg','jpeg','gif','png','svg'];
                var i;
                if(filename.match(/\.(jpg|jpeg|gif|png|svg)$/))  {
                    return true;
                }  else  {
                    return false;
                }
            };

            $("#attach_submit_button").click(function(evt)  {
                var file = $("input#file_input").val();
                var postURL = that.instance().project().url().match(/(.*).json/)[1]+"/attach/"; 
                if(file === "")  {
                    alert("please select a file");
                } else if(!validFile(file))  {
{'fraction_non_alphanumeric': 0.1660931174089069, 'fraction_numerical': 0.004251012145748988, 'mean_word_length': 1.2783029744062717, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '3294473', 'n_tokens_mistral': 2478, 'n_tokens_neox': 2311, 'n_words': 375}