<commit_before><!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Client storage test.</title>
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
        <script type="text/javascript" src="http://code.jquery.com/jquery-git2.js"></script>
        <script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
        <link rel="author" href="humans.txt">
    </head>
    <body>
      <div class="container">
        <h1>Client storage test</h1>
        <form  class="form-horizontal">
          <div class="form-group">
            <label for="single-elt">JSON to test</label>
            <textarea  class="form-control" name="singleElt" rows="6"></textarea>         
          </div>
          <div class="form-group">
            <label for="ajustment">0%</label>
            <input type="range" min="0" max="100" step="1" id="ajustment" value="0" name="ajustment" />  
          </div>
          <div class="form-group">
            <label for="nbObject">Nombre d'objet à insérer.</label>
            <input type="number" min="0" max="100000" step="1" id="nbObject" value="0" name="nbObject" />  
          </div>
          <button class="btn btn-primary" type="sybmit">Tester</button>
        </form>
        <div id='notifications'>
          
        </div>
      </div>
        
        <script type="text/javascript">

          //Repeat the string pattern.
          String.prototype.repeat = function(num) {
            return new Array(num + 1).join(this);
          }
        
          //Guid function.
          var guid = (function() {
            function s4() {
              return Math.floor((1 + Math.random()) * 0x10000)
                .toString(16)
                .substring(1);
            }
            return function() {
              return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
                s4() + '-' + s4() + s4() + s4();
            };
          })();
          function toObject(arr) {
            var rv = {};
            for (var i = 0; i < arr.length; ++i)
              rv[arr[i].name] = arr[i].value;
            return rv;
          }
          //Update the slider label.
          $('input[name="ajustment"]').on('change', function(e){
            $('label[for="ajustment"]').html(e.target.value + "%");
          });

          //Submit form event.
          $('form').on('submit', function(e){
            e.preventDefault();
            var data = $(this).serializeArray();
            populateLocalStorage(toObject(data));
          });
          
          function populateLocalStorage(data){
            data = data || {};
            var json =jQuery.parseJSON( data.singleElt) || {};
            var coeff = Math.floor( 1 +((data.ajustment || 0)/100))+1 ;
            //Increase the json size.
            for(prop in json){
              var stringJson = ""+ json[prop];
              json[prop] =  stringJson.repeat(stringJson.length * coeff); 
            }
            var stringifyJSON = JSON.stringify(json);
            var limit = 0;
            for (var i = 0; i < +(data.nbObject||0); i++) {
              try {
                localStorage.setItem(guid(), stringifyJSON)
              } catch (e) {
                console.log("LIMIT REACHED: (" + i + ")");
                limit = i;
                break;
              }
            }
            var message = function(){
              if(limit === 0){
                return "La limite n'est pas atteinte, vous pouvez stocker "+data.nbObject+ " sans problèmes";
              }else {
                return 'La limite est de ' + limit + " objets de longeur " + stringifyJSON.length;
              }
            }();
            $('#notifications').html("<p class='bg-danger'>"+message+"</p>");
          }
        </script>
    </body>
</html><commit_msg>Improve JSON parsing. Add clean message.<commit_after><!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>Client storage test.</title>
        <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
        <script type="text/javascript" src="http://code.jquery.com/jquery-git2.js"></script>
        <script type="text/javascript" src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
        <link rel="author" href="humans.txt">
    </head>
    <body>
      <div class="container">
        <h1>Client storage test</h1>
        <form  class="form-horizontal">
          <div class="form-group">
            <label for="single-elt">JSON to test</label>
            <textarea  class="form-control" name="singleElt" rows="6"></textarea>         
          </div>
          <div class="form-group">
            <label for="ajustment">0%</label>
            <input type="range" min="0" max="100" step="1" id="ajustment" value="0" name="ajustment" />  
          </div>
          <div class="form-group">
            <label for="nbObject">Nombre d'objet à insérer.</label>
            <input type="number" min="0" max="100000" step="1" id="nbObject" value="0" name="nbObject" />  
          </div>
          <button class="btn btn-primary" type="sybmit">Tester</button>
        </form>
        <div class="container" id='notifications'></div>
      </div>
        
        <script type="text/javascript">

          //Repeat the string pattern.
          String.prototype.repeat = function(num) {
            return new Array(num + 1).join(this);
          }
        
          //Guid function.
          var guid = (function() {
            function s4() {
              return Math.floor((1 + Math.random()) * 0x10000)
                .toString(16)
                .substring(1);
            }
            return function() {
              return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
                s4() + '-' + s4() + s4() + s4();
            };
          })();
          function toObject(arr) {
            var rv = {};
            for (var i = 0; i < arr.length; ++i)
              rv[arr[i].name] = arr[i].value;
            return rv;
          }
          //Update the slider label.
          $('input[name="ajustment"]').on('change', function(e){
            $('label[for="ajustment"]').html(e.target.value + "%");
          });

          //Submit form event.
          $('form').on('submit', function(e){
            e.preventDefault();
            var data = $(this).serializeArray();
            populateLocalStorage(toObject(data));
          });
          
          function renderNotification(message){
            $('#notifications').html("<div class='alert bg-"+message.type+"'>"+message.text+"</div>");
          };

          function populateLocalStorage(data){
            localStorage.clear();
             $('#notifications').html({type: "info", text:'En cours de traitement ...'})
            data = data || {};
            var json;
            try{
              json = jQuery.parseJSON(data.singleElt)
            }catch(e){
              renderNotification({type: "danger", text: "Le text inséré n'est pas un JSON valide."});
              return "";
            }

            var coeff = Math.floor( 1 +((data.ajustment || 0)/100))+1 ;
            //Increase the json size.
            for(prop in json){
              var stringJson = ""+ json[prop];
              json[prop] =  stringJson.repeat(stringJson.length * coeff); 
            }
            var stringifyJSON = JSON.stringify(json);
            var limit = 0;
            for (var i = 0; i < +(data.nbObject||0); i++) {
              try {
                localStorage.setItem(guid(), stringifyJSON)
              } catch (e) {
                console.log("LIMIT REACHED: (" + i + ")");
                limit = i;
                break;
              }
            }
            var message = function(){
              if(limit === 0){
                return{type: "success", text: "La limite n'est pas atteinte, vous pouvez stocker "+data.nbObject+ " objets de longeur moyenne: "+ stringifyJSON.length +" sans problèmes."};
              }else {
                return {type: "danger", text: 'La limite est de ' + limit + " objets de longeur textuelle moyenne de " + stringifyJSON.length+ "."};
              }
            }();
            renderNotification(message);
          }
        </script>
    </body>
</html>
{'fraction_non_alphanumeric': 0.16490096729617687, 'fraction_numerical': 0.013588208198986642, 'mean_word_length': 1.6519083969465649, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 99, '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': '1483140', 'n_tokens_mistral': 2574, 'n_tokens_neox': 2481, 'n_words': 518}