<commit_before><!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="fancy-settings/source/lib/default.css">

    <link rel="stylesheet" href="fancy-settings/source/css/main.css">
    <link rel="stylesheet" href="fancy-settings/source/css/setting.css">
    <link rel="stylesheet" href="fancy-settings/source/custom.css">
    <script src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
      var selectedProjects = []

      function jiraServerChanged() {
        $("#loadProjectKeys").show();
        save_options();
      }

      // Saves options to localStorage.
      function save_options() {
        localStorage["urls_to_jirafy"] = $("#urls_to_jirafy").val();
        localStorage["project_keys"] = $("#project_keys").val();
        localStorage["jira_server"] = getJiraServerValue();
      }

      // Restores select box state to saved value from localStorage.
      function restore_options() {
        var hostnamesToJirafy = localStorage["urls_to_jirafy"];
        if (!hostnamesToJirafy) {
          return;
        }
        urlsToJirafy = $("#urls_to_jirafy");
        urlsToJirafy.val(localStorage["urls_to_jirafy"]);

        projectKeys = $("#project_keys");
        projectKeys.val(localStorage["project_keys"]);

        keys = localStorage["project_keys"].split(",");
        for (index = 0; index < keys.length; index++) {
          selectedProjects[keys[index]] = true;
        }
        jiraServer = $("#jira_server");
        jiraServer.val(localStorage["jira_server"]);

        setRealOnChange(urlsToJirafy, save_options);
        setRealOnChange(projectKeys, save_options);
        setRealOnChange(jiraServer, jiraServerChanged);
      }

      function setRealOnChange(field, onChangeMethod) {
        (function () {
          var oldVal;
          field.bind('change keypress paste focus textInput input', function () {
            var val = this.value;
            if (val !== oldVal) {
              oldVal = val;
              onChangeMethod();
            }
          });
        }());
      }

      // Load the JIRA project keys from the specified server.
      function loadJiraProjectKeys() {
        $("#loadProjectKeys").hide();
        $.getJSON(getJiraServerValue() + "rest/api/2/project", function(data) {
          var items = [];
          // Populate the checkboxes with the API response.
          for(var c = 0; c < data.length; c++) {
            project = data[c].key;
            onchangeF = "checkProject(this, '" + project + "');";
            isChecked = selectedProjects[project] ? ' checked' : '';
            items.push('<input type="checkbox" onchange="' + onchangeF + '" class="project-checkbox" ' + isChecked + '>' + project + '<br>');
          }
          $("#project_checkboxes_container").replaceWith($("<div/>", {
            'class': 'project-keys-list',
            html: items.join('')
          }))
        });
      }

      // Called when one of the checkboxes is checked.
      function checkProject(input, value) {
        if (input.checked) {
          selectedProjects[value] = true;
        } else {
          selectedProjects[value] = false;
        }
        var projectStr = "";
        var first = true;
        for(project in selectedProjects) {
          if (selectedProjects[project]) {
            if (!first && projectStr.length > 0) projectStr += ",";
            projectStr += project;
          }
          first = false;
        }
        $("#project_keys").val(projectStr);
      }

      // Safely parse the value of the jira server field, adding a trailing slash if there isn't one.
      function getJiraServerValue() {
        field = $("#jira_server").val()
        if (!field) return "";
        if (!field.match("/$")) {
          field = field + "/";
        }
        return field;
      }
    </script>
  </head>
  <body class="no-select" onload="restore_options()">
    <div id="sidebar" class="fancy">
      <img id="icon" src="icon_128.png"/>
      <h1 id="settings-label">Jirafy</h1>
      <div id="tab-container">
        <div id="search-tab" class="tab">Linkify JIRA ticket numbers. Anywhere.</div>
      </div>
    </div>

    <div id="content">
      <div class="tab-content show">
        <h2>Settings</h2>
        <table class="setting group">
          <tr>
            <td class="setting group-name">Pages</td>
            <td class="setting group-content">
              <div class="setting bundle text">
                <div class="setting container text">
                  <label class="setting label text" for="urls_to_jirafy">URL Patterns:</label>
                  <input class="setting element text" type="text" name="urls_to_jirafy" id="urls_to_jirafy" size="100"/>
                </div>
              </div>
              <div class="setting bundle description">
                Comma-separated, can be any portion of the url.  For instance, to match any git server, use "git".  To restrict it to pull requests, use "git.squareup.com/myorg/myproject/pull".  Regexes NOT currently supported.
              </div>
            </td>
          </tr>
          <tr>
            <td class="setting group-name">JIRA </td>
            <td class="setting group-content">
              <div class="setting bundle text">
                <div class="setting container text">
                  <label class="setting label text" for="project_keys">Project Keys:</label>
                  <input type="text" name="project_keys" id="project_keys" size="100"/>
                  <div id="project_checkboxes_container"></div>
                </div>
                <div class="setting container text">
                  <label class="setting label text" for="jira_server">JIRA Server:</label>
                  <input type="text" name="jira_server" id="jira_server" value="https://go.squareup.com/jira/"/> <a id="loadProjectKeys" onclick="loadJiraProjectKeys()">Detect Projects</a>
                </div>
              </div>
              <div class="setting bundle description">
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
  </body>
