<commit_before>// Copyright 2011 Google Inc. All Rights Reserved.

/**
 * @fileoverview Options page for Chrome OS CIN.
 * @author <EMAIL> (<NAME>)
 */

var kTableUrlsKey = "table_urls";

function init() {
  loadTableUrls();
}

function addTableUrl() {
  var url = document.getElementById("cin_table_url_input").value;

  var table_urls = readLocalStorage(kTableUrlsKey, {});

  if (table_urls[url]) {
    setAddUrlStatus("URL already exists", true);
  } else {
    table_urls[url] = {"url": url};
    writeLocalStorage(kTableUrlsKey, table_urls);
    addTableUrlToTable(url);
    setAddUrlStatus("OK", false);
  }
}

function setAddUrlStatus(status, error) {
  var status_field = document.getElementById("add_url_status");
  status_field.innerHTML = status;
}

function addTableUrlToTable(url) {
  var table = document.getElementById("cin_table_url_table");

  var row = table.tBodies[0].insertRow(-1);
  var cell = row.insertCell(-1);
  cell.innerHTML = url;
  var cell = row.insertCell(-1);
  var button = document.createElement('input');
  button.type = 'button';
  button.value = 'Remove';<commit_msg>Store the value of the table at the url<commit_after>// Copyright 2011 Google Inc. All Rights Reserved.

/**
 * @fileoverview Options page for Chrome OS CIN.
 * @author <EMAIL> (<NAME>)
 */

var kTableUrlsKey = "table_urls";

function init() {
  loadTableUrls();
}

function addTableUrl() {
  var url = document.getElementById("cin_table_url_input").value;

  var table_urls = readLocalStorage(kTableUrlsKey, {});

  if (table_urls[url]) {
    setAddUrlStatus("URL already exists", true);
  } else {
    // Write a placeholder value.
    table_urls[url] = {};
    writeLocalStorage(kTableUrlsKey, table_urls);

    var xhr = new XMLHttpRequest();
    xhr.onreadystatechange = function () {
      if (this.readyState == 4) {
        if (this.status == 200) {
          // Update the entry in localStorage
          var table_urls = readLocalStorage(kTableUrlsKey, {});
          table_urls[url]["data"] = this.responseText;
          writeLocalStorage(kTableUrlsKey, table_urls);

          // Update the UI
          addTableUrlToTable(url);
          setAddUrlStatus("OK", false);
        } else {
          // Update the entry in localStorage
          var table_urls = readLocalStorage(kTableUrlsKey, {});
          delete table_urls[url];
          writeLocalStorage(kTableUrlsKey, table_urls);

          // Update the UI
          setAddUrlStatus("Could not read url.  Server returned " + this.status,
                          true);
        }
      }
    }
    xhr.open("GET", url, true);
    xhr.send(null);
  }
}

function setAddUrlStatus(status, error) {
  var status_field = document.getElementById("add_url_status");
  status_field.innerHTML = status;
}

function addTableUrlToTable(url) {
  var table = document.getElementById("cin_table_url_table");

  var row = table.tBodies[0].insertRow(-1);
  var cell = row.insertCell(-1);
  cell.innerHTML = url;
  var cell = row.insertCell(-1);
  var button = document.createElement('input');
  button.type = 'button';
  button.value = 'Remove';
{'fraction_non_alphanumeric': 0.12846104314230522, 'fraction_numerical': 0.00643915003219575, 'mean_word_length': 3.369901547116737, 'pattern_counts': {'":': 1, '<': 7, '<?xml version=': 0, '>': 7, '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': '3896593', 'n_tokens_mistral': 990, 'n_tokens_neox': 977, 'n_words': 220}