/* global: location, sessionStorage */

(function collectAnswers () {
  // select survey type
  if (location.pathname === '/select-survey') {
    var preSession = document.getElementById('pre-session-button')
    preSession.addEventListener('click', function () {
      sessionStorage.setItem('survey', 'pre-session')
    })

    var postSession = document.getElementById('post-session-button')
    postSession.addEventListener('click', function () {
      sessionStorage.setItem('survey', 'post-session')
    })
  }

  // obtain consent
  if (location.pathname === '/consent') {
    var yes = document.getElementById('yes')
    yes.addEventListener('click', function () {
      sessionStorage.setItem('consent', 'yes')
    })

    var no = document.getElementById('no')
    no.addEventListener('click', function () {
      sessionStorage.setItem('consent', 'no')
    })
  }

  // pre-session responses
  if (location.pathname === '/today' ||
    location.pathname === '/last-week' ||
    location.pathname === '/home' ||
    location.pathname === '/friends' ||
    location.pathname === '/school' ||
    location.pathname === '/play' ||
    location.pathname === 'next-week') {
    var veryGood = document.getElementById('very-good')
    veryGood.addEventListener('click', function () {
      sessionStorage.setItem((location.pathname).slice(1), 'very good')
    })

    var good = document.getElementById('good')
    good.addEventListener('click', function () {
      sessionStorage.setItem((location.pathname).slice(1), 'good')
    })

    var ok = document.getElementById('ok')
    ok.addEventListener('click', function () {
      sessionStorage.setItem((location.pathname).slice(1), 'ok')
    })

    var bad = document.getElementById('bad')
    bad.addEventListener('click', function () {
      sessionStorage.setItem((location.pathname).slice(1), 'bad')
    })

    var veryBad = document.getElementById('very-bad')
    veryBad.addEventListener('click', function () {
      sessionStorage.setItem((location.pathname).slice(1), 'very bad')
    })
  }

  // post-session responses
  if (location.pathname === '/listen' ||
    location.pathname === '/like' ||
    location.pathname === '/help' ||
    location.pathname === '/come-again') {
    var yes = document.getElementById('yes')
    yes.addEventListener('click', function () {
      sessionStorage.setItem((location.pathname).slice(1), 'yes')
    })

    var no = document.getElementById('no')
    no.addEventListener('click', function () {
      sessionStorage.setItem((location.pathname).slice(1), 'no')
    })

    var maybe = document.getElementById('maybe')
    maybe.addEventListener('click', function () {
      sessionStorage.setItem((location.pathname).slice(1), 'maybe')
    })
  }
})()

@@ -62,16 +62,57 @@
 ers () %7B
+%0A%0A  var path = location.pathname.slice(1)
 %0A  // se
@@ -138,32 +138,18 @@
 if (
-location.pathname
+path
  === '
-/
 sele
@@ -309,32 +309,28 @@
 age.setItem(
-'survey'
+path
 , 'pre-sessi
@@ -500,16 +500,12 @@
 tem(
-'survey'
+path
 , 'p
@@ -560,32 +560,18 @@
 if (
-location.pathname
+path
  === '
-/
 cons
@@ -700,25 +700,20 @@
 setItem(
-'consent'
+path
 , 'yes')
@@ -840,25 +840,20 @@
 setItem(
-'consent'
+path
 , 'no')%0A
@@ -901,32 +901,18 @@
 if (
-location.pathname
+path
  === '
-/
 toda
@@ -925,32 +925,18 @@
     
-location.pathname
+path
  === '
-/
 last
@@ -953,32 +953,18 @@
     
-location.pathname
+path
  === '
-/
 home
@@ -976,32 +976,18 @@
     
-location.pathname
+path
  === '
-/
 frie
@@ -1002,32 +1002,18 @@
     
-location.pathname
+path
  === '
-/
 scho
@@ -1027,32 +1027,18 @@
     
-location.pathname
+path
  === '
-/
 play
@@ -1046,33 +1046,20 @@
  %7C%7C%0A    
-location.pathname
+path
  === 'ne
@@ -1212,36 +1212,12 @@
 tem(
-(location.pathname).slice(1)
+path
 , 'v
@@ -1364,36 +1364,12 @@
 tem(
-(location.pathname).slice(1)
+path
 , 'g
@@ -1505,36 +1505,12 @@
 tem(
-(location.pathname).slice(1)
+path
 , 'o
@@ -1647,36 +1647,12 @@
 tem(
-(location.pathname).slice(1)
+path
 , 'b
@@ -1803,36 +1803,12 @@
 tem(
-(location.pathname).slice(1)
+path
 , 'v
@@ -1867,32 +1867,18 @@
 if (
-location.pathname
+path
  === '
-/
 list
@@ -1892,32 +1892,18 @@
     
-location.pathname
+path
  === '
-/
 like
@@ -1915,32 +1915,18 @@
     
-location.pathname
+path
  === '
-/
 help
@@ -1938,32 +1938,18 @@
     
-location.pathname
+path
  === '
-/
 come
@@ -2085,36 +2085,12 @@
 tem(
-(location.pathname).slice(1)
+path
 , 'y
@@ -2225,36 +2225,12 @@
 tem(
-(location.pathname).slice(1)
+path
 , 'n
@@ -2373,36 +2373,12 @@
 tem(
-(location.pathname).slice(1)
+path
 , 'm

set path var #67