{"size": 914, "ext": "js", "max_stars_repo_path": "src/ex12_js_dom/task-01.js", "max_stars_repo_name": "fortnoxcode/external-courses", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/ex12_js_dom/task-01.js", "max_issues_repo_name": "fortnoxcode/external-courses", "max_issues_repo_issues_event_min_datetime": "2020-05-03T14:17:53.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-06T22:44:51.000Z", "max_forks_repo_path": "src/ex12_js_dom/task-01.js", "max_forks_repo_name": "fortnoxcode/external-courses", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 24.7027027027, "max_line_length": 118, "alphanum_fraction": 0.6553610503}
const images = [
  'https://img.itch.zone/aW1nLzI3MjAzMzUuanBn/original/PKJHwd.jpg',
  'https://images.unsplash.com/photo-1523895665936-7bfe172b757d?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80',
  'https://images.wallpaperscraft.ru/image/ozero_gory_derevia_122294_800x600.jpg'
];

let currSlide = 0;

const setSlide = (slide) => {
  currSlide = slide;
  document.getElementById('slider-container').src = images[currSlide] || images[0];
};

const move = (next) => {
  let slide = currSlide + (next ? 1 : -1);
  if (slide > images.length - 1) {
    slide = 0;
  }
  if (slide < 0) {
    slide = images.length - 1;
  }
  setSlide(slide);
};

window.onload = document.getElementById('slider-container').src = images[0];

document.onkeydown = (ev) => {
  const arrowRight = 39;
  const arrowLeft = 37;
  if (ev.keyCode === arrowLeft) {
    move();
  }
  if (ev.keyCode === arrowRight) {
    move(true);
  }
};
