<commit_before>/**
 * editor.js
 */
//document.write('<title>Editing: '+CommonUtilities.getQueryParameter('path')+'</title>');


Actions = {
    getFile : function(){
        $.ajax({
            url:'http://' + location.host + '/rest/app/' + Actions.getQueryParameter('path'),
            data:'app_name=filemanager&method=GET',
            cache:false,
            success:function (response) {
               Actions.loadEditor(response);
            },
            error:function (response) {
                if (response.status == 401) {
                    $("#loginDialog").modal('toggle');
                }
            }
        });
    },
    saveFile:function(){
        $.ajax({
            url:'http://' + location.host + '/rest/app/' + Actions.getQueryParameter('path'),
            data:'app_name=filemanager&method=MERGE',
            type:'POST',
            cache:false,
            success:function (response) {
                //window.close();
            },
            error:function (response) {
                if (response.status == 401) {
                    $("#loginDialog").modal('toggle');
                }
            }
        });
    },
    loadEditor:function(contents){
        console.log('loaded');
        Editor = ace.edit("editor");
        Editor.setTheme("ace/theme/twilight");
        Editor.getSession().setMode("ace/mode/javascript");
        Editor.setValue(contents);

        $("#save").click(function(){
           Actions.saveFile();
        });

        $("#close").click(function(){
            window.close();
        });
    },
    getQueryParameter: function(key) {
        key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&");
        var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
        return match && decodeURIComponent(match[1].replace(/\+/g, " "));
    }
};
$(document).ready(function(){
	Actions.getFile();
	
});<commit_msg>editor now saves<commit_after>/**
 * editor.js
 */
//document.write('<title>Editing: '+CommonUtilities.getQueryParameter('path')+'</title>');


Actions = {
    getFile : function(){
        $.ajax({
            url:'http://' + location.host + '/rest/app/' + Actions.getQueryParameter('path'),
            data:'app_name=filemanager&method=GET',
            cache:false,
            success:function (response) {
                Actions.loadEditor(response);
            },
            error:function (response) {
                if (response.status == 401) {
                    $("#loginDialog").modal('toggle');
                }
            }
        });
    },
    getFileName:function () {
        var pathArray = Actions.getQueryParameter('path').split('/');

        return pathArray[pathArray.length - 1];
    },
    saveFile:function(){
        $.ajax({
            url:'http://' + location.host + '/rest/app/' + Actions.getQueryParameter('path') + '?&app_name=filemanager&method=MERGE',
            data: Editor.getValue(),
            type:'POST',
            cache:false,
            beforeSend: function(xhr) {
                xhr.setRequestHeader("X-File-Name",Actions.getFileName());
            },
            success:function (response) {
                window.close();
            },
            error:function (response) {
                if (response.status == 401) {
                    $("#loginDialog").modal('toggle');
                }
            }
        });
    },
    loadEditor:function(contents){
        console.log('loaded');
        Editor = ace.edit("editor");
        Editor.setTheme("ace/theme/twilight");
        Editor.getSession().setMode("ace/mode/javascript");
        Editor.setValue(contents);

        $("#save").click(function(){
            Actions.saveFile();
        });

        $("#close").click(function(){
            window.close();
        });
    },
    getQueryParameter: function(key) {
        key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&");
        var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
        return match && decodeURIComponent(match[1].replace(/\+/g, " "));
    }
};
$(document).ready(function(){
    Actions.getFile();

});
{'fraction_non_alphanumeric': 0.19334619093539054, 'fraction_numerical': 0.0036162005785920926, 'mean_word_length': 1.8417808219178082, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1426618', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1132, 'n_words': 144}