<commit_before>let createElement = (tag, className = null, html = null, onclick = null) => {
  let ele = document.createElement(tag)
  if (className !== null) ele.setAttribute('class', className)
  if (html !== null) ele.innerHTML = html
  if (onclick !== null) ele.onclick = onclick
  return ele
}

// 计算绝对的偏移量（相对于html）
let absoluteOffset = (el) => {
  let { offsetLeft, offsetTop, offsetParent } = el
  if (offsetParent) {
    let pOffset = absoluteOffset(offsetParent)
    offsetLeft += pOffset.left
    offsetTop += pOffset.top
  }
  return {left: offsetLeft, top: offsetTop}
}

let setPositionStyle = (el) => {
  let client = {w: document.body.scrollWidth, h: document.body.scrollHeight}
  let offset = absoluteOffset(el)
  // console.log('offset: ', offset, el)
  let arrowPosition = ''
  let style = 'display: block;'

  console.log(client.h, ':::', offset.top)

  if (client.h / 2 > offset.top) {
    arrowPosition += 'bottom'
    style += `top: ${offset.top + el.offsetHeight}px;`
  } else {
    arrowPosition += 'top'
    style += `bottom: -${offset.top}px; top: auto;`<commit_msg>offset => getBoundClientRect<commit_after>let createElement = (tag, className = null, html = null, onclick = null) => {
  let ele = document.createElement(tag)
  if (className !== null) ele.setAttribute('class', className)
  if (html !== null) ele.innerHTML = html
  if (onclick !== null) ele.onclick = onclick
  return ele
}

// 计算绝对的偏移量（相对于html）
let absoluteOffset = (el) => {
  return el.getBoundingClientRect()
}

let setPositionStyle = (el) => {
  let client = {w: document.body.scrollWidth, h: document.body.scrollHeight}
  let offset = absoluteOffset(el)
  // console.log('offset: ', offset, el)
  let arrowPosition = ''
  let style = 'display: block;'

  console.log(client.h, ':::', offset.top)

  if (client.h / 2 > offset.top) {
    arrowPosition += 'bottom'
    style += `top: ${offset.top + el.offsetHeight}px;`
  } else {
    arrowPosition += 'top'
    style += `bottom: -${offset.top}px; top: auto;`
{'fraction_non_alphanumeric': 0.16059850374064838, 'fraction_numerical': 0.000997506234413965, 'mean_word_length': 3.7875894988066827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, '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': '1646102', 'n_tokens_mistral': 677, 'n_tokens_neox': 680, 'n_words': 169}