<commit_before><commit_msg>Add promises marking when the containing body is in various stages of completion<commit_after>ready = $.Deferred()
complete = $.Deferred()

if /^(interactive|complete)$/.test(document.readyState)
  ready.resolve()
else
  document.addEventListener('DOMContentLoaded', -> ready.resolve())

if 'complete' == document.readyState
  complete.resolve()
else
  console.log "queuing handler since we're in state #{document.readyState}"
  window.addEventListener('load', -> complete.resolve())

console.log document.readyState

FactlinkJailRoot.ready_promise = ready.promise()
FactlinkJailRoot.load_promise = complete.promise()

FactlinkJailRoot.ready_promise.done -> console.log 'AAAAAAAAAAAAAAAA'
FactlinkJailRoot.load_promise.done -> console.log 'BBBBBBBBBBBBBBBB'


FactlinkJailRoot.ready_promise
  .then( -> FactlinkJailRoot.delay 4000)
  .then( -> console.log("final state #{document.readyState}"))
{'fraction_non_alphanumeric': 0.1248642779587405, 'fraction_numerical': 0.004343105320304018, 'mean_word_length': 6.203125, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6437399', 'n_tokens_mistral': 282, 'n_tokens_neox': 271, 'n_words': 57}