<commit_before>require 'opal'

$window.addEventListener 'DOMContentLoaded', proc {

  css = <<-CSS
    body {
      font-family: 'Arial';
    }
  CSS

  title = $document.createElement 'h1'
  title.className = 'main-title'
  title.innerHTML = 'Opal Native Example'

  desc = $document.createElement 'p'
  desc.innerHTML = "Hello world! From Opal."

  target = $document.getElementById 'native-example'

  unless target
    raise "'native-example' doesn't exist?"
  end

  target.appendChild title
  target.appendChild desc

  styles = $document.createElement 'style'
  styles.type = 'text/css'

  if styles.respond_to? :styleSheet
    styles.styleSheet.cssText = css
  else
    styles.appendChild $document.createTextNode css
  end

  $document.getElementsByTagName('head')[0].appendChild(styles)

}, false<commit_msg>Fix examples/native to use $global for window reference<commit_after>require 'opal'

$global.addEventListener 'DOMContentLoaded', proc {

  css = <<-CSS
    body {
      font-family: 'Arial';
    }

    h1 {
      color: rgb(10, 94, 232);
    }
  CSS

  document = $global.document

  title = document.createElement 'h1'
  title.className = 'main-title'
  title.innerHTML = 'Opal Native Example'

  desc = document.createElement 'p'
  desc.innerHTML = "Hello world! From Opal."

  target = document.getElementById 'native-example'

  unless target
    raise "'native-example' doesn't exist?"
  end

  target.appendChild title
  target.appendChild desc

  styles = document.createElement 'style'
  styles.type = 'text/css'

  if styles.respond_to? :styleSheet
    styles.styleSheet.cssText = css
  else
    styles.appendChild document.createTextNode css
  end

  document.getElementsByTagName('head')[0].appendChild(styles)

}, false
{'fraction_non_alphanumeric': 0.11142857142857143, 'fraction_numerical': 0.006857142857142857, 'mean_word_length': 3.632275132275132, 'pattern_counts': {'":': 0, '<': 7, '<?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': '7456109', 'n_tokens_mistral': 550, 'n_tokens_neox': 518, 'n_words': 131}