<file_sep>/*
 * Name: <NAME>
 * Date: May 19, 2020
 * Section: CSE 154 AJ
 *
 * This is the JS to implement the UI
 */
"use strict";
(function() {

  window.addEventListener("load", starter);
  let gameArray = TEXT;
  console.log(TEXT);
  let packArray = [true, true, true, true, true, true, true];


  /**
   * This function is the starter function for everything that I want
   * to fire when the HTML page loads
   * no parameters, no returns
   */
  function starter() {
    /**
     * what options do I want to add:
     * sort/filter by jackbox party pack number
     * something that shows player num/range and party pack number in the textbox
   */
    id("all-games").innerHTML = "";
    for (let i = 0; i < gameArray.length; i++) {
      console.log(i);
      addGames(i);
    }
    let enterButton = document.getElementById("enter");
    enterButton.addEventListener("click", clickEnter);
    let homeButton = document.getElementById("home");
    homeButton.addEventListener("click", homeButton);
  }

  function addAllGames(gameArray, players){
    packArray = [id("box_1").checked,id("box_2").checked,id("box_3").checked,id("box_4").checked,id("box_5").checked,id("box_6").checked,id("box_7").checked]
    id("all-games").innerHTML = "";
    players = parseInt(players);
    console.log(players);
    for (let i = 0; i < gameArray.length; i++) {
      let min = gameArray[i].min;
      let max = gameArray[i].max;
      if(players >= min && players <= max){
        addGames(i);
      }
    }
  }

  function addGames(i){
    console.log(i);
    console.log(packArray[gameArray[i].pack]-1);
    if(packArray[gameArray[i].pack-1]){
      console.log(i);
      let link = document.createElement("a");
      let div = document.createElement("div");
      let gameName = gameArray[i].gamename;
      let text = document.createElement("p");
      text.innerHTML = gameName + ":" +"<br>" + gameArray[i].description ;
      let range = document.createElement("p");
      range.innerHTML =  "range: " + gameArray[i].min + "-" + gameArray[i].max + "p";
      range.classList.add("ranges");
      let pack_num = document.createElement("p");
      pack_num.innerHTML = "Party Pack: " + gameArray[i].pack;
      pack_num.classList.add("pack_num");
      let image = document.createElement("img");
      image.src = "images/" + gameArray[i].image + ".jpg";
      div.id = gameName;
      image.alt = gameName;
      image.id = "pic_" + gameName;
      link.appendChild(div);
      div.appendChild(image);
      text.appendChild(pack_num);
      text.appendChild(range);
      div.appendChild(text);
      id("all-games").appendChild(link);
    }
  }

  function clickEnter(){
    console.log("player input value:" + id("players").value);  
    addAllGames(gameArray, id("players").value);
  }

  /**
   * This function is the default id function
   * @param {string} id - an id string used by html
   * @return {element} element gotten by getElementById
   */
  function id(id) {
    return document.getElementById(id);
  }


})();<file_sep>
//sourced from excel file and 
//http://www.convertcsv.com/csv-to-json.htm
const TEXT = 
[
  {
    "pack": 1,
    "gamename": "Drawful",
    "description": "Hilarious drawing and deception game",
    "min": 5,
    "max": 8,
    "image": "drawful"
  },
  {
    "pack": 1,
    "gamename": "Fibbage XL",
    "description": "Aim to decieve friends while finding the truth",
    "min": 2,
    "max": 8,
    "image": "fibbageXL"
  },
  {
    "pack": 1,
    "gamename": "Lie Swatter",
    "description": "Find the truth from the flies and swat it down",
    "min": 1,
    "max": 100,
    "image": "lie-swatter"
  },
  {
    "pack": 1,
    "gamename": "Word Spud",
    "description": "Form strange word clouds",
    "min": 2,
    "max": 8,
    "image": "word-spud"
  },
  {
    "pack": 1,
    "gamename": "You Don't Know Jack",
    "description": "A terribly fun trivia game",
    "min": 1,
    "max": 4,
    "image": "you-dont-know-jack"
  },
  {
    "pack": 2,
    "gamename": "Bidiots",
    "description": "Draw and bid on \"Works of Art\" made by you and friends",
    "min": 2,
    "max": 6,
    "image": "bidiots"
  },
  {
    "pack": 2,
    "gamename": "Bomb Corp",
    "description": "Cooperative bomb defusal game",
    "min": 1,
    "max": 4,
    "image": "bomb-corp"
  },
  {
    "pack": 2,
    "gamename": "Earwax",
    "description": "Create an auditory experience to shock your friends",
    "min": 3,
    "max": 8,
    "image": "earwax"
  },
  {
    "pack": 2,
    "gamename": "Fibbage 2",
    "description": "Aim to decieve friends while finding the truth�AGAIN",
    "min": 2,
    "max": 8,
    "image": "fibbage-2"
  },
  {
    "pack": 2,
    "gamename": "Quiplash XL",
    "description": "Make your friends laugh enough to pick your answer",
    "min": 3,
    "max": 8,
    "image": "quiplashXL"
  },
  {
    "pack": 3,
    "gamename": "Fakin' It",
    "description": "find the faker in your group by using social deduction",
    "min": 3,
    "max": 6,
    "image": "fakin-it"
  },
  {
    "pack": 3,
    "gamename": "Guesspionage",
    "description": "Guess the percentage of strange facts",
    "min": 2,
    "max": 8,
    "image": "guesspionage"
  },
  {
    "pack": 3,
    "gamename": "Quiplash 2",
    "description": "Quiplash, but with custom episodes and cartoons",
    "min": 3,
    "max": 8,
    "image": "quiplash-2"
  },
  {
    "pack": 3,
    "gamename": "<NAME>.",
    "description": "Create the best custom T-shirts to amuse your friends",
    "min": 3,
    "max": 8,
    "image": "tee-k-o"
  },
  {
    "pack": 3,
    "gamename": "Trivia Murder Party",
    "description": "A murderously fun trivia game",
    "min": 1,
    "max": 8,
    "image": "trivia-murder-party"
  },
  {
    "pack": 4,
    "gamename": "Bracketeering",
    "description": "Have dumb arguments about dumber questions",
    "min": 3,
    "max": 16,
    "image": "bracketeering"
  },
  {
    "pack": 4,
    "gamename": "Civic Doodle",
    "description": "Commit cooperative graffiti with friends and vote on the best",
    "min": 3,
    "max": 8,
    "image": "civic-doodle"
  },
  {
    "pack": 4,
    "gamename": "Fibbage 3",
    "description": "Fibbage, but with personalized options for close friends",
    "min": 2,
    "max": 8,
    "image": "fibbage-3"
  },
  {
    "pack": 4,
    "gamename": "Monster Seeking Monster",
    "description": "Multiplayer dating sim where you're all secret monsters",
    "min": 3,
    "max": 7,
    "image": "monster-seeking-monster"
  },
  {
    "pack": 4,
    "gamename": "Survive the Internet",
    "description": "Try to make your friends tweet strange things",
    "min": 3,
    "max": 8,
    "image": "survive-the-internet"
  },
  {
    "pack": 5,
    "gamename": "Mad Verse City",
    "description": "Rap battle your friends for glory and bragging rights",
    "min": 3,
    "max": 8,
    "image": "mad-verse-city"
  },
  {
    "pack": 5,
    "gamename": "Patently Stupid",
    "description": "convince your friends to invest in your genius startup",
    "min": 3,
    "max": 8,
    "image": "patently-stupid"
  },
  {
    "pack": 5,
    "gamename": "Split the Room",
    "description": "Try to divide your friends opinions with one word",
    "min": 3,
    "max": 8,
    "image": "split-the-room"
  },
  {
    "pack": 5,
    "gamename": "You Don't Know Jack-Full Stream",
    "description": "Trivia game run by the corporation BinjPipe",
    "min": 1,
    "max": 8,
    "image": "you-dont-know-jack-full-stream"
  },
  {
    "pack": 5,
    "gamename": "<NAME>",
    "description": "Space-themed platforming fighting game",
    "min": 1,
    "max": 6,
    "image": "zeeple-dome"
  },
  {
    "pack": 6,
    "gamename": "Dictionarium",
    "description": "Define strange words and give definitions stranger words",
    "min": 3,
    "max": 8,
    "image": "dictionarium"
  },
  {
    "pack": 6,
    "gamename": "<NAME>",
    "description": "Strange stand-up to survive on a sinking ship",
    "min": 3,
    "max": 8,
    "image": "joke-boat"
  },
  {
    "pack": 6,
    "gamename": "Push The Button",
    "description": "Try and find alien infiltrators in your spaceship",
    "min": 4,
    "max": 10,
    "image": "push-the-button"
  },
  {
    "pack": 6,
    "gamename": "Role Models",
    "description": "Pigeonhole your friends into roles",
    "min": 3,
    "max": 6,
    "image": "role-models"
  },
  {
    "pack": 6,
    "gamename": "Trivia Murder Party 2",
    "description": "Murderously fun trivia game",
    "min": 1,
    "max": 8,
    "image": "trivia-murder-party-2"
  },
  {
    "pack": 7,
    "gamename": "Blather Round",
    "description": "Describe your word with a very limited vocabulary",
    "min": 2,
    "max": 6,
    "image": "blather-round"
  },
  {
    "pack": 7,
    "gamename": "Champ'd Up",
    "description": "Create champions and force them to face off for strange titles",
    "min": 3,
    "max": 8,
    "image": "champd-up"
  },
  {
    "pack": 7,
    "gamename": "Devil in the Details",
    "description": "Collaborate with your friends to survive devil suburbia",
    "min": 3,
    "max": 8,
    "image": "devil-in-the-details"
  },
  {
    "pack": 7,
    "gamename": "Quiplash 3",
    "description": "It's quiplash for the 3rd time.",
    "min": 3,
    "max": 8,
    "image": "quiplash-3"
  },
  {
    "pack": 7,
    "gamename": "Talking Points",
    "description": "Intrigue your friends with an on-the-cuff presentation",
    "min": 3,
    "max": 8,
    "image": "talking-points"
  }
 ]
 ;<file_sep>## Jackbox Sorter
link: https://adam-nicewarner.github.io/jackbox-sorter/


This is a simple site made to help you out with finding the right Jackbox Games for your group of friends. I noticed that there isn't a good repository of Jackbox Games sorted by player number and rough summary, so I made this. If there is anything you'd like to add, please message me on twitter @AdamNicewarner, and I'll do my best to fix it.