</html>
<commit_msg>Bug where onerrything listeners weren't always getting hooked up<commit_after><!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="fancy-settings/source/lib/default.css">

    <link rel="stylesheet" href="fancy-settings/source/css/main.css">
    <link rel="stylesheet" href="fancy-settings/source/css/setting.css">
    <link rel="stylesheet" href="fancy-settings/source/custom.css">
    <script src="jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
      var selectedProjects = []

      function jiraServerChanged() {
        $("#loadProjectKeys").show();
        save_options();
      }

      // Saves options to localStorage.
      function save_options() {
        localStorage["urls_to_jirafy"] = $("#urls_to_jirafy").val();
        localStorage["project_keys"] = $("#project_keys").val();
        localStorage["jira_server"] = getJiraServerValue();
      }

      // Restores select box state to saved value from localStorage.
      function restore_options() {
        urlsToJirafy = $("#urls_to_jirafy");
        projectKeys = $("#project_keys");
        jiraServer = $("#jira_server");
        setRealOnChange(urlsToJirafy, save_options);
        setRealOnChange(projectKeys, save_options);
        setRealOnChange(jiraServer, jiraServerChanged);

        var hostnamesToJirafy = localStorage["urls_to_jirafy"];
        if (!hostnamesToJirafy) {
          return;
        }
        urlsToJirafy.val(localStorage["urls_to_jirafy"]);

        projectKeys.val(localStorage["project_keys"]);

        keys = localStorage["project_keys"].split(",");
        for (index = 0; index < keys.length; index++) {
          selectedProjects[keys[index]] = true;
        }
        jiraServer.val(localStorage["jira_server"]);
      }

      function setRealOnChange(field, onChangeMethod) {
        (function () {
          var oldVal;
          field.bind('change keypress paste focus textInput input', function () {
            var val = this.value;
            if (val !== oldVal) {
              oldVal = val;
              onChangeMethod();
            }
          });
        }());
      }

      // Load the JIRA project keys from the specified server.
      function loadJiraProjectKeys() {
        $("#loadProjectKeys").hide();
        $.getJSON(getJiraServerValue() + "rest/api/2/project", function(data) {
          var items = [];
          // Populate the checkboxes with the API response.
          for(var c = 0; c < data.length; c++) {
            project = data[c].key;
            onchangeF = "checkProject(this, '" + project + "');";
            isChecked = selectedProjects[project] ? ' checked' : '';
            items.push('<input type="checkbox" onchange="' + onchangeF + '" class="project-checkbox" ' + isChecked + '>' + project + '<br>');
          }
          $("#project_checkboxes_container").replaceWith($("<div/>", {
            'class': 'project-keys-list',
            html: items.join('')
          }))
        });
      }

      // Called when one of the checkboxes is checked.
      function checkProject(input, value) {
        if (input.checked) {
          selectedProjects[value] = true;
        } else {
          selectedProjects[value] = false;
        }
        var projectStr = "";
        var first = true;
        for(project in selectedProjects) {
          if (selectedProjects[project]) {
            if (!first && projectStr.length > 0) projectStr += ",";
            projectStr += project;
          }
          first = false;
        }
        $("#project_keys").val(projectStr);
      }

      // Safely parse the value of the jira server field, adding a trailing slash if there isn't one.
      function getJiraServerValue() {
        field = $("#jira_server").val()
        if (!field) return "";
        if (!field.match("/$")) {
          field = field + "/";
        }
        return field;
      }
    </script>
  </head>
  <body class="no-select" onload="restore_options()">
    <div id="sidebar" class="fancy">
      <img id="icon" src="icon_128.png"/>
      <h1 id="settings-label">Jirafy</h1>
      <div id="tab-container">
        <div id="search-tab" class="tab">Linkify JIRA ticket numbers. Anywhere.</div>
      </div>
    </div>

    <div id="content">
      <div class="tab-content show">
        <h2>Settings</h2>
        <table class="setting group">
          <tr>
            <td class="setting group-name">Pages</td>
            <td class="setting group-content">
              <div class="setting bundle text">
                <div class="setting container text">
                  <label class="setting label text" for="urls_to_jirafy">URL Patterns:</label>
                  <input class="setting element text" type="text" name="urls_to_jirafy" id="urls_to_jirafy" size="100"/>
                </div>
              </div>
              <div class="setting bundle description">
                Comma-separated, can be any portion of the url.  For instance, to match any git server, use "git".  To restrict it to pull requests, use "git.squareup.com/myorg/myproject/pull".  Regexes NOT currently supported.
              </div>
            </td>
          </tr>
          <tr>
            <td class="setting group-name">JIRA </td>
            <td class="setting group-content">
              <div class="setting bundle text">
                <div class="setting container text">
                  <label class="setting label text" for="project_keys">Project Keys:</label>
                  <input type="text" name="project_keys" id="project_keys" size="100"/>
                  <div id="project_checkboxes_container"></div>
                </div>
                <div class="setting container text">
                  <label class="setting label text" for="jira_server">JIRA Server:</label>
                  <input type="text" name="jira_server" id="jira_server" value="https://go.squareup.com/jira/"/> <a id="loadProjectKeys" onclick="loadJiraProjectKeys()">Detect Projects</a>
                </div>
              </div>
              <div class="setting bundle description">
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
  </body>
</html>

{'fraction_non_alphanumeric': 0.14520151234816187, 'fraction_numerical': 0.0033786501488214946, 'mean_word_length': 2.1165705690649284, 'pattern_counts': {'":': 0, '<': 161, '<?xml version=': 0, '>': 159, 'https://': 2, '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': '2060989', 'n_tokens_mistral': 3599, 'n_tokens_neox': 3527, 'n_words': 782}