<commit_before>var FileLoader = require("file_loader");

function urlFromSelection(selection) {
  return "http://localhost:3000/" + selection.toLowerCase() + ".jpg";
}

function showError(e) {
  Ti.API.error(JSON.stringify(e, null, 2));
  alert(e.message);
}

function callbackImageChange(e) {
  var url = urlFromSelection(e.selectedValue[0]);
  Ti.API.info("Requested URL: " + url);
  FileLoader.download(url, {
    onload: function(file_path) {
      $.callbackImage.image = file_path;
    },
    onerror: showError
  });
}

function promiseImageChange(e) {
  var url = urlFromSelection(e.selectedValue[0]);
  Ti.API.info("Requested URL: " + url);
  FileLoader.download(url)
    .then(function(file_path) {
      $.promiseImage.image = file_path;
    })
    .fail(showError)
    .done();
}

$.callbackPicker.addEventListener("change", callbackImageChange);
$.promisePicker.addEventListener("change", promiseImageChange);

$.index.open();
<commit_msg>Add initialization for TaableView<commit_after>var FileLoader = require("file_loader");

function urlFromSelection(selection) {
  return "http://localhost:3000/" + selection.toLowerCase() + ".jpg";
}

function showError(e) {
  Ti.API.error(JSON.stringify(e, null, 2));
  alert(e.message);
}

function callbackImageChange(e) {
  var url = urlFromSelection(e.selectedValue[0]);
  Ti.API.info("Requested URL: " + url);
  FileLoader.download(url, {
    onload: function(file_path) {
      $.callbackImage.image = file_path;
    },
    onerror: showError
  });
}

function promiseImageChange(e) {
  var url = urlFromSelection(e.selectedValue[0]);
  Ti.API.info("Requested URL: " + url);
  FileLoader.download(url)
    .then(function(file_path) {
      $.promiseImage.image = file_path;
    })
    .fail(showError)
    .done();
}

(function() {
  var tags = [
    "sun",
    "sea",
    "tree",
    "cat",
    "dog"
  ];

  function makeRowFor(tag) {
    var row = Ti.UI.createTableViewRow({ title: tag });
    FileLoader.download("http://flickholdr.com/128/128/" + tag)
      .then(function(path) { row.leftImage = path; }).done();
    return row;
  }

  var tag_index = 0, i, row, rows = [];
  for (i = 0; i < 100; i++) {
    rows.push(makeRowFor(tags[tag_index]));
    tag_index++;
    tag_index = (tag_index >= tags.length) ? 0 : tag_index;
  }

  $.tableList.setData(rows);
})();

$.callbackPicker.addEventListener("change", callbackImageChange);
$.promisePicker.addEventListener("change", promiseImageChange);

$.index.open();

{'fraction_non_alphanumeric': 0.1678773204196933, 'fraction_numerical': 0.010492332526230832, 'mean_word_length': 3.997983870967742, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3676679', 'n_tokens_mistral': 852, 'n_tokens_neox': 833, 'n_words': 144}