<commit_before><html>
  <head>
    <title>gDriveSync</title>
    <script src="../lib/login.service.js"></script>
    <script src="../lib/drive.service.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"
    			  integrity="<KEY>
    			  crossorigin="anonymous"></script>    
  </head>
  <body>
    <h1>gDriveSync</h1>

      <div class="authenticated">
        Logged in <br/>
        
        <textarea id="textEditor">Write here</textarea><br/>
        <a href="#" onclick="save()">save</a>
        <a href="#" onclick="load()">load</a>
        <a href="#" onclick="list()">list</a>
        

        <div id="filesListSection">
          <ul>
            <!-- <li each={files}>
              <span data-name={name} data-id={id} onclick={load}>{name}</span>
            </li> -->
          </ul>
        </div>
      </div>

      <div class="not_authenticated">
        <p>Please sign-in with your Google account to continue.</p>
        <button onclick="login()">Sign-in</button>
      </div>
    

    
    <script>
      var SCOPES = ['https://www.googleapis.com/auth/drive.file']
      var CLIENT_ID = '';
      window.loginService = new LoginService(CLIENT_ID, SCOPES);
      window.driveService = new DriveService();

      function init_gapi() {
        gapi.client.load('drive' , 'v3');
        auth();
      } 
      
      function auth() {
        if (gapi && gapi.auth) {
          window.loginService.checkAuth(function(err, response){
            if (err){
              console.log('show login dialog')
              not_auth();
            } else {
              console.log('is logged in')
              is_auth();
            }
          })
        } else {
          setTimeout(auth, 10); //just in case the gapi lib is not loaded, we call it again
        }        
      }
      
      function login() {
        loginService.login(function(err, response){
          if (err){
            console.log('Login error')
            not_auth();
          } else {
            console.log('Login ok')
            is_auth();
          }
        })    
      } 
      
      //variable to reference the file id that we are modified, used when updated it
      window.current_file = {
          content: '',
          id:null,
          name: 'gDriveSync.example.txt'
        };

      function save() {
        window.current_file.content = $('#textEditor').val()
        driveService.saveFile(window.current_file, function(file){
          window.current_file = file
          console.log('saved file with id:'+file.id)
        })
      }
      
      //Just jquery stuff to hide, show divs
      $( document ).ready(function() {
        $('.not_authenticated').hide();
        $('.authenticated').hide();
      });
      
      function is_auth() {
        $('.not_authenticated').hide();
        $('.authenticated').show();
      }
      
      function not_auth() {
        $('.not_authenticated').show();
        $('.authenticated').hide();
      }      
            
        
    </script>
    <script src="https://apis.google.com/js/client.js?onload=init_gapi"></script>
  </body>
</html><commit_msg>Add list and load documents in the demo<commit_after><html>
  <head>
    <title>gDriveSync</title>
    <script src="../lib/login.service.js"></script>
    <script src="../lib/drive.service.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"
    			  integrity="<KEY>
    			  crossorigin="anonymous"></script>    
  </head>
  <body>
    <h1>gDriveSync</h1>

      <div class="authenticated">
        Logged in <br/>
        
        <textarea id="textEditor">Write here</textarea><br/>
        <a href="#" onclick="save()">save</a>
        <a href="#" onclick="load()">load</a>
        <a href="#" onclick="list()">list</a>
        

        <div id="filesListSection">
          <ul>
          </ul>
        </div>
      </div>

      <div class="not_authenticated">
        <p>Please sign-in with your Google account to continue.</p>
        <button onclick="login()">Sign-in</button>
      </div>
    

    
    <script>
      var SCOPES = ['https://www.googleapis.com/auth/drive.file']
      var CLIENT_ID = '';
      window.loginService = new LoginService(CLIENT_ID, SCOPES);
      window.driveService = new DriveService();

      function init_gapi() {
        gapi.client.load('drive' , 'v3');
        auth();
      } 
      
      function auth() {
        if (gapi && gapi.auth) {
          window.loginService.checkAuth(function(err, response){
            if (err){
              console.log('show login dialog')
              not_auth();
            } else {
              console.log('is logged in')
              is_auth();
            }
          })
        } else {
          setTimeout(auth, 10); //just in case the gapi lib is not loaded, we call it again
        }        
      }
      
      function login() {
        loginService.login(function(err, response){
          if (err){
            console.log('Login error')
            not_auth();
          } else {
            console.log('Login ok')
            is_auth();
          }
        })    
      } 
      
      //variable to reference the file id that we are modified, used when updated it
      window.current_file = {
          content: '',
          id:null,
          name: 'gDriveSync.example.txt'
        };


      function save() {
        window.current_file.content = $('#textEditor').val()
        driveService.saveFile(window.current_file, function(file){
          window.current_file = file
          console.log('saved file with id:'+file.id)
        })
      }
      
      function load(fileId) {
        var file = {id: fileId }
        window.driveService.loadFile(file, function(file){
          window.current_file = file;
          $('#textEditor').val(file.content);
        })           
      }

      function list() {
        window.driveService.listFiles(function(err, files){
          if (err) {
            console.log('List error:'+err)
            return
          }
          $('#filesListSection ul').html("");
          $.each(files, function( index, file ) {
            var li = $('<li/>')
            var newLink = $("<a />", {
                href : "#",
                class: 'file_link',
                'data-id': file.id,
                'data-name': file.name,
                onclick: 'load("'+file.id+'")',
                text: file.name
            }).appendTo(li);
            $('#filesListSection ul').append(li)
          });
        })     
      }      
      //Just jquery stuff to hide, show divs
      $( document ).ready(function() {
        $('.not_authenticated').hide();
        $('.authenticated').hide();
      });
      
      function is_auth() {
        $('.not_authenticated').hide();
        $('.authenticated').show();
      }
      
      function not_auth() {
        $('.not_authenticated').show();
        $('.authenticated').hide();
      }      
            
        
    </script>
    <script src="https://apis.google.com/js/client.js?onload=init_gapi"></script>
  </body>
</html>
{'fraction_non_alphanumeric': 0.15874578177727783, 'fraction_numerical': 0.0022497187851518562, 'mean_word_length': 1.617960986382039, 'pattern_counts': {'":': 0, '<': 96, '<?xml version=': 0, '>': 96, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, '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': '7610225', 'n_tokens_mistral': 2122, 'n_tokens_neox': 2053, 'n_words': 399}