<commit_before><html>
<head>
    <title>Lumify: User Admin</title>
    <script src='/libs/jquery/jquery.js'></script>
    <script src='/libs/ejs/ejs.js'></script>
</head>
<body>
<h1>Lumify: User Admin</h1>

<h3>Me</h3>

<div id="me-user-id"></div>
<div id="me-user-name"></div>

<h3>User ID</h3>

<div id="user-id"></div>

<h3>User name</h3>

<form method="GET">
    <input type="text" name="user-name" id="user-name"/>
    <input type="submit" value="Load User"/>
</form>

<h3>Privileges</h3>

<ul>
    <li><input type="checkbox" id="privilege-read" onchange="updatePrivileges()"> Read</li>
    <li><input type="checkbox" id="privilege-edit" onchange="updatePrivileges()"> Edit</li>
    <li><input type="checkbox" id="privilege-publish" onchange="updatePrivileges()"> Publish</li>
    <li><input type="checkbox" id="privilege-admin" onchange="updatePrivileges()"> Admin</li>
</ul>

<h3>Authorizations</h3>

<ul id="authorizations"></ul>

<h3>Add Authorizations</h3>

<form>
    Value: <input type="text" id="new-auth"/>
    <button id="add">Add Auth</button>
</form>

<h3>Workspaces</h3>

<h4>Current Workspace</h4>
<div id="current-workspace"></div>

<h4>Workspaces</h4>
<ul id="workspaces"></ul>

<button onclick="deleteUser()">Delete User</button>

<script type="text/javascript">
    $.ajaxPrefilter(function(options) {
        var eligibleForProtection = options.type !== 'GET',
            token = window.token;

        if (eligibleForProtection && token) {
            options.headers = $.extend(options.headers || {}, {
                'Lumify-CSRF-Token': token
            });
        }
    });

    $(function () {
        document.authorizationsTemplate = document.getElementById('authorizationsTemplate').innerHTML;
        document.workspacesTemplate = document.getElementById('workspacesTemplate').innerHTML;

        $('#add').click(function () {
            try {
                var auth = $('#new-auth').val();
                $.ajax({
                    type: 'POST',
                    url: '/user/auth/add',
                    data: { auth: auth },
                    success: function (data) {
                        console.log(data);
                        $('#new-auth').val('');
                        reload();
                    }
                });
            } catch (e) {
                console.log('could not add auth', e);
            }
            return false;
        });

        reload();
    });

    function reload() {
        var url = '/user/me';
        var userNameParameter = getURLParameter('user-name');
        if(userNameParameter) {
            url = '/user?user-name=' + encodeURIComponent(userNameParameter);
        }

        $.ajax({
            url: url,
            success: function (data) {
                console.log(data);
                $('#user-id').html(data.id);
                $('#user-name').val(data.userName);
                var html = ejs.render(document.authorizationsTemplate, data);
                $('#authorizations').html(html);
                $('#privilege-read').attr('checked', data.privileges.indexOf('READ') >= 0);
                $('#privilege-edit').attr('checked', data.privileges.indexOf('EDIT') >= 0);
                $('#privilege-publish').attr('checked', data.privileges.indexOf('PUBLISH') >= 0);
                $('#privilege-admin').attr('checked', data.privileges.indexOf('ADMIN') >= 0);

                $('#current-workspace').html(document.currentWorkspaceId);
                html = ejs.render(document.workspacesTemplate, data);
                $('#workspaces').html(html);
            },
            dataType: 'json'
        });

        $.ajax({<commit_msg>Fix js error on admin page<commit_after><html>
<head>
    <title>Lumify: User Admin</title>
    <script src='/libs/jquery/jquery.js'></script>
    <script src='/libs/ejs/ejs.js'></script>
</head>
<body>
<h1>Lumify: User Admin</h1>

<h3>Me</h3>

<div id="me-user-id"></div>
<div id="me-user-name"></div>

<h3>User ID</h3>

<div id="user-id"></div>

<h3>User name</h3>

<form method="GET">
    <input type="text" name="user-name" id="user-name"/>
    <input type="submit" value="Load User"/>
</form>

<h3>Privileges</h3>

<ul>
    <li><input type="checkbox" id="privilege-read" onchange="updatePrivileges()"> Read</li>
    <li><input type="checkbox" id="privilege-edit" onchange="updatePrivileges()"> Edit</li>
    <li><input type="checkbox" id="privilege-publish" onchange="updatePrivileges()"> Publish</li>
    <li><input type="checkbox" id="privilege-admin" onchange="updatePrivileges()"> Admin</li>
</ul>

<h3>Authorizations</h3>

<ul id="authorizations"></ul>

<h3>Add Authorizations</h3>

<form>
    Value: <input type="text" id="new-auth"/>
    <button id="add">Add Auth</button>
</form>

<h3>Workspaces</h3>

<h4>Current Workspace</h4>
<div id="current-workspace"></div>

<h4>Workspaces</h4>
<ul id="workspaces"></ul>

<button onclick="deleteUser()">Delete User</button>

<script type="text/javascript">
    $.ajaxPrefilter(function(options) {
        var eligibleForProtection = options.type !== 'GET',
            token = window.token;

        if (eligibleForProtection && token) {
            options.headers = $.extend(options.headers || {}, {
                'Lumify-CSRF-Token': token
            });
        }
    });

    $(function () {
        document.authorizationsTemplate = document.getElementById('authorizationsTemplate').innerHTML;
        document.workspacesTemplate = document.getElementById('workspacesTemplate').innerHTML;

        $('#add').click(function () {
            try {
                var auth = $('#new-auth').val();
                $.ajax({
                    type: 'POST',
                    url: '/user/auth/add',
                    data: { auth: auth },
                    success: function (data) {
                        console.log(data);
                        $('#new-auth').val('');
                        reload();
                    }
                });
            } catch (e) {
                console.log('could not add auth', e);
            }
            return false;
        });

        reload();
    });

    function reload() {
        var url = '/user/me';
        var userNameParameter = getURLParameter('user-name');
        if(userNameParameter) {
            url = '/user?user-name=' + encodeURIComponent(userNameParameter);
        }

        $.ajax({
            url: url,
            success: function (data) {
                console.log(data);
                $('#user-id').html(data.id);
                $('#user-name').val(data.userName);
                var html = ejs.render(document.authorizationsTemplate, data);
                $('#authorizations').html(html);
                $('#privilege-read').attr('checked', data.privileges.indexOf('READ') >= 0);
                $('#privilege-edit').attr('checked', data.privileges.indexOf('EDIT') >= 0);
                $('#privilege-publish').attr('checked', data.privileges.indexOf('PUBLISH') >= 0);
                $('#privilege-admin').attr('checked', data.privileges.indexOf('ADMIN') >= 0);

                $('#current-workspace').html(data.currentWorkspaceId);
                if (data.workspaces) {
                    html = ejs.render(document.workspacesTemplate, data);
                    $('#workspaces').html(html);
                }
            },
            dataType: 'json'
        });

        $.ajax({
{'fraction_non_alphanumeric': 0.18300565580393213, 'fraction_numerical': 0.006463775922434689, 'mean_word_length': 2.183454779254179, 'pattern_counts': {'":': 0, '<': 139, '<?xml version=': 0, '>': 147, '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': '6716081', 'n_tokens_mistral': 2300, 'n_tokens_neox': 2212, 'n_words': 366}