<commit_before>'use strict';

function plus(){
    var total = parseInt(
      document.getElementById('number').innerHTML,
      10
    ) + 1;

    document.getElementById('number').innerHTML = total;
    setTitle(total);
}

function repo_init(){
    core_input_binds_add({
      'keybinds': {
        'all': {
          'todo': function(){
              if(!core_input_keys['all']['state']){
                  plus();
              }
          },
        },
      },
    });

    document.getElementById('number').innerHTML =
      window.localStorage.getItem('PlusPlus.htm-number') || 0;
    setTitle(document.getElementById('number').innerHTML);

    document.getElementById('plus').onclick = plus;
    document.getElementById('reset').onclick = reset;

    window.onbeforeunload = function(e){
        if(parseInt(document.getElementById('number').innerHTML, 10) > 0){
            window.localStorage.setItem(
              'PlusPlus.htm-number',
              document.getElementById('number').innerHTML
            );
        }
    };
}

function reset(){
    if(!window.confirm('Reset score?')){
        return;
    }

    window.localStorage.removeItem('PlusPlus.htm-number');
    document.getElementById('number').innerHTML = 0;
    setTitle(0);
}

function setTitle(newTitle){
    document.title = newTitle + ' - PlusPlus.htm';
}
<commit_msg>added core_handle_beforeunload(), added beforeunload arg to core_input_binds_add()<commit_after>'use strict';

function plus(){
    var total = parseInt(
      document.getElementById('number').innerHTML,
      10
    ) + 1;

    document.getElementById('number').innerHTML = total;
    setTitle(total);
}

function repo_init(){
    core_input_binds_add({
      'beforeunload': {
        'todo': function(){
            if(parseInt(document.getElementById('number').innerHTML, 10) > 0){
                window.localStorage.setItem(
                  'PlusPlus.htm-number',
                  document.getElementById('number').innerHTML
                );
            }
        },
      },
      'keybinds': {
        'all': {
          'todo': function(){
              if(!core_input_keys['all']['state']){
                  plus();
              }
          },
        },
      },
    });

    document.getElementById('number').innerHTML =
      window.localStorage.getItem('PlusPlus.htm-number') || 0;
    setTitle(document.getElementById('number').innerHTML);

    document.getElementById('plus').onclick = plus;
    document.getElementById('reset').onclick = reset;
}

function reset(){
    if(!window.confirm('Reset score?')){
        return;
    }

    window.localStorage.removeItem('PlusPlus.htm-number');
    document.getElementById('number').innerHTML = 0;
    setTitle(0);
}

function setTitle(newTitle){
    document.title = newTitle + ' - PlusPlus.htm';
}

{'fraction_non_alphanumeric': 0.15024805102763997, 'fraction_numerical': 0.0063784549964564135, 'mean_word_length': 2.4301336573511545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2303627', 'n_tokens_mistral': 801, 'n_tokens_neox': 768, 'n_words': 111}