<commit_before>// saves options (synced)
function saveOptions() {
  // get base URL
  event.preventDefault();
  var status = document.getElementById('status');
  var urlPattern = new RegExp("(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})");
  var jira = document.getElementById('jira-url').value;
  if (!urlPattern.test(jira)) {
    status.className = "active";
    status.textContent = 'Please specify a valid URL!';
  } else {
    var defaultOption = document.getElementById('default-option').value;
    chrome.storage.sync.set({
      jiraURL: jira,
      defaultOption: defaultOption
    }, function() {
      // notify user
      status.className = "active";
      status.textContent = 'Options were saved!';
      // remove after 500ms
      window.setTimeout(window.close, 500);
    });
  }
}

// restore the JIRA base url
function restoreOptions() {
  // fallback to empty string
  chrome.storage.sync.get({
    jiraURL: '',
    defaultOption: 'current tab'
  }, function(options) {
    // set value
    document.getElementById('jira-url').value = options.jiraURL;
    document.getElementById('default-option').value = options.defaultOption;
  });
}
<commit_msg>fixed use chrome api to close current tab<commit_after>// saves options (synced)
function saveOptions() {
  // get base URL
  event.preventDefault();
  var status = document.getElementById('status');
  var urlPattern = new RegExp("(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})");
  var jira = document.getElementById('jira-url').value;
  if (!urlPattern.test(jira)) {
    status.className = "active";
    status.textContent = 'Please specify a valid URL!';
  } else {
    var defaultOption = document.getElementById('default-option').value;
    chrome.storage.sync.set({
      jiraURL: jira,
      defaultOption: defaultOption
    }, function() {
      // notify user
      status.className = "active";
      status.textContent = 'Options were saved!';
      // remove after 500ms
      window.setTimeout(function() {
        closeTab();
      }, 500);
    });
  }
}

function closeTab() {
  chrome.tabs.getCurrent(function(tab) {
    chrome.tabs.remove(tab.id, function() { })
  });
}

// restore the JIRA base url
function restoreOptions() {
  // fallback to empty string
  chrome.storage.sync.get({
    jiraURL: '',
    defaultOption: 'current tab'
  }, function(options) {
    // set value
    document.getElementById('jira-url').value = options.jiraURL;
    document.getElementById('default-option').value = options.defaultOption;
  });
}

{'fraction_non_alphanumeric': 0.1733541098558629, 'fraction_numerical': 0.0062329567588624854, 'mean_word_length': 3.230642504118616, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '860377', 'n_tokens_mistral': 803, 'n_tokens_neox': 784, 'n_words': 165}