<commit_before>// Data ******************************************

var id = undefined;
var token = undefined;
var state = undefined;
var editor = undefined;
var gref = {
    "client_id": "758681145932-be7pq7936jb71v6h23h2nen6ivak2vc2.apps.googleusercontent.com",
    "discoveryDocs": ["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"],
};

// Helper ******************************************

function getParam(name) {
    return (new URL(window.location.href)).searchParams.get(name);
}

function uiShowDesktop() {
    $('#desktop').css("visibility", "visible");
}

function uiHideInfo() {
    $('#info').css("visibility", "hidden");
}

// Start/Entrypoint ******************************************

$(function() {
    // ACE
    editor = ace.edit("editor");
    editor.renderer.setShowGutter(true);
    editor.setOption("wrap", true);
    editor.setOption("indentedSoftWrap", false);
    // Export functions
    window.saveFile = saveFile;
    // Check params
    state = getParam("state");
    if (state == undefined) return;
    $("#info").html("Please wait...");
    if (state == "installation" || state == "Installation") {
        gapi.load('client:auth2', initClientInstall);
    } else {
        gapi.load('client:auth2', initClient);
    }
})

// Init and execute ******************************************

function initClientInstall() {
    gref.scope = "https://www.googleapis.com/auth/drive.install";
    gapi.client.init(gref).then(function() {
        gapi.auth2.getAuthInstance().signIn().then(function() {
            $('#info').html("Installation done.");
        }).catch(function(err) {
            $("#info").html("Installation error! " + err.error);
            console.log(err);
        });
    }).catch(function(err) {
        $("#info").html("Installation error! " + err.error);
        console.log(err);
    });
};

function initClient() {
    gref.scope = "https://www.googleapis.com/auth/drive";
    gapi.client.init(gref).then(function() {
        if (gapi.auth2.getAuthInstance().currentUser.get().isSignedIn()) {
            exe();
        } else {
            gapi.auth2.getAuthInstance().signIn().then(function() {
                exe();
            }).catch(function(err) {
                $("#info").html("Error! See console for details.");
                console.log(err);
            });
        }
    }).catch(function(err) {
        $("#info").html("Error! See console for details.");
        console.log(err);
    });
}

function exe() {
    // User
    $('#userimage').attr("src",gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile().getImageUrl());
    // Misc
    token = gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse(true).access_token;
    state = JSON.parse(getParam("state"));
    if (state == undefined) return;
    if (state.action == "open") {
        id = state.ids[0];
        showContent(id);
    } else
    if (state.action == "create") {
        uiHideInfo();
        uiShowDesktop();
        editor.gotoLine(0);
        editor.focus();
    }
}

// Operations ******************************************

function showContent(id) {<commit_msg>Anpassungen zur Installation und Ausführung.<commit_after>// Data ******************************************

var id = undefined;
var token = undefined;
var state = undefined;
var editor = undefined;
var gref = {
    "client_id": "758681145932-be7pq7936jb71v6h23h2nen6ivak2vc2.apps.googleusercontent.com",
    "discoveryDocs": ["https://www.googleapis.com/discovery/v1/apis/drive/v3/rest"],
};

// Helper ******************************************

function getParam(name) {
    return (new URL(window.location.href)).searchParams.get(name);
}

function uiShowDesktop() {
    $('#desktop').css("visibility", "visible");
}

function uiHideInfo() {
    $('#info').css("visibility", "hidden");
}

// Start/Entrypoint ******************************************

$(function() {
    // ACE
    $('#editor').css("visibility","hidden");
    editor = ace.edit("editor");
    editor.renderer.setShowGutter(true);
    editor.setOption("wrap", true);
    editor.setOption("indentedSoftWrap", false);
    // Export functions
    window.saveFile = saveFile;
    // Check params
    state = getParam("state");
    if (state == undefined) return;
    $("#info").html("Please wait...");
    if (state == "installation" || state == "Installation") {
        gapi.load('client:auth2', initClientInstall);
    } else {
        gapi.load('client:auth2', initClient);
    }
})

// Init and execute ******************************************

function initClientInstall() {
    $('#sbtn').prop('disabled', true);
    gref.scope = "https://www.googleapis.com/auth/drive.install";
    gapi.client.init(gref).then(function() {
        gapi.auth2.getAuthInstance().signIn().then(function() {
            $('#info').html("Installation done.");
        }).catch(function(err) {
            $("#info").html("Installation error! " + err.error);
            console.log(err);
        });
    }).catch(function(err) {
        $("#info").html("Installation error! " + err.error);
        console.log(err);
    });
};

function initClient() {
    gref.scope = "https://www.googleapis.com/auth/drive";
    gapi.client.init(gref).then(function() {
        if (gapi.auth2.getAuthInstance().currentUser.get().isSignedIn()) {
            exe();
        } else {
            gapi.auth2.getAuthInstance().signIn().then(function() {
                exe();
            }).catch(function(err) {
                $("#info").html("Error! See console for details.");
                console.log(err);
            });
        }
    }).catch(function(err) {
        $("#info").html("Error! See console for details.");
        console.log(err);
    });
}

function exe() {
    // Editor
    $('#editor').css("visibility","visible");
    // User
    $('#userimage').attr("src",gapi.auth2.getAuthInstance().currentUser.get().getBasicProfile().getImageUrl());
    // Misc
    token = gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse(true).access_token;
    state = JSON.parse(getParam("state"));
    if (state == undefined) return;
    if (state.action == "open") {
        id = state.ids[0];
        showContent(id);
    } else
    if (state.action == "create") {
        uiHideInfo();
        uiShowDesktop();
        editor.gotoLine(0);
        editor.focus();
    }
}

// Operations ******************************************

function showContent(id) {
{'fraction_non_alphanumeric': 0.23943007588663465, 'fraction_numerical': 0.011460430540498683, 'mean_word_length': 3.038774233896185, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 6, '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': '1591135', 'n_tokens_mistral': 1964, 'n_tokens_neox': 1912, 'n_words': 297}