Reveal.initialize({
  width: 375,
  height: 812,
  hash: true,
  controls: false,
  // Learn about plugins: https://revealjs.com/plugins/
  plugins: [RevealMarkdown, RevealHighlight, RevealNotes],

  dependencies: [{
    src: 'plugin/typed/typed.js',
    async: false,
    callback: function () {
      callTypedJs()
    }
  }

  ]
})

function init_type (event) {
  console.log('SLIDE CHANGE.')

  // console.log(event);
  // console.log(event.currentSlide);
  // console.log(event.indexh);

  index = event.indexh
  div_typed_content = event.currentSlide.getElementsByClassName('typed-content')[0]

  if (div_typed_content == undefined) {
    console.log('Nothing to do. No type div found.')

    return false
  }

  div_typed_content.id = 'typed-content-' + index
  div_typed_insert = event.currentSlide.getElementsByClassName('typed-insert')[0]
  div_typed_insert.id = 'typed-insert-' + index

  if (typeof window['typed' + index] === 'undefined') {
    window['typed' + index] = new Typed('#' + div_typed_insert.id, {
      stringsElement: '#' + div_typed_content.id,
      loop: false,
      startDelay: 500,
      typeSpeed: 50,
      backSpeed: 0
    })
  }
}

Reveal.on('slidechanged', event => {
  init_type(event)
})

// Hit on first slide
Reveal.on('ready', event => {
  init_type(event)
})
