<commit_before>/* global CustomEvent */
import iFrameResize from 'iframe-resizer/js/iframeResizer'
import isUndefined from 'lodash-es/isUndefined'
import includes from 'lodash-es/includes'
import endsWith from 'lodash-es/endsWith'
import isEmpty from 'lodash-es/isEmpty'

class IframeIntegrationClient {
  constructor (targetUrl, elementTagName) {
    this.targetUrl = targetUrl
    this.elementTagName = elementTagName
  }

  encodeQueryData (data) {
    let ret = []
    for (let d in data) {
      ret.push(encodeURIComponent(d) + '=' + encodeURIComponent(data[d]))
    }
    return ret.join('&')
  }

  buildSourceUrl (targetUrl, options) {
    if (isEmpty(options)) {
      return targetUrl;
    }
    if (endsWith(targetUrl, '?')) {
      return `${targetUrl}${this.encodeQueryData(options)}`
    } else if (includes(targetUrl, '?')) {
      return `${targetUrl}&${this.encodeQueryData(options)}`
    } else {
      return `${targetUrl}?${this.encodeQueryData(options)}`
    }
  }

  render (options, targetUrl, elementTagName) {
    let ifrm, width, element

    if (isUndefined(elementTagName)) {
      element = document.getElementsByTagName(this.elementTagName)[0]
    } else {
      element = document.getElementsByTagName(elementTagName)[0]
    }
    if (isUndefined(element)) {
      console.error(`no matching element for listing was found or provided, place an ${this.elementTagName} on the page before executing the render method or pass an element along as the third parameter`)
      return false
    }<commit_msg>removing debug code # ficing code style<commit_after>/* global CustomEvent */
import iFrameResize from 'iframe-resizer/js/iframeResizer'
import isUndefined from 'lodash-es/isUndefined'
import includes from 'lodash-es/includes'
import endsWith from 'lodash-es/endsWith'
import isEmpty from 'lodash-es/isEmpty'

class IframeIntegrationClient {
  constructor (targetUrl, elementTagName) {
    this.targetUrl = targetUrl
    this.elementTagName = elementTagName
  }

  encodeQueryData (data) {
    let ret = []
    for (let d in data) {
      ret.push(encodeURIComponent(d) + '=' + encodeURIComponent(data[d]))
    }
    return ret.join('&')
  }

  buildSourceUrl (targetUrl, options) {
    if (isEmpty(options)) {
      return targetUrl
    }
    if (endsWith(targetUrl, '?')) {
      return `${targetUrl}${this.encodeQueryData(options)}`
    } else if (includes(targetUrl, '?')) {
      return `${targetUrl}&${this.encodeQueryData(options)}`
    } else {
      return `${targetUrl}?${this.encodeQueryData(options)}`
    }
  }

  render (options, targetUrl, elementTagName) {
    let ifrm, width, element

    if (isUndefined(elementTagName)) {
      element = document.getElementsByTagName(this.elementTagName)[0]
    } else {
      element = document.getElementsByTagName(elementTagName)[0]
    }
    if (isUndefined(element)) {
      console.error(`no matching element for listing was found or provided, place an ${this.elementTagName} on the page before executing the render method or pass an element along as the third parameter`)
      return false
    }
{'fraction_non_alphanumeric': 0.11783748786014892, 'fraction_numerical': 0.0012949174490126255, 'mean_word_length': 3.8205928237129485, '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': '1052829', 'n_tokens_mistral': 948, 'n_tokens_neox': 938, 'n_words': 229}