const way = require('senseway')
const wayElem = require('../../lib/wayElem')

module.exports = (model, dispatch) => {

  const waySelected = (() => {
    const c = model.how.select.channel
    const t = model.how.select.time
    return way.set(way.fill(model.timeline, 0), c, t, 1)
  })()

  const eventSelector = wayElem(model.timeline, {
    reversed: true,
    heading: 'Event to Predict',
    caption: 'We predict the events one by one. '
      + '<strong>Select</strong> an event to see '
      + 'how we form its probability.',
    selected: waySelected
  })

  eventSelector.addEventListener('click', (ev) => {
    dispatch({
      type: 'HOW_EDIT_SELECTED',
      channel: parseInt(ev.target.dataset.channel),
      time: parseInt(ev.target.dataset.time)
    })
  })

  return eventSelector
}

@@ -619,66 +619,17 @@
     
-dispatch(%7B%0A      type: 'HOW_EDIT_SELECTED',%0A      channel:
+const c =
  par
@@ -664,21 +664,22 @@
 nel)
-,
 %0A    
-  time:
+const t =
  par
@@ -707,16 +707,195 @@
 et.time)
+%0A%0A    // NaN in case where non-cell was clicked%0A    if (isNaN(c) %7C%7C isNaN(t)) %7B%0A      return%0A    %7D%0A%0A    dispatch(%7B%0A      type: 'HOW_EDIT_SELECTED',%0A      channel: c,%0A      time: t
 %0A    %7D)%0A

Fix NaN click bug