mose/shellplay

View on GitHub
tpl/shellplay.js

Summary

Maintainability
A
0 mins
Test Coverage
(function(){

  var current = 0;
  var last = $(".screen").size() - 1;

  function draw() {
    $(".screen").hide();
    $("#s"+current).show();
  }

  function next() {
    if (current < last) {
      current++;
    }
    draw();
  }

  function previous() {
    console.log(current);
    if (current > 0) {
      current--;
    }
    draw();
  }

  $(".screen").hide();
  $("#intro").show();


  $(document).keydown(function(e) {
    switch(e.keyCode) {
      case 39: // ->
      case 78: // n
      case 13: // enter
        next();
        break;
      case 37: // <-
      case 80: // p
        previous();
        break;
      default:
        console.log(e.keyCode);
    }
  });

}());