<commit_before>document.addEventListener('DOMContentLoaded', function(){
  // check local storage
  chrome.storage.local.get('snapshots', function(storage){
    if(!storage.snapshots){
      chrome.storage.local.set({'snapshots': {
        'hackage': {'name': 'Hackage', 'prim': true},
        'lts': {'name': 'LTS (latest)', 'prim': true},
        'nightly': {'name': 'Nightly (latest)', 'prim': true}
      }});
    }
    main();
  });
});

function main(){
  // open a new tab for the result of a query on the snapshot
  var searchButton = document.getElementById('search');
  searchButton.addEventListener('click', function(){
    var query = document.getElementById('searchForm').query.value;
    var snapshot = document.querySelector('input[name="snapshot"]:checked').value;

    var url;

    if(snapshot === 'hackage'){
      url = 'https://www.haskell.org/hoogle/?hoogle=';
    }else{
      url = 'https://www.stackage.org/' + snapshot + '/hoogle?q=';
    }

    url += query;
    chrome.tabs.create({'url': url});
  });

  // display snapshots
  var snapshots = document.getElementById('snapshots');
  chrome.storage.local.get('snapshots', function (storage){
    if(storage.snapshots){
      var snapshotDict = storage.snapshots;
      for(var snapId in snapshotDict){
        var span = document.createElement('span');
        span.classList.add('snapshot');<commit_msg>Fix a bug about main()<commit_after>document.addEventListener('DOMContentLoaded', function(){
  // check local storage
  chrome.storage.local.get('snapshots', function(storage){
    if(!storage.snapshots){
      chrome.storage.local.set({'snapshots': {
        'hackage': {'name': 'Hackage', 'prim': true},
        'lts': {'name': 'LTS (latest)', 'prim': true},
        'nightly': {'name': 'Nightly (latest)', 'prim': true}
      }}, main);
    }else{
      main();
    }
  });
});

function main(){
  // open a new tab for the result of a query on the snapshot
  var searchButton = document.getElementById('search');
  searchButton.addEventListener('click', function(){
    var query = document.getElementById('searchForm').query.value;
    var snapshot = document.querySelector('input[name="snapshot"]:checked').value;

    var url;

    if(snapshot === 'hackage'){
      url = 'https://www.haskell.org/hoogle/?hoogle=';
    }else{
      url = 'https://www.stackage.org/' + snapshot + '/hoogle?q=';
    }

    url += query;
    chrome.tabs.create({'url': url});
  });

  // display snapshots
  var snapshots = document.getElementById('snapshots');
  chrome.storage.local.get('snapshots', function (storage){
    if(storage.snapshots){
      var snapshotDict = storage.snapshots;
      for(var snapId in snapshotDict){
        var span = document.createElement('span');
        span.classList.add('snapshot');
{'fraction_non_alphanumeric': 0.1758595988538682, 'fraction_numerical': 0.0, 'mean_word_length': 3.526742301458671, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '6368309', 'n_tokens_mistral': 837, 'n_tokens_neox': 817, 'n_words': 181}