<commit_before>var TPM = (function () {

  var my = {};
  
  function startsWith = function (input, prefix) {
    return input.slice(0, prefix.length) == prefix;
  };

  my.getMWOPH = function () {
    return chrome.bookmarks.MAX_WRITE_OPERATIONS_PER_HOUR;
  }

  my.getMSWOPM = function () {
    return chrome.bookmarks.MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE;
  }

  var baseBookMarkName= "TabProject";

  my.ProjectPageBase = 'chrome-extension://__MSG_@@extensionid/tabproject.html?name=';
  my.getProjectPageUrl = function (name) {
    return my.ProjectPageBase+encodeURIComponent(name);
  }
  my.isProjectPageUrl = function (url) {
    return startsWith(url, TPM.ProjectPageBase);
  }

  function getParameterByName(url, name) {
    var match = RegExp('[?&]' + name + '=([^&]*)').exec(url);
    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
  }

  my.scanTabsForProjects = function () {
    var projects = [];
    console.log('Starting scanTabs');
    chrome.tabs.query({}, function (tabs) {
      var curProject = null;
      var length = arr.length,
          tab = null;
      for (var i = 0; i < length; i++) {
        tabs = tabs[i];
        if (tabs.index == 0) {
          curProject = null;
        }
        if (isProjectPageUrl(tabs.url)) {
          curProject = { name: getParameterByName(tabs.url, 'name'), tabDescs: [] };
          projects.push(curProject);
          console.log('FirstProjectTab', curProject);
        } else if (curProject != null) {
          var tabDesc = { title: tab.title, url: tab.url; favIconUrl: tab.favIconUrl };
          curProject.tabDescs.push(tabDesc);
          console.log('ProjectTab', tabDesc);
        }
      }      
    });
    console.log('Finished scanTabs');
    return projects;
  }

  return my;
}());

var Scanner = (function (TPM) {
  var my = {};



  return my;
}(TPM));


var Popup = (function (TPM) {
  var my = {};

  function isBlank(str) {
    return (!str || /^\s*$/.test(str));
  }

  my.addNewProject = function () {
  alert("add");
    var name = $('newProjectName').text();
    if (isBlank(name)) {
      message("You must enter a Project Name first!");
      return;
    }
    var projectPageUrl = TPM.getProjectPageUrl(name);
    chrome.tabs.create({url:projectPageUrl});
  }

  my.init = function () {
  alert("init");

    // TODO enable button on name !blank
    $('#newProjectButton').click( function() {
      my.addNewProject();
    });

    var projects = TPM.scanTabsForProjects();
    var items = ['<ul>'];
    $.each(projects, function(i, project) {
      items.push('<li>'+project.name+'</li><ul>');
      $.each(project.tabDescs, function(j, tabDesc) {
        items.push('<li>'+tabDesc.title+'</li>');
      });
      items.push('</ul>');
    });  // close each()
    items.push('</ul>');
    $('#projectList').append( items.join('') );    
  }

  return my;
}(TPM));


document.addEventListener('DOMContentLoaded', function () {
  alert("ONO");
  if (TPM.isProjectPageUrl(window.location.search)) {

  } else {
    Popup.init();
  }
});
<commit_msg>Basic system (no project pages yet)<commit_after>"use strict";

var TPM = (function () {
  var my = {};

  function startsWith(input, prefix) {
    return input.slice(0, prefix.length) === prefix;
  }

  my.getMWOPH = function () {
    return chrome.bookmarks.MAX_WRITE_OPERATIONS_PER_HOUR;
  };

  my.getMSWOPM = function () {
    return chrome.bookmarks.MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE;
  };

  var baseBookMarkName = "TabProject";

  my.ProjectPageBase = 'chrome-extension://__MSG_@@extension_id__/tabproject.html?name=';
  my.getProjectPageUrl = function (name) {
    return my.ProjectPageBase + encodeURIComponent(name);
  };
  my.isProjectPageUrl = function (url) {
    return startsWith(url, TPM.ProjectPageBase);
  };

  function getParameterByName(url, name) {
    var match = new RegExp('[?&]' + name + '=([^&]*)').exec(url);
    return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
  }

  my.scanTabsForProjects = function () {
    var projects = [];
    console.log('Starting scanTabs');
    chrome.tabs.query({}, function (tabs) {
      var curProject = null;
      $.each(tabs, function(i, tab) {
        console.log('TAB i=' + i + ', index=' + tab.index + ', title=' + tab.title);
        if (tab.index === 0) {
          curProject = null;
        }
        if (my.isProjectPageUrl(tab.url)) {
          curProject = { name: getParameterByName(tab.url, 'name'), tabDescs: [] };
          projects.push(curProject);
          console.log('FirstProjectTab', curProject);
        } else if (curProject !== null) {
          var tabDesc = { title: tab.title, url: tab.url, favIconUrl: tab.favIconUrl };
          curProject.tabDescs.push(tabDesc);
          console.log('ProjectTab', tabDesc);
        }
      });
    });
    console.log('Finished scanTabs', projects);
    return projects;
  };

  return my;
}());

var Scanner = (function (TPM) {
  var my = {};



  return my;
}(TPM));


var Popup = (function (TPM) {
  var my = {};

  function isBlank(str) {
    return (!str || /^\s*$/.test(str));
  }

  my.addNewProject = function () {
    var name = $('#newProjectName').val();
    if (isBlank(name)) {
      alert("You must enter a Project Name first!");
      return;
    }
    var projectPageUrl = TPM.getProjectPageUrl(name);
    chrome.tabs.create({url:projectPageUrl});
  };

  my.init = function () {

    // TODO enable button on name !blank
    $('#newProjectButton').click( function() {
      my.addNewProject();
    });

    var projects = TPM.scanTabsForProjects();
    var items = ['<ul>'];
    $.each(projects, function(i, project) {
      items.push('<li>'+project.name+'</li><ul>');
      $.each(project.tabDescs, function(j, tabDesc) {
        items.push('<li>'+tabDesc.title+'</li>');
      });
      items.push('</ul>');
    });  // close each()
    items.push('</ul>');
    $('#projectList').append( items.join('') );    
  };

  return my;
}(TPM));


document.addEventListener('DOMContentLoaded', function () {
  if (TPM.isProjectPageUrl(window.location.search)) {

  } else {
    Popup.init();
  }
});

{'fraction_non_alphanumeric': 0.1762595793249633, 'fraction_numerical': 0.0011413663786075331, 'mean_word_length': 2.889663918833228, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 19, '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': '2311686', 'n_tokens_mistral': 2084, 'n_tokens_neox': 2031, 'n_words': 387}