<commit_before>html = document.documentElement
body = document.body

undo_stack = []
prop_saver = (obj, prop) ->
  (newval) ->
    oldval = obj[prop]
    undo_stack.push -> obj[prop] = oldval
    obj[prop] = newval
    oldval

restore_everything = ->
  while undo_stack.length
    undo_stack.pop()()

html_marginRight = prop_saver html.style, 'marginRight'
html_overflow = prop_saver html.style, 'overflow'
body_overflow = prop_saver body.style, 'overflow'

FactlinkJailRoot.on 'modalOpened', ->
  debugger
  right_margin = window.innerWidth - html.clientWidth - html.offsetLeft
  body_width = body.offsetWidth
  if right_margin > 0
    html_marginRight right_margin + 'px'
    html_overflow 'hidden'
    body_overflow 'visible'

    width_error = body_width - body.offsetWidth

    if width_error != 0
      console.warn('browser oddness: changing right margin caused offset:',width_error, body_width, body.offsetWidth)
      # apparently firefox does this when a margin is on the html element
      right_margin -= width_error
      html_marginRight right_margin + 'px'
  else
    html_overflow 'hidden'<commit_msg>Remove debug code<commit_after>html = document.documentElement
body = document.body

undo_stack = []
prop_saver = (obj, prop) ->
  (newval) ->
    oldval = obj[prop]
    undo_stack.push -> obj[prop] = oldval
    obj[prop] = newval
    oldval

restore_everything = ->
  while undo_stack.length
    undo_stack.pop()()

html_marginRight = prop_saver html.style, 'marginRight'
html_overflow = prop_saver html.style, 'overflow'
body_overflow = prop_saver body.style, 'overflow'

FactlinkJailRoot.on 'modalOpened', ->
  right_margin = window.innerWidth - html.clientWidth - html.offsetLeft
  body_width = body.offsetWidth
  if right_margin > 0
    html_marginRight right_margin + 'px'
    html_overflow 'hidden'
    body_overflow 'visible'

    width_error = body_width - body.offsetWidth

    if width_error != 0
      console.warn('browser oddness: changing right margin caused offset:',width_error, body_width, body.offsetWidth)
      # apparently firefox does this when a margin is on the html element
      right_margin -= width_error
      html_marginRight right_margin + 'px'
  else
    html_overflow 'hidden'
{'fraction_non_alphanumeric': 0.0916030534351145, 'fraction_numerical': 0.001796138302649304, 'mean_word_length': 3.8859649122807016, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '7661135', 'n_tokens_mistral': 705, 'n_tokens_neox': 686, 'n_words': 174}