<commit_before><?php include '_header.phtml';
/* @var $user BuildMyCV\classes\User */
?>

<style>
    legend{font-size: large}
    input, textArea{width:400px; font-family: monospace;border-bottom: 1px dashed gray;border-top: none;border-left: none;border-right: none;}
    fieldset{display: inline-block; max-width: 400px}
    button.json-editor-btn-edit {display: none}
</style>

<h1>Admin</h1>

<div id="editor_holder"></div>

<input id="submit" type="submit">

<script src="/js/jsoneditor.min.js"></script>

<script>
    
    /* 
     * function to get json object from an url
     * picked from: http://stackoverflow.com/a/14388512/5935198
    */
    function fetchJSONFile(path, callback) {
        var httpRequest = new XMLHttpRequest();
        httpRequest.onreadystatechange = function() {
            if (httpRequest.readyState === 4) {
                if (httpRequest.status === 200) {
                    var data = JSON.parse(httpRequest.responseText);
                    if (callback) callback(data);
                }
            }
        };
        httpRequest.open('GET', path);
        httpRequest.send(); 
    }
    
    fetchJSONFile('/schema.json', function(ajax_shema){
        var editor = new JSONEditor(document.getElementById('editor_holder'),{
        schema: ajax_shema
        
      });
      
      // Hook up the submit button to log to the console
      document.getElementById('submit').addEventListener('click',function() {
        // Get the value from the editor
        var xmlhttp = new XMLHttpRequest();   // new HttpRequest instance 
        xmlhttp.open("POST", "/admin");
        xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
        xmlhttp.send(JSON.stringify( editor.getValue(), null, 2 ));
      });
      
    })
    
      
      
</script>

<?php include '_footer.phtml'?><commit_msg>Laod data.json into the admin form<commit_after><?php include '_header.phtml';
/* @var $user BuildMyCV\classes\User */
?>

<style>
    legend{font-size: large}
    input, textArea{width:400px; font-family: monospace;border-bottom: 1px dashed gray;border-top: none;border-left: none;border-right: none;}
    fieldset{display: inline-block; max-width: 400px}
    button.json-editor-btn-edit {display: none}
</style>

<h1>Admin</h1>

<div id="editor_holder"></div>

<input id="submit" type="submit">

<script src="/js/jsoneditor.min.js"></script>

<script>
    
    /* 
     * function to get json object from an url
     * picked from: http://stackoverflow.com/a/14388512/5935198
    */
    function fetchJSONFile(path, callback) {
        var httpRequest = new XMLHttpRequest();
        httpRequest.onreadystatechange = function() {
            if (httpRequest.readyState === 4) {
                if (httpRequest.status === 200) {
                    var data = JSON.parse(httpRequest.responseText);
                    if (callback) callback(data);
                }
            }
        };
        httpRequest.open('GET', path);
        httpRequest.send(); 
    }
    
    fetchJSONFile('/schema.json', function(ajax_shema){
        fetchJSONFile('/data.json', function(ajax_data){
        var editor = new JSONEditor(document.getElementById('editor_holder'),{
        schema: ajax_shema,
        startval: ajax_data
        
      });
      
      // Hook up the submit button to log to the console
      document.getElementById('submit').addEventListener('click',function() {
        // Get the value from the editor
        var xmlhttp = new XMLHttpRequest();   // new HttpRequest instance 
        xmlhttp.open("POST", "/admin");
        xmlhttp.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
        xmlhttp.send(JSON.stringify( editor.getValue(), null, 2 ));
      });
      
      })
      
    })
    
      
      
</script>

<?php include '_footer.phtml'?>
{'fraction_non_alphanumeric': 0.1390402075226978, 'fraction_numerical': 0.01556420233463035, 'mean_word_length': 2.4582959641255604, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, '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': '5185288', 'n_tokens_mistral': 1176, 'n_tokens_neox': 1115, 'n_words': 238}