<header id="challenge-header" class="site-header">
  <div class="lang-select">
    <select id="lang-select" class="lang-select">
      <option value="">English</option>
      <option value="zhtw">正體中文</option>
    </select>
  </div>
  <div class="pagination">
    <a href="{{preurl}}"
      <span class="hand">☜</span>
    </a>
    <a href="{{nexturl}}"
      <span class="hand">☞</span>
    </a>
  </div>
  <a class="filledblock" href="../index{{lang}}.html">
    Git-it
  </a>
  <span class="challenge-title">{{challengetitle}}</span>
</header>

<script type="text/javascript">
  var selector = document.getElementById('lang-select')
  var currentLang = "{{ lang }}".replace(/-/, '')
  selector.value = currentLang
  selector.addEventListener('change', function () {
    var currentChallenge = document.querySelector('.challenge-item.current')
    var dir = 'challenges' + (selector.value ? '-' + selector.value : '') + '/'
    var url = currentChallenge.href.replace(/challenges(.+)?\//, dir)
    location.href = url
  })
</script>
