<commit_before>/*
See BasicTemplate.js for documentation and an example of a BasicController
*/

var BasicController = function(params) {
  this.name = document.location.hostname;
  for (var key in params) {
    this[key] = params[key];
  }
  if (params.doThrottling) {
    var sendStateThrottled = this.throttle(sendState, 250);
    this.stateChangeObserver = new WebKitMutationObserver(function(mutations, observer) {
      sendStateThrottled();
    });
  } else {
    this.stateChangeObserver = new WebKitMutationObserver(function(mutations, observer) {
      sendState();
    });
  }
};

BasicController.prototype.doc = function() {
  return (this.frameSelector && document.querySelector(this.frameSelector).tagName === "IFRAME") ? document.querySelector(this.frameSelector).contentWindow.document : document;
}

BasicController.prototype.init = function() {
  var observedKeys = [
    'playStateSelector',
    'titleSelector',
    'artistSelector',
    'artworkImageSelector',
    'thumbsUpSelector',
    'thumbsDownSelector',
    'favoriteSelector'
  ];
  for (var i = 0; i < observedKeys.length; ++i) {
    if (this.useLazyObserving) {
      if (this[observedKeys[i]] && !this.doc().querySelector(this[observedKeys[i]])) {
        console.log("Waiting for element: ", this[observedKeys[i]])
        return false;
      }
    }
  }
  for (var i = 0; i < observedKeys.length; ++i) {
    this.observeStateChanges(this[observedKeys[i]]);
  }
  if (this.watchedElements) {
    for (var i = 0; i < this.watchedElements.length; ++i) {
      this.observeStateChanges(this.watchedElements[i]);
    }
  }
  return true;
}<commit_msg>Add some logging for IFRAME detection to the init<commit_after>/*
See BasicTemplate.js for documentation and an example of a BasicController
*/

var BasicController = function(params) {
  this.name = document.location.hostname;
  for (var key in params) {
    this[key] = params[key];
  }
  if (params.doThrottling) {
    var sendStateThrottled = this.throttle(sendState, 250);
    this.stateChangeObserver = new WebKitMutationObserver(function(mutations, observer) {
      sendStateThrottled();
    });
  } else {
    this.stateChangeObserver = new WebKitMutationObserver(function(mutations, observer) {
      sendState();
    });
  }
};

BasicController.prototype.doc = function() {
  var useFrameSelector = (this.frameSelector && document.querySelector(this.frameSelector).tagName === "IFRAME");
  return (useFrameSelector) ? document.querySelector(this.frameSelector).contentWindow.document : document;
}

BasicController.prototype.init = function() {
  var observedKeys = [
    'playStateSelector',
    'titleSelector',
    'artistSelector',
    'artworkImageSelector',
    'thumbsUpSelector',
    'thumbsDownSelector',
    'favoriteSelector'
  ];
  if (this.frameSelector && document.querySelector(this.frameSelector).tagName !== "IFRAME")
    console.log("frameSelector is defined but the element is not an IFRAME so it will be ignored.");
  for (var i = 0; i < observedKeys.length; ++i) {
    if (this.useLazyObserving) {
      if (this[observedKeys[i]] && !this.doc().querySelector(this[observedKeys[i]])) {
        console.log("Waiting for element: ", this[observedKeys[i]])
        return false;
      }
    }
  }
  for (var i = 0; i < observedKeys.length; ++i) {
    this.observeStateChanges(this[observedKeys[i]]);
  }
  if (this.watchedElements) {
    for (var i = 0; i < this.watchedElements.length; ++i) {
      this.observeStateChanges(this.watchedElements[i]);
    }
  }
  return true;
}
{'fraction_non_alphanumeric': 0.1335219236209335, 'fraction_numerical': 0.0033946251768033945, 'mean_word_length': 3.9247910863509747, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4421366', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1103, 'n_words': 224}