<commit_before>window.onload = function(e) {
  if (isIframe()) {
    // Send message to parent
    let PADDING = 30;
    let sessionId = getParameterByName('sessionId');
    if (!sessionId) {
      console.error("URL[" + window.location.href + "] does not contain session id");
    }
    else {
      sendHeightData();

      let key = sessionId + "-childFrameWidth";
      let width = $(document).width() + PADDING;
      let message = {
        "key" : key,
        "value" : width
      };

      console.log("Page for session [" + key + "] has width: " + width + " px");
      parent.postMessage(JSON.stringify(message), "*");
    }
  }
  else {
    // Redirect to the proper page
    let target = location.origin + '?goto=' + 
      location.pathname.replace('/pages/', '/page/').replace('.html', '') + 
      location.search.replace('?', '&');
    location.href = target;
  }
};

// Monitor page height to send it to parent
$(function () {
  let previousHeight = $(document).height();
  $(document).attrchange({
    callback: function (e) {
      let currentHeight = $(this).height();
      if (previousHeight !== currentHeight) {
        let msg = '[ChildFrame.ChangedHeight] Change height: ' + previousHeight;
        msg = msg + 'px to ' + currentHeight + 'px';
        console.log(msg);

        sendHeightData();
        previousHeight = currentHeight;
      }
    }
  }).resizable();
});

/**
 * Sends height data to parent frame
 */
function sendHeightData() {<commit_msg>Minor fixes<commit_after>window.onload = function(e) {
  if (isIframe()) {
    // Send message to parent
    let PADDING = 30;
    let sessionId = getParameterByName('sessionId');
    if (!sessionId) {
      console.error("URL[" + window.location.href + "] does not contain session id");
    }
    else {
      sendHeightData();

      let key = sessionId + "-childFrameWidth";
      let width = $(document).width() + PADDING;
      let message = {
        "key" : key,
        "value" : width
      };

      console.log("Page for session [" + key + "] has width: " + width + " px");
      parent.postMessage(JSON.stringify(message), "*");
    }
  }
  else {
    // Redirect to the proper page
    let target = location.origin + '?goto=' + 
      location.pathname.replace('/pages/', '/page/').replace('.html', '') + 
      location.search.replace('?', '&');
    location.href = target;
  }
  
  // Monitor page height to send it to parent
  $(function () {
    let previousHeight = $(document).height();
    $(document).attrchange({
      callback: function (e) {
        let currentHeight = $(this).height();
        if (previousHeight !== currentHeight) {
          let msg = '[ChildFrame.ChangedHeight] Change height: ' + previousHeight;
          msg = msg + 'px to ' + currentHeight + 'px';
          console.log(msg);
  
          sendHeightData();
          previousHeight = currentHeight;
        }
      }
    }).resizable();
  });
};

/**
 * Sends height data to parent frame
 */
function sendHeightData() {
{'fraction_non_alphanumeric': 0.15978695073235685, 'fraction_numerical': 0.0013315579227696406, 'mean_word_length': 2.454022988505747, 'pattern_counts': {'":': 0, '<': 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': '2242288', 'n_tokens_mistral': 889, 'n_tokens_neox': 878, 'n_words': 221}