<commit_before>(function() {
  if(!!window.Intent) return;

  var addEventListener = function(obj, type, func, capture) {
    if(!!window.addEventListener) {
      obj.addEventListener(type, func, capture);
    }
    else {
      obj.attachEvent("on" + type, func);
    }
  };

  // __WEBINTENTS_ROOT
 
  var server = __WEBINTENTS_ROOT; 
  var serverSource = server + "intents.html";
  var pickerSource = server + "picker.html";
  var iframe;
  var channels = {};
  var intents = {};

  var encodeNameTransport = function(data) {
    return window.btoa(unescape(encodeURIComponent(JSON.stringify(data)))).replace(/=/g, "_");
  };

  var decodeNameTransport = function(str) {
    return JSON.parse(window.atob(str.replace(/_/g, "=")));
  };

  var Intents = function() {
  };

  /*
   * Starts an activity.
   */
  Intents.prototype.startActivity = function (intent, onResult) {
    var id = "intent" + new Date().valueOf();
    var params = "directories=no,menubar=no,status=0,location=0,fullscreen=no";
    
    intent._id = id;
    intents[id] = { intent: intent }; 

    var w = window.open(pickerSource, encodeNameTransport(intent), params);
    
    if(onResult) {
      iframe.contentWindow.postMessage(
        _str({"request": "registerCallback", "id": id }), 
        serverSource );
      intents[id].callback = onResult;
    }
  };

  var _str = function(obj) {
    return JSON.stringify(obj);
  };

  var handler = function(e) {
    var data = JSON.parse(e.data);
    if(data.request &&
            data.request == "response") {
      intents[data.intent._id].callback(data.intent);<commit_msg>Fixes #43<commit_after>(function() {
  if(!!window.Intent) return;

  var addEventListener = function(obj, type, func, capture) {
    if(!!window.addEventListener) {
      obj.addEventListener(type, func, capture);
    }
    else {
      obj.attachEvent("on" + type, func);
    }
  };

  // __WEBINTENTS_ROOT
 
  var server = __WEBINTENTS_ROOT; 
  var serverSource = server + "intents.html";
  var pickerSource = server + "picker.html";
  var iframe;
  var channels = {};
  var intents = {};

  var encodeNameTransport = function(data) {
    return window.btoa(unescape(encodeURIComponent(JSON.stringify(data)))).replace(/=/g, "_");
  };

  var decodeNameTransport = function(str) {
    return JSON.parse(window.atob(str.replace(/_/g, "=")));
  };

  var Intents = function() {
  };

  /*
   * Starts an activity.
   */
  Intents.prototype.startActivity = function (intent, onResult) {
    var id = "intent" + new Date().valueOf();
    var params = "directories=no,menubar=no,status=0,location=0,fullscreen=no";
    
    intent._id = id;
    intents[id] = { intent: intent }; 

    var w = window.open(pickerSource, encodeNameTransport(intent), params);
    
    if(onResult) {
      iframe.contentWindow.postMessage(
        _str({"request": "registerCallback", "id": id }), 
        serverSource );
      intents[id].callback = onResult;
    }
  };

  var _str = function(obj) {
    return JSON.stringify(obj);
  };

  var handler = function(e) {
    var data = JSON.parse(e.data);
    if(!!intents[data.intent._id] == true &&
       data.request &&
       data.request == "response") {

      intents[data.intent._id].callback(data.intent);
{'fraction_non_alphanumeric': 0.1566635887965528, 'fraction_numerical': 0.0018467220683287165, 'mean_word_length': 3.1296060991105463, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '7274726', 'n_tokens_mistral': 1087, 'n_tokens_neox': 1052, 'n_words': 196}