<commit_before>


var api = pinoccioAPI();


(function(){

  $(document).on('flatdoc:ready', function() {
    o.init();
  });

  var o;
  o = {
    sync:false,
    state:{},
    account:false,
    pollingLogin:false, 
    init:function(){

      var z = this;
      this.pollLoginState();
      this.uiLoginButton();

    },
    onLogin:function(){
      var data = this.account;
      // hide login show logged in.
      $(".login-loggedout").hide();
      var a = $("<a>").attr('href',"#").css({"display":"inline","vertical-align":"top"});
      a.text("Hi, "+(data.firstname.length?data.firstname:data.email.split('@').shift()))

      $(".login-loggedin").append("<img src='"+data.gravatar+"' width='20' height='20' alt=''/>");
      $(".login-loggedin").append(a).show()

      /*
      var sync = api.sync();
      sync.on('data',function(data){
        console.log('data',data); 
      });
      this.sync = sync;
      */

      this.updateExamples();

    },
    pollLoginState:function(){
      var z = this;
      if(z.pollingLogin) return;
      if(z.account) return (z.pollingLogin = false);

      z.pollingLogin = true;
      (function fn(){

        // because sync stream requires login  a login in another tab would not be picked up here. 
        api.rest({url:'/v1/account'},function(err,data){

          if(err || !data) {
            console.log('not logged in ',err);
            return setTimeout(function(){
              fn();
              //return console.log('not logged in');
            },30000);
          }

          z.pollingLogin = false;

          z.account = data;
          z.onLogin();
        })
      }());
    },
    handleLogin:function(data,cb){
      var z = this;
      api.login(data.email,data.password,function(err,data){
        cb(err,data);
        if(data){
          z.account = data;
          z.onLogin();
        }
      });
    },
    updateExamples:function(){
      var replacements = {
        '7fc11b7554f0cd303bad94eb0eb36e2d':api.token
      };
      $("code").each(function(){
        var html = $(this).html();
        var changed = false;
        var code = this;
        $.each(replacements,function(k,v){
          var added = fal;se;
          $(code).find('.string, .comment').each(function(){
            var text = $(this).text()||'';
            if(text.trim().indexOf(k) > -1) {
              text = text.replace(k,v);
              $(this).text(text);
            }<commit_msg>fixing typo<commit_after>


var api = pinoccioAPI();


(function(){

  $(document).on('flatdoc:ready', function() {
    o.init();
  });

  var o;
  o = {
    sync:false,
    state:{},
    account:false,
    pollingLogin:false, 
    init:function(){

      var z = this;
      this.pollLoginState();
      this.uiLoginButton();

    },
    onLogin:function(){
      var data = this.account;
      // hide login show logged in.
      $(".login-loggedout").hide();
      var a = $("<a>").attr('href',"#").css({"display":"inline","vertical-align":"top"});
      a.text("Hi, "+(data.firstname.length?data.firstname:data.email.split('@').shift()))

      $(".login-loggedin").append("<img src='"+data.gravatar+"' width='20' height='20' alt=''/>");
      $(".login-loggedin").append(a).show()

      /*
      var sync = api.sync();
      sync.on('data',function(data){
        console.log('data',data); 
      });
      this.sync = sync;
      */

      this.updateExamples();

    },
    pollLoginState:function(){
      var z = this;
      if(z.pollingLogin) return;
      if(z.account) return (z.pollingLogin = false);

      z.pollingLogin = true;
      (function fn(){

        // because sync stream requires login  a login in another tab would not be picked up here. 
        api.rest({url:'/v1/account'},function(err,data){

          if(err || !data) {
            console.log('not logged in ',err);
            return setTimeout(function(){
              fn();
              //return console.log('not logged in');
            },30000);
          }

          z.pollingLogin = false;

          z.account = data;
          z.onLogin();
        })
      }());
    },
    handleLogin:function(data,cb){
      var z = this;
      api.login(data.email,data.password,function(err,data){
        cb(err,data);
        if(data){
          z.account = data;
          z.onLogin();
        }
      });
    },
    updateExamples:function(){
      var replacements = {
        '<PASSWORD>':api.token
      };
      $("code").each(function(){
        var html = $(this).html();
        var changed = false;
        var code = this;
        $.each(replacements,function(k,v){
          $(code).find('.string, .comment').each(function(){
            var text = $(this).text()||'';
            if(text.trim().indexOf(k) > -1) {
              text = text.replace(k,v);
              $(this).text(text);
            }
{'fraction_non_alphanumeric': 0.18505557842733636, 'fraction_numerical': 0.008027995059695347, 'mean_word_length': 1.955596107055961, 'pattern_counts': {'":': 4, '<': 8, '<?xml version=': 0, '>': 10, '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': '5237373', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1497, 'n_words': 274}