{"size": 957, "ext": "js", "max_stars_repo_path": "thunderbird-todoist/scripts/settings.js", "max_stars_repo_name": "johnf/ThunderbirdTodoist", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "thunderbird-todoist/scripts/settings.js", "max_issues_repo_name": "johnf/ThunderbirdTodoist", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "thunderbird-todoist/scripts/settings.js", "max_forks_repo_name": "johnf/ThunderbirdTodoist", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 28.1470588235, "max_line_length": 86, "alphanum_fraction": 0.7272727273}
function saveSettings() {
  const token = document.getElementById('apitoken').value;
  const defaultproject = getSelectedProject('defaultproject');
  browser.storage.local.set({
    apitoken: token,
    defaultproject: defaultproject,
  });
}

function saveAndLoadProjects() {
  saveSettings();
  fillAllProjectsSelect('defaultproject');
}

function initSettings() {
  loadAPIToken().then(token => {
    document.getElementById('apitoken').value = token || '';
    if (token) {
      fillAllProjectsSelect('defaultproject');
    }
  });
}

function hideSettings() {
  document.getElementById('popup-settings').style.display = 'none';
  document.getElementById('popup-page').style.display = 'block';
}

document.addEventListener('DOMContentLoaded', function () {
  document.getElementById('apitoken').addEventListener('change', saveAndLoadProjects);
  document.getElementById('defaultproject').addEventListener('change', saveSettings);
  initSettings();
});
