<commit_before>(function () {

  var words = {
    "animals": [
      "Barb",
      "Bandicoot",
      "Tiger",
      "Caterpillar",
      "Badger"
    ],
    "internet slangs": [
      "LMAO",
      "ROFL",
      "WWWY",
      "SHIZZLE",
      "OKAY",
      "IIGHT",
      "FOOTY"
    ],
    "countries": [
      "India",
      "Zimbabwe",
      "Russia",
      "Puerto Rico",
      "Chile",
      "China",
      "United Arab Emirates",
      "Afghanistan",
      "Uruguay",
      "Estonia",
      "Luxembourg"
    ],
    "apps": [
      "snapchat",
      "facebook",
      "blinq",
      "whatsapp",
      "telegram",
      "airbnb"
    ],
    "people": [
      "Mother Teresa",
      "Pitbull",
      "Justin Bieber",
      "Selena Gomez",
      "Taylor Swift"
    ]
  }

  // listens to keyboard for any keypress
  function listenKeyboardLetters(cb) {
    // listening forr keys all over the document for now
    var element = $(document)
    return element.on("keypress", function (event) {
      var key =   String.fromCharCode(event.charCode)
      if (key.search(/[a-zA-Z]/) != -1) {
        cb(key)
      }
    })
  }

  // unlistens the keyboard for the keypresses
  function unListenKeyboard(element) {
    if (!element) {
      var element = $(document)
    }
    element.off("keypress")
  }

  // starts the game according to the category
  function startGame(category) {
    $(".categoryscene").hide()
    $(".lives").show()
    $(".playscene").show()

    // displays the remaining lives in the DOM
    function displayLives(numLives) {
      var lives = $("#livesHearts")
      lives.empty()
      var lifeElement = "favorite"
      for (var i = 0; i < numLives; i++) {
        lives.append($(lifeElement))
      }
    }

    if (!category) {
      throw new Error("Category not given")
    }
    var numLives = 5
    displayLives(numLives)
    var categoryWords = words[category]
    var wordToFind = categoryWords[Math.floor(Math.random() * categoryWords.length)]
    var splitWord = wordToFind.split("")
    var silentSplitWord = silentWord(wordToFind).split("")
    displayWord(silentSplitWord)
    listenKeyboardLetters(function (key) {
      var found = false
      silentSplitWord.forEach(function (value, index) {
        // means not currently filled
        if (value == "_") {
          if (splitWord[index] == key) {
            silentSplitWord[index] = splitWord[index]
            found = true
          }
        }
      })
      displayWord(silentSplitWord)

      if (silentSplitWord.join("").search(/_/) == -1) {
        gameWin()
      }
      else if (!found) {
        reduceLife()
      }
    })

    function reduceLife () {
      numLives -= 1
      displayLives(numLives)
      if (numLives == 0) {
        gameOver()
      }
    }

    // in case if the game is won
    function gameWin() {
      puzzleEnd(true)
    }

    // in case of losing the game
    function gameOver() {
      puzzleEnd(false)
    }

    function puzzleEnd(win) {
      $(".categoryscene").hide()
      $(".playscene").hide()
      unListenKeyboard()

      var finalMessage = $("#finalMessage")

      var image;
      var images = {
        gameOverImages: [
          "gameover1.gif",
          "gameover2.gif"
        ],
        youWinImages: [
          "youwin.gif"
        ]
      }

      if (win) {
        image = images.youWinImages[Math.floor(Math.random() * images.youWinImages.length)]
        finalMessage.attr("class", "green-text hangStyle")
        finalMessage.html("You Won! Now go to FOSSASIA.org")
      } else {
        finalMessage.attr("class", "red-text hangStyle")
        finalMessage.html("Did you really go to school?")
        image = images.gameOverImages[Math.floor(Math.random() * images.gameOverImages.length)]
      }

      $("#finalImage").attr("src", "assets/"+image)
      $(".finalscene").show()
    }

    function displayWord (wordArray) {
      $("#wordplay").text(wordArray.join(""))
    }

  }

  function silentWord(word) {
    return word.replace(/[aeiou]/g, "_")
  }

  // initializing the plugins here
  $(document).ready(function () {
    // $(".lives").hide()
    handleSoundControl()
    resetGame()
    var wordsProps = Object.getOwnPropertyNames(words)
    wordsProps.forEach(function (value) {
      $("#selectBox").append($("<option value='" + value + "'>" + value + "</option>"))
    })

    $("select").material_select()
    $("#startButton").on("click", function (el) {
      startGame($("#selectBox").val())
    })

    $("#resetcontrol").click(function (el) {
      resetGame()
    })
  })

  function resetGame () {
    $(".lives").hide()
    $(".playscene").hide()
    $(".finalscene").hide()
    unListenKeyboard()
    $(".categoryscene").show()
  }

  // handles the events related to the sound control
  function handleSoundControl() {
    var musicControl = $("#musiccontrol").get(0)
    var soundDisplay = $("#sounddisplay")

    soundDisplay.on("click", function () {
      musicControl.muted = !musicControl.muted
      if (musicControl.muted) {
        soundDisplay.addClass("red-text")
        soundDisplay.text("volume_off")
      }
      else {
        soundDisplay.removeClass("red-text")
        soundDisplay.text("volume_up")
      }
    })
  }

})()
<commit_msg>tryagain button event add<commit_after>(function () {

  var words = {
    "animals": [
      "Barb",
      "Bandicoot",
      "Tiger",
      "Caterpillar",
      "Badger"
    ],
    "internet slangs": [
      "LMAO",
      "ROFL",
      "WWWY",
      "SHIZZLE",
      "OKAY",
      "IIGHT",
      "FOOTY"
    ],
    "countries": [
      "India",
      "Zimbabwe",
      "Russia",
      "Puerto Rico",
      "Chile",
      "China",
      "United Arab Emirates",
      "Afghanistan",
      "Uruguay",
      "Estonia",
      "Luxembourg"
    ],
    "apps": [
      "snapchat",
      "facebook",
      "blinq",
      "whatsapp",
      "telegram",
      "airbnb"
    ],
    "people": [
      "Mother Teresa",
      "Pitbull",
      "Justin Bieber",
      "Selena Gomez",
      "Taylor Swift"
    ]
  }

  // listens to keyboard for any keypress
  function listenKeyboardLetters(cb) {
    // listening forr keys all over the document for now
    var element = $(document)
    return element.on("keypress", function (event) {
      var key =   String.fromCharCode(event.charCode)
      if (key.search(/[a-zA-Z]/) != -1) {
        cb(key)
      }
    })
  }

  // unlistens the keyboard for the keypresses
  function unListenKeyboard(element) {
    if (!element) {
      var element = $(document)
    }
    element.off("keypress")
  }

  // starts the game according to the category
  function startGame(category) {
    $(".categoryscene").hide()
    $(".lives").show()
    $(".playscene").show()

    // displays the remaining lives in the DOM
    function displayLives(numLives) {
      var lives = $("#livesHearts")
      lives.empty()
      var lifeElement = "favorite"
      for (var i = 0; i < numLives; i++) {
        lives.append($(lifeElement))
      }
    }

    if (!category) {
      throw new Error("Category not given")
    }
    var numLives = 5
    displayLives(numLives)
    var categoryWords = words[category]
    var wordToFind = categoryWords[Math.floor(Math.random() * categoryWords.length)]
    var splitWord = wordToFind.split("")
    var silentSplitWord = silentWord(wordToFind).split("")
    displayWord(silentSplitWord)
    listenKeyboardLetters(function (key) {
      var found = false
      silentSplitWord.forEach(function (value, index) {
        // means not currently filled
        if (value == "_") {
          if (splitWord[index] == key) {
            silentSplitWord[index] = splitWord[index]
            found = true
          }
        }
      })
      displayWord(silentSplitWord)

      if (silentSplitWord.join("").search(/_/) == -1) {
        gameWin()
      }
      else if (!found) {
        reduceLife()
      }
    })

    function reduceLife () {
      numLives -= 1
      displayLives(numLives)
      if (numLives == 0) {
        gameOver()
      }
    }

    // in case if the game is won
    function gameWin() {
      puzzleEnd(true)
    }

    // in case of losing the game
    function gameOver() {
      puzzleEnd(false)
    }

    function puzzleEnd(win) {
      $(".categoryscene").hide()
      $(".playscene").hide()
      unListenKeyboard()

      var finalMessage = $("#finalMessage")

      var image;
      var images = {
        gameOverImages: [
          "gameover1.gif",
          "gameover2.gif"
        ],
        youWinImages: [
          "youwin.gif"
        ]
      }

      if (win) {
        image = images.youWinImages[Math.floor(Math.random() * images.youWinImages.length)]
        finalMessage.attr("class", "green-text hangStyle")
        finalMessage.html("You Won! Now go to FOSSASIA.org")
      } else {
        finalMessage.attr("class", "red-text hangStyle")
        finalMessage.html("Did you really go to school?")
        image = images.gameOverImages[Math.floor(Math.random() * images.gameOverImages.length)]
      }

      $("#finalImage").attr("src", "assets/"+image)
      $(".finalscene").show()
    }

    function displayWord (wordArray) {
      $("#wordplay").text(wordArray.join(""))
    }

  }

  function silentWord(word) {
    return word.replace(/[aeiou]/g, "_")
  }

  // initializing the plugins here
  $(document).ready(function () {
    // $(".lives").hide()
    handleSoundControl()
    resetGame()
    var wordsProps = Object.getOwnPropertyNames(words)
    wordsProps.forEach(function (value) {
      $("#selectBox").append($("<option value='" + value + "'>" + value + "</option>"))
    })

    $("select").material_select()
    $("#startButton").on("click", function (el) {
      startGame($("#selectBox").val())
    })

    $("#tryagainbutton").click(function (el) {
      resetGame()
    })

    $("#resetcontrol").click(function (el) {
      resetGame()
    })
  })

  function resetGame () {
    $(".lives").hide()
    $(".playscene").hide()
    $(".finalscene").hide()
    unListenKeyboard()
    $(".categoryscene").show()
  }

  // handles the events related to the sound control
  function handleSoundControl() {
    var musicControl = $("#musiccontrol").get(0)
    var soundDisplay = $("#sounddisplay")

    soundDisplay.on("click", function () {
      musicControl.muted = !musicControl.muted
      if (musicControl.muted) {
        soundDisplay.addClass("red-text")
        soundDisplay.text("volume_off")
      }
      else {
        soundDisplay.removeClass("red-text")
        soundDisplay.text("volume_up")
      }
    })
  }

})()
<|endoftext|>


<commit_before>var resolutionX = 30;
var resolutionY = 6;
var tileSize = 30;
var fps = 3;
var $grid = $('#scaling-grid-tetris');
var shapes = [
    "xxxx",
    "xxx\
     x..",
    "xx\
     xx",
    ".xx\
     xx.",
    ".x.\
     xxx"
];
var shapeDelay = 6;
var frameCounter = 0;
var landed = false;
function buildScreen() {
    $grid.each(function() {
      for(var i = 0; i < resolutionX*resolutionY; i++) {
        var x = i % resolutionX + 1;
        var invertedY = Math.floor(i / resolutionX) + 1;
        var y = Math.abs(invertedY - resolutionY)+1;
        var $tile = $('<div/>')
          .addClass("tile")
          .attr("id","x"+x+"-"+"y"+y)
          .css("width",tileSize+"px")
          .css("height",tileSize+"px");
        $(this).append($tile);
      }
    }).css("width",resolutionX*tileSize);
}

function gameOver() {
  $(".shape-shade").each(function() {
    $(this).removeClass("shape-shade");
    $grid.addClass("game-over");
    clearInterval(frameEvent);
  })
}

var frameEvent = function() {
  // physics of shapes
  moveLeft();
  // Feed Shapes into grid
  if(frameCounter == 1 || landed == true) {
    var randy = Math.ceil(Math.random()*resolutionY);
    var priorcell = '#x'+(resolutionX-1)+'-'+'y'+randy;
    if( $(priorcell).hasClass("plat-shade")) {
      gameOver();
    } else {
      $('#x'+resolutionX+'-'+'y'+randy).addClass("shape-shade");
      landed = false;
    }
  }
  frameCounter++;
}

var moveLeft = function() {
  $('.shape-shade').each(function() {
    var coordinates = $(this).attr("id").split("-");
    var x = coordinates[0].slice(1);
    var y = coordinates[1].slice(1);
    var newx = x - 1;
    var newcoordinates = "#x"+newx+"-"+"y"+y;
    var $priorcell = $(newcoordinates);
    if(newx > 0 && !$priorcell.hasClass("plat-shade")) {
      $(this).removeClass("shape-shade");
      $priorcell.addClass("shape-shade");
      landed = false;
    } else {
      $(this).removeClass("shape-shade");
      $(this).addClass("plat-shade");
      landed = true;
    }
  });
}

var moveUp = function() {
  $('.shape-shade').each(function() {
    var coordinates = $(this).attr("id").split("-");
    var x = coordinates[0].slice(1);
    var y = coordinates[1].slice(1);
    var newy = y;
    if(y < resolutionY) {
      newy = Number(y) + 1;
    }
    var newcoordinates = "#x"+x+"-"+"y"+newy;
    console.log(coordinates);
    console.log(newcoordinates);
    $(this).removeClass("shape-shade");
    $(newcoordinates).addClass("shape-shade");
  });
}

var moveDown = function() {
  $('.shape-shade').each(function() {
    var coordinates = $(this).attr("id").split("-");
    var x = coordinates[0].slice(1);
    var y = coordinates[1].slice(1);
    var newy = y;
    if(y > 1) {
      newy = Number(y) - 1;
    }
    var newcoordinates = "#x"+x+"-"+"y"+newy;
    console.log(coordinates);
    console.log(newcoordinates);
    $(this).removeClass("shape-shade");
    $(newcoordinates).addClass("shape-shade");
  });
}

var moveRight = function() {

}

$(document).ready(function() {
  buildScreen();
  frameEvent();
  setInterval(frameEvent, 1000/fps);
  $(window).on("keydown",function(event) {
    if(event.keyCode == 37) {
      moveLeft();
    } else if (event.keyCode == 38) {
      moveUp();
    } else if (event.keyCode == 40) {
      moveDown();
    }
  });
});<commit_msg>Basic row clearing functionality added<commit_after>var resolutionX = 30;
var resolutionY = 6;
var tileSize = 30;
var fps = 3;
var $grid = $('#scaling-grid-tetris');
var shapes = [
    "xxxx",
    "xxx\
     x..",
    "xx\
     xx",
    ".xx\
     xx.",
    ".x.\
     xxx"
];
var shapeDelay = 6;
var frameCounter = 0;
var landed = false;
function buildScreen() {
    $grid.each(function() {
      for(var i = 0; i < resolutionX*resolutionY; i++) {
        var x = i % resolutionX + 1;
        var invertedY = Math.floor(i / resolutionX) + 1;
        var y = Math.abs(invertedY - resolutionY)+1;
        var $tile = $('<div/>')
          .addClass("tile")
          .attr("id","x"+x+"-"+"y"+y)
          .css("width",tileSize+"px")
          .css("height",tileSize+"px");
        $(this).append($tile);
      }
    }).css("width",resolutionX*tileSize);
}

function gameOver() {
  $(".shape-shade").each(function() {
    $(this).removeClass("shape-shade");
    $grid.addClass("game-over");
    clearInterval(frameEvent);
  })
}

var frameEvent = function() {
  // physics of shapes
  moveLeft();

  // clear fullRows
  var rowFilledTo = {};
  $('.plat-shade').each(function() {
    var coordinates = $(this).attr("id").split("-");
    var x = coordinates[0].slice(1);
    var y = coordinates[1].slice(1);
    if(!rowFilledTo.hasOwnProperty(x)) {
      rowFilledTo[x] = 1;
    } else {
      rowFilledTo[x]++;
    }
  });
  for(var row in rowFilledTo) {
    if(rowFilledTo[row] == resolutionY) {
      for(var y = 1; y <= resolutionY; y++) {
        var x = row;
        $(makeCoordinates(x,y)).removeClass("plat-shade");
      }
      $('.plat-shade').each(function() {
        var coordinates = $(this).attr("id").split("-");
        var x = coordinates[0].slice(1);
        var y = coordinates[1].slice(1);
        $(this).removeClass("plat-shade");
        $(makeCoordinates(x-1,y)).addClass("plat-shade");
      });
    }
  }

  // Feed Shapes into grid
  if(frameCounter == 1 || landed == true) {
    var randy = Math.ceil(Math.random()*resolutionY);
    var priorcell = '#x'+(resolutionX-1)+'-'+'y'+randy;
    if( $(priorcell).hasClass("plat-shade")) {
      gameOver();
    } else {
      $('#x'+resolutionX+'-'+'y'+randy).addClass("shape-shade");
      landed = false;
    }
  }
  frameCounter++;
}

var moveLeft = function() {
  $('.shape-shade').each(function() {
    var coordinates = $(this).attr("id").split("-");
    var x = coordinates[0].slice(1);
    var y = coordinates[1].slice(1);
    var newx = x - 1;
    var newcoordinates = "#x"+newx+"-"+"y"+y;
    var $priorcell = $(newcoordinates);
    if(newx > 0 && !$priorcell.hasClass("plat-shade")) {
      $(this).removeClass("shape-shade");
      $priorcell.addClass("shape-shade");
      landed = false;
    } else {
      $(this).removeClass("shape-shade");
      $(this).addClass("plat-shade");
      landed = true;
    }
  });
}

var moveUp = function() {
  $('.shape-shade').each(function() {
    var coordinates = $(this).attr("id").split("-");
    var x = coordinates[0].slice(1);
    var y = coordinates[1].slice(1);
    var newy = y;
    if(y < resolutionY) {
      newy = Number(y) + 1;
    }
    var newcoordinates = "#x"+x+"-"+"y"+newy;
    console.log(coordinates);
    console.log(newcoordinates);
    if(!$(newcoordinates).hasClass("plat-shade")) {
      $(this).removeClass("shape-shade");
      $(newcoordinates).addClass("shape-shade");
    }

  });
}

var moveDown = function() {
  $('.shape-shade').each(function() {
    var coordinates = $(this).attr("id").split("-");
    var x = coordinates[0].slice(1);
    var y = coordinates[1].slice(1);
    var newy = y;
    if(y > 1) {
      newy = Number(y) - 1;
    }
    var newcoordinates = "#x"+x+"-"+"y"+newy;
    console.log(coordinates);
    console.log(newcoordinates);
    if(!$(newcoordinates).hasClass("plat-shade")) {
      $(this).removeClass("shape-shade");
      $(newcoordinates).addClass("shape-shade");
    }

  });
}

var moveRight = function() {

}

$(document).ready(function() {
  buildScreen();
  frameEvent();
  setInterval(frameEvent, 1000/fps);
  $(window).on("keydown",function(event) {
    if(event.keyCode == 37) {
      moveLeft();
    } else if (event.keyCode == 38) {
      moveUp();
    } else if (event.keyCode == 40) {
      moveDown();
    }
  });
});

// utility

function makeCoordinates(x,y) {
  return "#x"+x+"-y"+y;
}<|endoftext|>


<commit_before>function addThingToSlidyThing(caption, background, page){
	var slidyThing = document.getElementById("myCarousel");
	{
		var indicatorsCon = slidyThing.getElementsByClassName("carousel-indicators")[0]
		var count = indicatorsCon.children.length;
		var element = document.createElement("li");
		if(count == 0) element.className += "active";
		element.setAttribute("data-target", "#myCarousel");
		element.setAttribute("data-slide-to", count);
		indicatorsCon.appendChild(element);
	}

	var slidesCon = slidyThing.getElementsByClassName("carousel-inner")[0];
	var element = document.createElement("a");
	element.className = "item";

	if(slidesCon.children.length == 0) element.className += " active";

	element.href = page;

		var cap = document.createElement("div");
		cap.className = "carousel-caption";

		// var h2 = document.createElement("h2");
		// h2.innerHTML = head;
		// cap.appendChild(h2);

		// var ch3 = document.createElement("h3");
		// ch3.innerHTML = captionhead;
		// cap.appendChild(ch3);

		var cp = document.createElement("p");
		cp.innerHTML = caption;
		cap.appendChild(cp);

	element.appendChild(cap);

		var img = document.createElement("img");
		img.src = background;
		console.log(img.src);
	element.appendChild(img);

	slidesCon.appendChild(element);
}

$(document).ready(function(){
	var thingamajigs = [
		["Get circles! Three in a row increases your size and multiplier. Avoid triangles! Three will take your multiplier and 25 points.", "img/Slider/CubeInfinity.png", "game1.html"],
		["Speed down the highway to catch the escaping villain in your Austin martin db5. !!Explosions!!", "img/Slider/Highway.png", "game2.html"],
		["Build a castle to protect your king from the devastating fury of the enemies cannon fire. Hit the enemy king with a cannon ball to win.", "img/Slider/CannonKings.png", "game3.html"],

		["You have stolen forbidden magic from the high mages, and have been sent to a labyrinth called Renovo as punishment.", "img/Slider/Renovo.png", "game11.html"],
		["Can you solve the puzzles and lead Walter out of Walters Wizard Warehouse.", "img/Slider/WWW.png", "game12.html"],
		["Hear the Music, be the music.", "img/Slider/Rizard.png", "game13.html"],

		["Prevent tourists from disrupting your quiet fishing spot so that you can release the kraken.", "img/Slider/GetKraken.png", "game21.html"],
		["Everyone knows that antivirus programs play Bomberman in their spare time!", "img/Slider/AntiVirus.png", "game22.html"],
		["This is Valour, a 2D side-scrolling platform game based on the aftermath of Normandy Beach from World War 2.", "img/Slider/Valour.png", "game23.html"],
		["How did you end up here? Too much science! Harvest sheep on this pixellated island if you want any hope of surviving the night.", "img/Slider/67.png", "game24.html"],
		["You are alone on an alien world and your ship is out of fuel. Find the compound you need to fuel your ship and get home.", "img/Slider/Galileo.png", "game25.html"],
		["Fight through waves of zombies while you collect parts to fix for your broken down car. Collect by day, fight by night.", "img/Slider/DeadWood.png", "game26.html"],
	];

	var dfsvg = thingamajigs[0];
	addThingToSlidyThing(dfsvg[0], dfsvg[1], dfsvg[2]);

});
<commit_msg>Randomised slider finished<commit_after>function addThingToSlidyThing(caption, background, page){
	var slidyThing = document.getElementById("myCarousel");
	{
		var indicatorsCon = slidyThing.getElementsByClassName("carousel-indicators")[0]
		var count = indicatorsCon.children.length;
		var element = document.createElement("li");
		if(count == 0) element.className += "active";
		element.setAttribute("data-target", "#myCarousel");
		element.setAttribute("data-slide-to", count);
		indicatorsCon.appendChild(element);
	}

	var slidesCon = slidyThing.getElementsByClassName("carousel-inner")[0];
	var element = document.createElement("a");
	element.className = "item";

	if(slidesCon.children.length == 0) element.className += " active";

	element.href = page;

		var cap = document.createElement("div");
		cap.className = "carousel-caption";

		// var h2 = document.createElement("h2");
		// h2.innerHTML = head;
		// cap.appendChild(h2);

		// var ch3 = document.createElement("h3");
		// ch3.innerHTML = captionhead;
		// cap.appendChild(ch3);

		var cp = document.createElement("p");
		cp.innerHTML = caption;
		cap.appendChild(cp);

	element.appendChild(cap);

		var img = document.createElement("img");
		img.src = background;
		console.log(img.src);
	element.appendChild(img);

	slidesCon.appendChild(element);
}

function shuffle(array) {
  var currentIndex = array.length, temporaryValue, randomIndex ;

  // While there remain elements to shuffle...
  while (0 !== currentIndex) {

    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = array[currentIndex];
    array[currentIndex] = array[randomIndex];
    array[randomIndex] = temporaryValue;
  }

  return array;
}

$(document).ready(function(){
	var gamesInSlider = [
		["Get circles! Three in a row increases your size and multiplier. Avoid triangles! Three will take your multiplier and 25 points.", "img/Slider/CubeInfinity.png", "game1.html"],
		["Speed down the highway to catch the escaping villain in your Austin martin db5. !!Explosions!!", "img/Slider/Highway.png", "game2.html"],
		["Build a castle to protect your king from the devastating fury of the enemies cannon fire. Hit the enemy king with a cannon ball to win.", "img/Slider/CannonKings.png", "game3.html"],

		["You have stolen forbidden magic from the high mages, and have been sent to a labyrinth called Renovo as punishment.", "img/Slider/Renovo.png", "game11.html"],
		["Can you solve the puzzles and lead Walter out of Walters Wizard Warehouse.", "img/Slider/WWW.png", "game12.html"],
		["Hear the Music, be the music.", "img/Slider/Rizard.png", "game13.html"],

		["Prevent tourists from disrupting your quiet fishing spot so that you can release the kraken.", "img/Slider/GetKraken.png", "game21.html"],
		["Everyone knows that antivirus programs play Bomberman in their spare time!", "img/Slider/AntiVirus.png", "game22.html"],
		["This is Valour, a 2D side-scrolling platform game based on the aftermath of Normandy Beach from World War 2.", "img/Slider/Valour.png", "game23.html"],
		["How did you end up here? Too much science! Harvest sheep on this pixellated island if you want any hope of surviving the night.", "img/Slider/67.png", "game24.html"],
		["You are alone on an alien world and your ship is out of fuel. Find the compound you need to fuel your ship and get home.", "img/Slider/Galileo.png", "game25.html"],
		["Fight through waves of zombies while you collect parts to fix for your broken down car. Collect by day, fight by night.", "img/Slider/DeadWood.png", "game26.html"],
	];

	shuffle(gamesInSlider);

	for(i = 0; i < gamesInSlider.length; i++) {
		var temp = gamesInSlider[i];
		addThingToSlidyThing(temp[0], temp[1], temp[2]);
	}
});
<|endoftext|>


<commit_before>// Generales
function alertDismissed() {}
function checkConnection() {
  var networkState = navigator.connection.type;
  var states = {};
  states[Connection.UNKNOWN] = 'Desconocida';
  states[Connection.ETHERNET] = 'Ethernet';
  states[Connection.WIFI] = 'WiFi';
  states[Connection.CELL_2G] = 'Teléfono 2G';
  states[Connection.CELL_3G] = 'Teléfono 3G';
  states[Connection.CELL_4G] = 'Teléfono 4G';
  states[Connection.NONE] = 'Sin conexión';
  alert('Conexión de red: ' + states[networkState]);
}

// Al cargar la página de noticias
$(document).on('pagebeforeshow', '#noticias', function() {
  $.ajax({
    url: 'http://www.villarrobledo.com/app/listado_noticias.php',
    type: 'GET',
    dataType: 'json',
    timeout: 25000,
    success: function(data, status) {
      $.each(data, function(i,item) {
        $('#listadonoticias').append('
' + item.publicacion + '
' + item.titulo + '
').trigger("create");
      });
    },
    error: function(xhr, status, error) {
      alert("ERROR - xhr.status: " + xhr.status + '\nxhr.responseText: ' + xhr.responseText + '\nxhr.statusText: ' + xhr.statusText + '\nError: ' + error + '\nStatus: ' + status);
    }
  });
});

// Al cargar Cordova PhoneGap
function onDeviceReady() {
  //navigator.notification.alert("El dispositivo está listo", alertDismissed(), 'Aviso', 'Cerrar');
  // checkConnection();
  $('#consola').empty().append('
El dispositivo está listo
').trigger("create");
}

// Al cargar la aplicación
function init() {
  document.addEventListener("deviceready", onDeviceReady(), false);
}
<commit_msg>Check connection<commit_after>// Generales
function alertDismissed() {}
function checkConnection() {
  var networkState = navigator.connection.type;
  var states = {};
  states[Connection.UNKNOWN] = 'Desconocida';
  states[Connection.ETHERNET] = 'Ethernet';
  states[Connection.WIFI] = 'WiFi';
  states[Connection.CELL_2G] = 'Teléfono 2G';
  states[Connection.CELL_3G] = 'Teléfono 3G';
  states[Connection.CELL_4G] = 'Teléfono 4G';
  states[Connection.NONE] = 'Sin conexión';
  alert('Conexión de red: ' + states[networkState]);
}

// Al cargar la página de noticias
$(document).on('pagebeforeshow', '#noticias', function() {
  $.ajax({
    url: 'http://www.villarrobledo.com/app/listado_noticias.php',
    type: 'GET',
    dataType: 'json',
    timeout: 25000,
    success: function(data, status) {
      $.each(data, function(i,item) {
        $('#listadonoticias').append('
' + item.publicacion + '
' + item.titulo + '
').trigger("create");
      });
    },
    error: function(xhr, status, error) {
      alert("ERROR - xhr.status: " + xhr.status + '\nxhr.responseText: ' + xhr.responseText + '\nxhr.statusText: ' + xhr.statusText + '\nError: ' + error + '\nStatus: ' + status);
    }
  });
});

// Al cargar Cordova PhoneGap
function onDeviceReady() {
  //navigator.notification.alert("El dispositivo está listo", alertDismissed(), 'Aviso', 'Cerrar');
  $('#consola').empty().append('
El dispositivo está listo.
').trigger("create");
  checkConnection();
}

// Al cargar la aplicación
function init() {
  document.addEventListener("deviceready", onDeviceReady(), false);
}
<|endoftext|>


<commit_before>/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/

function getopts(args, opts)
{
  var result = opts.default || {};
  args.replace(
      new RegExp("([^?=&]+)(=([^&]*))?", "g"),
      function($0, $1, $2, $3) { result[$1] = $3; });

  return result;
};

var args = getopts(location.search,
{
  default:
  {
    ws_uri: 'wss://219.251.4.177:30007/kurento',
    ice_servers: undefined
  }
});

if (args.ice_servers) {
  console.log("Use ICE servers: " + args.ice_servers);
  kurentoUtils.WebRtcPeer.prototype.server.iceServers = JSON.parse(args.ice_servers);
} else {
  console.log("Use freeice")
}

window.addEventListener('load', function(){
  console = new Console('console', console);
	var videoOutput = document.getElementById('videoOutput');
	var address = document.getElementById('address');
	address.value = 'rtsp://192.168.10.156/avc';
  var pipeline;
  var webRtcPeer;

  startButton = document.getElementById('start');
  startButton.addEventListener('click', start);

  stopButton = document.getElementById('stop');
  stopButton.addEventListener('click', stop);

  function start() {
  	if(!address.value){
  	  window.alert("You must set the video source URL first");
  	  return;
  	}
  	address.disabled = true;
  	showSpinner(videoOutput);
    var options = {
      remoteVideo : videoOutput
    };
    webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(options,
      function(error){
        if(error){
          return console.error(error);
        }
        webRtcPeer.generateOffer(onOffer);
        webRtcPeer.peerConnection.addEventListener('iceconnectionstatechange', function(event){
          if(webRtcPeer && webRtcPeer.peerConnection){
            console.log("oniceconnectionstatechange -> " + webRtcPeer.peerConnection.iceConnectionState);
            console.log('icegatheringstate -> ' + webRtcPeer.peerConnection.iceGatheringState);
          }
        });
    });
  }

  function onOffer(error, sdpOffer){
    if(error) return onError(error);

  	kurentoClient(args.ws_uri, function(error, kurentoClient) {
  		if(error) return onError(error);

  		kurentoClient.create("MediaPipeline", function(error, p) {
  			if(error) return onError(error);

  			pipeline = p;

  			pipeline.create("PlayerEndpoint", {uri: address.value}, function(error, player){
  			  if(error) return onError(error);

  			  pipeline.create("WebRtcEndpoint", function(error, webRtcEndpoint){
  				if(error) return onError(error);

          setIceCandidateCallbacks(webRtcEndpoint, webRtcPeer, onError);

  				webRtcEndpoint.processOffer(sdpOffer, function(error, sdpAnswer){
  					if(error) return onError(error);

            webRtcEndpoint.gatherCandidates(onError);

  					webRtcPeer.processAnswer(sdpAnswer);
  				});

  				player.connect(webRtcEndpoint, function(error){
  					if(error) return onError(error);

  					console.log("PlayerEndpoint-->WebRtcEndpoint connection established");

  					player.play(function(error){
  					  if(error) return onError(error);

  					  console.log("Player playing ...");
  					});
  				});
  			});
  			});
  		});
  	});
  }

  function stop() {
    address.disabled = false;
    if (webRtcPeer) {
      webRtcPeer.dispose();
      webRtcPeer = null;
    }
    if(pipeline){
      pipeline.release();
      pipeline = null;
    }
    hideSpinner(videoOutput);
  }

});

function setIceCandidateCallbacks(webRtcEndpoint, webRtcPeer, onError){
  webRtcPeer.on('icecandidate', function(candidate){
    console.log("Local icecandidate " + JSON.stringify(candidate));

    candidate = kurentoClient.register.complexTypes.IceCandidate(candidate);

    webRtcEndpoint.addIceCandidate(candidate, onError);

  });
  webRtcEndpoint.on('OnIceCandidate', function(event){
    var candidate = event.candidate;

    console.log("Remote icecandidate " + JSON.stringify(candidate));

    webRtcPeer.addIceCandidate(candidate, onError);
  });
}

function onError(error) {
  if(error)
  {
    console.error(error);
    stop();
  }
}

function showSpinner() {
	for (var i = 0; i < arguments.length; i++) {
		arguments[i].poster = 'img/transparent-1px.png';
		arguments[i].style.background = "center transparent url('img/spinner.gif') no-repeat";
	}
}

function hideSpinner() {
	for (var i = 0; i < arguments.length; i++) {
		arguments[i].src = '';
		arguments[i].poster = 'img/webrtc.png';
		arguments[i].style.background = '';
	}
}

/**
 * Lightbox utility (to display media pipeline image in a modal dialog)
 */
$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
	event.preventDefault();
	$(this).ekkoLightbox();
});
<commit_msg>Update index.js<commit_after>/*
* (C) Copyright 2014 Kurento (http://kurento.org/)
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Lesser General Public License
* (LGPL) version 2.1 which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/lgpl-2.1.html
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/

function getopts(args, opts)
{
  var result = opts.default || {};
  args.replace(
      new RegExp("([^?=&]+)(=([^&]*))?", "g"),
      function($0, $1, $2, $3) { result[$1] = $3; });

  return result;
};

var args = getopts(location.search,
{
  default:
  {
    ws_uri: 'wss://219.251.4.177:30008/kurento',
    ice_servers: undefined
  }
});

if (args.ice_servers) {
  console.log("Use ICE servers: " + args.ice_servers);
  kurentoUtils.WebRtcPeer.prototype.server.iceServers = JSON.parse(args.ice_servers);
} else {
  console.log("Use freeice")
}

window.addEventListener('load', function(){
  console = new Console('console', console);
	var videoOutput = document.getElementById('videoOutput');
	var address = document.getElementById('address');
	address.value = 'rtsp://192.168.10.156/avc';
  var pipeline;
  var webRtcPeer;

  startButton = document.getElementById('start');
  startButton.addEventListener('click', start);

  stopButton = document.getElementById('stop');
  stopButton.addEventListener('click', stop);

  function start() {
  	if(!address.value){
  	  window.alert("You must set the video source URL first");
  	  return;
  	}
  	address.disabled = true;
  	showSpinner(videoOutput);
    var options = {
      remoteVideo : videoOutput
    };
    webRtcPeer = kurentoUtils.WebRtcPeer.WebRtcPeerRecvonly(options,
      function(error){
        if(error){
          return console.error(error);
        }
        webRtcPeer.generateOffer(onOffer);
        webRtcPeer.peerConnection.addEventListener('iceconnectionstatechange', function(event){
          if(webRtcPeer && webRtcPeer.peerConnection){
            console.log("oniceconnectionstatechange -> " + webRtcPeer.peerConnection.iceConnectionState);
            console.log('icegatheringstate -> ' + webRtcPeer.peerConnection.iceGatheringState);
          }
        });
    });
  }

  function onOffer(error, sdpOffer){
    if(error) return onError(error);

  	kurentoClient(args.ws_uri, function(error, kurentoClient) {
  		if(error) return onError(error);

  		kurentoClient.create("MediaPipeline", function(error, p) {
  			if(error) return onError(error);

  			pipeline = p;

  			pipeline.create("PlayerEndpoint", {uri: address.value}, function(error, player){
  			  if(error) return onError(error);

  			  pipeline.create("WebRtcEndpoint", function(error, webRtcEndpoint){
  				if(error) return onError(error);

          setIceCandidateCallbacks(webRtcEndpoint, webRtcPeer, onError);

  				webRtcEndpoint.processOffer(sdpOffer, function(error, sdpAnswer){
  					if(error) return onError(error);

            webRtcEndpoint.gatherCandidates(onError);

  					webRtcPeer.processAnswer(sdpAnswer);
  				});

  				player.connect(webRtcEndpoint, function(error){
  					if(error) return onError(error);

  					console.log("PlayerEndpoint-->WebRtcEndpoint connection established");

  					player.play(function(error){
  					  if(error) return onError(error);

  					  console.log("Player playing ...");
  					});
  				});
  			});
  			});
  		});
  	});
  }

  function stop() {
    address.disabled = false;
    if (webRtcPeer) {
      webRtcPeer.dispose();
      webRtcPeer = null;
    }
    if(pipeline){
      pipeline.release();
      pipeline = null;
    }
    hideSpinner(videoOutput);
  }

});

function setIceCandidateCallbacks(webRtcEndpoint, webRtcPeer, onError){
  webRtcPeer.on('icecandidate', function(candidate){
    console.log("Local icecandidate " + JSON.stringify(candidate));

    candidate = kurentoClient.register.complexTypes.IceCandidate(candidate);

    webRtcEndpoint.addIceCandidate(candidate, onError);

  });
  webRtcEndpoint.on('OnIceCandidate', function(event){
    var candidate = event.candidate;

    console.log("Remote icecandidate " + JSON.stringify(candidate));

    webRtcPeer.addIceCandidate(candidate, onError);
  });
}

function onError(error) {
  if(error)
  {
    console.error(error);
    stop();
  }
}

function showSpinner() {
	for (var i = 0; i < arguments.length; i++) {
		arguments[i].poster = 'img/transparent-1px.png';
		arguments[i].style.background = "center transparent url('img/spinner.gif') no-repeat";
	}
}

function hideSpinner() {
	for (var i = 0; i < arguments.length; i++) {
		arguments[i].src = '';
		arguments[i].poster = 'img/webrtc.png';
		arguments[i].style.background = '';
	}
}

/**
 * Lightbox utility (to display media pipeline image in a modal dialog)
 */
$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) {
	event.preventDefault();
	$(this).ekkoLightbox();
});
<|endoftext|>


<commit_before>var submit = document.getElementById("submit");
var keywords = document.getElementById("keywords");
var opts = {
  lines: 13, // The number of lines to draw
  length: 5, // The length of each line
  width: 2, // The line thickness
  radius: 7, // The radius of the inner circle
  corners: 1, // Corner roundness (0..1)
  rotate: 4, // The rotation offset
  direction: 1, // 1: clockwise, -1: counterclockwise
  color: '#000', // #rgb or #rrggbb or array of colors
  speed: 1.2, // Rounds per second
  trail: 42, // Afterglow percentage
  shadow: false, // Whether to render a shadow
  hwaccel: false, // Whether to use hardware acceleration
  className: 'spinner', // The CSS class to assign to the spinner
  zIndex: 2e9 // The z-index (defaults to 2000000000)
};
var spinner = new Spinner(opts);
var body = document.body;
var desc = document.getElementById("desc");
var spinDiv = document.getElementById("spinner");
var values = ["The internet hates you and your keywords",
"The internet strongly dislikes you and your keywords",
"The internet would appreciate it if you changed your interests to not include those keywords",
"The internet is slightly irritated with your keywords",
"The internet is a tad bit annoyed when someone searches your keywords",
"The internet is indifferent to you and your keywords",
"The internet has a faintly positive reaction to your keywords",
"The internet feels good when it sees your keywords",
"The internet has butterflies in its stomach when your keywords appear",
"The internet would love to have coffee with your keywords",
"The internet wants to put up ads for your keywords for free"];
var invisibleColor = "rgba(0, 0, 0, 0)";
//var chart;
//addEventListener('load',function(e){chart = document.getElementById('chartDiv');});
function drawChart(array,bgcolor) {
    var ourData = [];
    var chart = document.getElementById('chartDiv');
    var data = new google.visualization.DataTable();

    data.addColumn('string', 'Source');
    data.addColumn('number', 'Opinion Factor');
    var i=1;
    for(var key in array) {
        ourData[i] = [];
        ourData[i][1] = array[key];
        key = key.split("-")[1];
        key = key[0].toUpperCase() + key.slice(1);
        ourData[i][0] = key;
        data.addRows([ourData[i]]);
        i++;
    }

    var table = new google.visualization.Table(document.getElementById('chartContainer'));
    var formatter = new google.visualization.BarFormat({width: 120});
    formatter.format(data, 1); // Apply formatter to second column

    table.draw(data, {allowHtml: true, showRowNumber: true});
    var options = {
      base: 0,
      colorNegative: "blue",
      colorPositive: "red",
      max: 1,
      min: -1,
      width: 100,
      drawZeroLine: true,
    };
    document.getElementById('chartContainer').style.display = "block";
}

submit.onclick=function(e) {
    if(keywords.value != "") {
        var req = new XMLHttpRequest();
        req.open("GET", "AnalysisCoordinator.php?q=" + encodeURIComponent(keywords.value));
        desc.innerHTML = "";
        spinner.spin(spinDiv);
        req.onreadystatechange = function() {
    		if(req.readyState == 4) {
                if(req.status == 200) {
                    spinner.stop();
                    console.log(req.responseText);
                    var scores = JSON.parse(req.responseText);

                    var score = 0;
                    var count = 0;
                    var isRateLimited = false;
                    for(var key in scores) {
                        //Use scores[key] as the value and key as the key
                        if(scores[key] != 2) {
                            score += scores[key];
                            count++;
                        }
                        else {
                            isRateLimited = key;
                            break;
                        }
                    }
                    if(!isRateLimited) {
                        score = score / count;
                    }
                    else {
                        score = 2;
                    }
                    if(isRateLimited) {
                        desc.innerHTML = "You have been rate limited on " + isRateLimited;
                        color = "rgba(225, 225, 225, 1)";
                        borderColor = "rgba(125, 125, 125, 0.5)";
                    }
                    else if(score > 0) {
                        color = "rgba(0, 0, 225, " + (score/2) + ")";
                        borderColor = "rgba(0, 0, 225, " + (score+0.2) + ")";
                        console.log(color);
                    }
                    else {
                        color = "rgba(225, 0, 0, " + -(score / 2) + ")";
                        borderColor = "rgba(225, 0, 0, " + -(score + 0.2) + ")";
                    }
                    console.log(color);
                    body.style.backgroundColor = color;
                    console.log(color);
                    //bContainer.style.backgroundColor = "#FFFFFF";
                    //submit.style.borderColor = invisibleColor;
                    keywords.style.borderColor = "rbga(100,100,100,.1)";
                    if(document.querySelector("#submit:hover")) {
                        submit.style.borderColor = borderColor;
                    }
                    else if(document.activeElement == keywords) {
                        keywords.style.borderColor = borderColor;
                    }
                    keywords.onfocus = function() {
                        keywords.style.borderColor = borderColor;
                    }
                    keywords.onblur = function() {
                        keywords.style.borderColor = invisibleColor;
                    }
                    submit.onmouseover = function() {
                        submit.style.borderColor = borderColor;
                    }
                    submit.onmouseout = function() {
                        submit.style.borderColor = invisibleColor;
                    }
                    if(score >= -1 && score <= 1) {
                        score *= 100;
                        score /= 20;
                        score = Math.floor(score);
                        score += 5;
                        desc.innerHTML = values[score];
                        desc.classList.add("active");
                    }
                    if(!isRateLimited) {
                        document.getElementById('chartContainer').style.visibility = "visible";
                        drawChart(scores,color);
                    }
                    else {
                        document.getElementById('chartContainer').style.visibility = "hidden";
                    }
                } else {
                    desc.innerHTML = "Hmm, something went wrong..";
                    spinner.stop();
                }
    		}
        }
        req.send();
	} else {
	    desc.innerHTML = "Please enter a keyword or phrase";
	}

}
keywords.onkeydown = function(e) {
    if(e.keyCode == 13) {
        submit.click();
    }
}<commit_msg>Hide graph on search<commit_after>var submit = document.getElementById("submit");
var keywords = document.getElementById("keywords");
var opts = {
  lines: 13, // The number of lines to draw
  length: 5, // The length of each line
  width: 2, // The line thickness
  radius: 7, // The radius of the inner circle
  corners: 1, // Corner roundness (0..1)
  rotate: 4, // The rotation offset
  direction: 1, // 1: clockwise, -1: counterclockwise
  color: '#000', // #rgb or #rrggbb or array of colors
  speed: 1.2, // Rounds per second
  trail: 42, // Afterglow percentage
  shadow: false, // Whether to render a shadow
  hwaccel: false, // Whether to use hardware acceleration
  className: 'spinner', // The CSS class to assign to the spinner
  zIndex: 2e9 // The z-index (defaults to 2000000000)
};
var spinner = new Spinner(opts);
var body = document.body;
var desc = document.getElementById("desc");
var spinDiv = document.getElementById("spinner");
var values = ["The internet hates you and your keywords",
"The internet strongly dislikes you and your keywords",
"The internet would appreciate it if you changed your interests to not include those keywords",
"The internet is slightly irritated with your keywords",
"The internet is a tad bit annoyed when someone searches your keywords",
"The internet is indifferent to you and your keywords",
"The internet has a faintly positive reaction to your keywords",
"The internet feels good when it sees your keywords",
"The internet has butterflies in its stomach when your keywords appear",
"The internet would love to have coffee with your keywords",
"The internet wants to put up ads for your keywords for free"];
var invisibleColor = "rgba(0, 0, 0, 0)";
//var chart;
//addEventListener('load',function(e){chart = document.getElementById('chartDiv');});
function drawChart(array,bgcolor) {
    var ourData = [];
    var chart = document.getElementById('chartDiv');
    var data = new google.visualization.DataTable();

    data.addColumn('string', 'Source');
    data.addColumn('number', 'Opinion Factor');
    var i=1;
    for(var key in array) {
        ourData[i] = [];
        ourData[i][1] = array[key];
        key = key.split("-")[1];
        key = key[0].toUpperCase() + key.slice(1);
        ourData[i][0] = key;
        data.addRows([ourData[i]]);
        i++;
    }

    var table = new google.visualization.Table(document.getElementById('chartContainer'));
    var formatter = new google.visualization.BarFormat({width: 120});
    formatter.format(data, 1); // Apply formatter to second column

    table.draw(data, {allowHtml: true, showRowNumber: true});
    var options = {
      base: 0,
      colorNegative: "blue",
      colorPositive: "red",
      max: 1,
      min: -1,
      width: 100,
      drawZeroLine: true,
    };
    document.getElementById('chartContainer').style.display = "block";
}

submit.onclick=function(e) {
    if(keywords.value != "") {
        var req = new XMLHttpRequest();
        document.getElementById('chartContainer').style.visibility = "hidden";
        req.open("GET", "AnalysisCoordinator.php?q=" + encodeURIComponent(keywords.value));
        desc.innerHTML = "";
        spinner.spin(spinDiv);
        req.onreadystatechange = function() {
    		if(req.readyState == 4) {
                if(req.status == 200) {
                    spinner.stop();
                    console.log(req.responseText);
                    var scores = JSON.parse(req.responseText);

                    var score = 0;
                    var count = 0;
                    var isRateLimited = false;
                    for(var key in scores) {
                        //Use scores[key] as the value and key as the key
                        if(scores[key] != 2) {
                            score += scores[key];
                            count++;
                        }
                        else {
                            isRateLimited = key;
                            break;
                        }
                    }
                    if(!isRateLimited) {
                        score = score / count;
                    }
                    else {
                        score = 2;
                    }
                    if(isRateLimited) {
                        desc.innerHTML = "You have been rate limited on " + isRateLimited;
                        color = "rgba(225, 225, 225, 1)";
                        borderColor = "rgba(125, 125, 125, 0.5)";
                    }
                    else if(score > 0) {
                        color = "rgba(0, 0, 225, " + (score/2) + ")";
                        borderColor = "rgba(0, 0, 225, " + (score+0.2) + ")";
                        console.log(color);
                    }
                    else {
                        color = "rgba(225, 0, 0, " + -(score / 2) + ")";
                        borderColor = "rgba(225, 0, 0, " + -(score + 0.2) + ")";
                    }
                    console.log(color);
                    body.style.backgroundColor = color;
                    console.log(color);
                    //bContainer.style.backgroundColor = "#FFFFFF";
                    //submit.style.borderColor = invisibleColor;
                    keywords.style.borderColor = "rbga(100,100,100,.1)";
                    if(document.querySelector("#submit:hover")) {
                        submit.style.borderColor = borderColor;
                    }
                    else if(document.activeElement == keywords) {
                        keywords.style.borderColor = borderColor;
                    }
                    keywords.onfocus = function() {
                        keywords.style.borderColor = borderColor;
                    }
                    keywords.onblur = function() {
                        keywords.style.borderColor = invisibleColor;
                    }
                    submit.onmouseover = function() {
                        submit.style.borderColor = borderColor;
                    }
                    submit.onmouseout = function() {
                        submit.style.borderColor = invisibleColor;
                    }
                    if(score >= -1 && score <= 1) {
                        score *= 100;
                        score /= 20;
                        score = Math.floor(score);
                        score += 5;
                        desc.innerHTML = values[score];
                        desc.classList.add("active");
                    }
                    if(!isRateLimited) {
                        document.getElementById('chartContainer').style.visibility = "visible";
                        drawChart(scores,color);
                    }
                    else {
                        document.getElementById('chartContainer').style.visibility = "hidden";
                    }
                } else {
                    desc.innerHTML = "Hmm, something went wrong..";
                    spinner.stop();
                }
    		}
        }
        req.send();
	} else {
	    desc.innerHTML = "Please enter a keyword or phrase";
	}

}
keywords.onkeydown = function(e) {
    if(e.keyCode == 13) {
        submit.click();
    }
}<|endoftext|>


<commit_before>$(document).ready(function(){
  if($("dns")){
    for(var key in dns){
      $("dns").append("
" + dns[key][0] + ", " + dns[key][1] + " - " + dns[key][2] + "
");
    }
  }
});
<commit_msg>Update index.js<commit_after>$(document).ready(function(){
  if($("dns")){
    $(".twitter-timeline").height(350)
    for(var key in dns){
      $("dns").append("
" + dns[key][0] + ", " + dns[key][1] + " - " + dns[key][2] + "
");
    }
  }
});
<|endoftext|>


<commit_before>// Code will go here, someday!  Someday I will grow up to be an adult softwares!

require('./fidget-spinner')
<commit_msg>add a debug sperk so sperks play at start<commit_after>// Code will go here, someday!  Someday I will grow up to be an adult softwares!

//debug while I figure out particles
require('./particles')

require('./fidget-spinner')
<|endoftext|>


<commit_before>// setup

var $ = require('jquery-browserify');
var Backbone = require('backbone');
var play = window.play = require('play-audio');
var path = require('path');
Backbone.$ = $; // for browserify
var hbs = require('handlebars-runtime');
hbs.registerHelper('pluralize', function(num, single, plural) {
  if (parseInt(num,10) === 1) { return single; }
  else { return plural; }
});
// underscore and string methods
var _ = require('underscore');
_.str = require('underscore.string');

// app stuff
var Releases = require('./collections/releases-collection');
var ReleaseView = require('./views/release-view');
var ReleaseListView = require('./views/release-list-view');
var Router = require('./router');

// templates
var relpage_tpl = require('./templates/details.hbs');
var about_tpl = require('./templates/about.hbs');

// could be an API, but flat object for now
var data = require('../data/all.json');

// releases collection
var releases = new Releases(data);

// view where it will all live
var list = new ReleaseListView({
	collection: releases
});

var router = new Router();

router.on('release', function(cat) {
	this.currentPage = 'release';
	var release = releases.filter(function(rel){
		return rel.get('cat') === cat;
	});

	if (!release) {
		Backbone.history.navigate('/');
	} else {
		list.remove();
		var relData = release[0].toJSON();

		relData.formattedDate = release[0].get('momented').format('MMMM Do, YYYY');
		relData.numTracks = relData.tracks ? relData.tracks.length : false;

		var html = relpage_tpl(relData);
		document.title = '' + relData.album + ' - ' + relData.artist + '  | '+relData.cat.toUpperCase();
		$("#main").html(html)
				  .find('.play').on('click', function(){
						player.queue(relData.tracks);
					});
	}
});

router.on('about',function(){
	this.currentPage = 'about';
	list.remove();
	var content = about_tpl();
	$("#main").empty().html(content);
});

router.on('error',function(){
	Backbone.history.navigate('/');
});

router.on('home', function() {
	this.currentPage = 'home';
	document.title = 'Enough Records';
  	list.render();
  	document.title
	$("#main").empty().append(list.el);

});

var app = {
	rootURL: '/'
};

// search box stuff
var lastSearch = false;
var searchHandler = function(){
	if (router.currentPage !== 'home') {
		Backbone.history.navigate('/',{trigger:true});
	};
	if(this.value === lastSearch){
		return;
	} else {
		lastSearch = this.value;
	}

	if (this.value.length === 0) {
		releases.resetVisibility();
		return;
	} else {
		releases.search(this.value);
	}

}

$("#top-bar input").on('keyup', _.debounce(searchHandler,333));

// player

var controls = document.getElementById('bottom-bar');
var Player = function(elem){
	this.elem = elem;
	this.playing = false;
	this.widget = play([],elem).autoplay();
	this.playButton = $("#play-state");
	this.widget.volume(0.5);
	this.widget.on('play', this.togglePlayState.bind(this,true));
	this.widget.on('ended',this.advance.bind(this));

	$(".controls span").on('click',this.doControl.bind(this));
}

Player.prototype.doControl = function(evt) {
	if (!this.playlist) {return};
	var ctrl = evt.target.getAttribute('ctrl');

	switch (ctrl){
		case 'stop':
			this.widget.pause().currentTime(0);
			this.togglePlayState(false);
			break;
		case 'play':
			if (this.playing) this.widget.pause() && this.togglePlayState(false);
			else this.widget.play();
			break;
		case 'forward':
			this.advance(true);
			break;
		case 'back':
			this.advance(false);
			break;
	}

};

Player.prototype.togglePlayState = function(playing) {
	this.playButton.removeClass();

	if (playing) {
		this.playButton.addClass('fa fontawesome-pause');
		var name = path.basename(this.widget.src());
		$(".now-playing").removeClass('nothing').html(name);
		this.playing = true;
	} else {
		this.playButton.addClass('fa fontawesome-play');
		this.playing = false;
		$(".now-playing").html('nothing playing').addClass('nothing');
	}
};

Player.prototype.advance = function(fwd) {
	var mod = fwd ? 1 : -1;
	this.position = this.position + mod;
	if(this.position > this.playlist.length-1) this.position = 0;
	else if(this.position < 0) this.position = this.playlist.length-1;
	this.play();

};

Player.prototype.play = function() {
	var pos = this.position;
	this.widget.src(this.playlist[pos]);
};

Player.prototype.queue = function(files){
	if (files && files.length) {
		this.playlist = files;
		this.position = 0;
		this.play();
	} else {
		alert('This release has no playable files, sorry.');
	}
}

var player = window.player = new Player(controls);

// start routing
Backbone.history.start({ pushState: true, root: app.rootURL });

$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
	// Get the absolute anchor href.
	var href = {
		prop: $(this).prop("href"),
		attr: $(this).attr("href")
	};
	// Get the absolute root.
	var root = location.protocol + "//" + location.host + app.rootURL;

	// Ensure the root is part of the anchor href, meaning it's relative.
	if (href.prop.slice(0, root.length) === root) {
		evt.preventDefault();
		// `Backbone.history.navigate` is sufficient for all Routers and will
		// trigger the correct events. The Router's internal `navigate` method
		// calls this anyways.  The fragment is sliced from the root.
		Backbone.history.navigate(href.attr, true);
	}
});
<commit_msg>Oops about us page title<commit_after>// setup

var $ = require('jquery-browserify');
var Backbone = require('backbone');
var play = window.play = require('play-audio');
var path = require('path');
Backbone.$ = $; // for browserify
var hbs = require('handlebars-runtime');
hbs.registerHelper('pluralize', function(num, single, plural) {
  if (parseInt(num,10) === 1) { return single; }
  else { return plural; }
});
// underscore and string methods
var _ = require('underscore');
_.str = require('underscore.string');

// app stuff
var Releases = require('./collections/releases-collection');
var ReleaseView = require('./views/release-view');
var ReleaseListView = require('./views/release-list-view');
var Router = require('./router');

// templates
var relpage_tpl = require('./templates/details.hbs');
var about_tpl = require('./templates/about.hbs');

// could be an API, but flat object for now
var data = require('../data/all.json');

// releases collection
var releases = new Releases(data);

// view where it will all live
var list = new ReleaseListView({
	collection: releases
});

var router = new Router();

router.on('release', function(cat) {
	this.currentPage = 'release';
	var release = releases.filter(function(rel){
		return rel.get('cat') === cat;
	});

	if (!release) {
		Backbone.history.navigate('/');
	} else {
		list.remove();
		var relData = release[0].toJSON();

		relData.formattedDate = release[0].get('momented').format('MMMM Do, YYYY');
		relData.numTracks = relData.tracks ? relData.tracks.length : false;

		var html = relpage_tpl(relData);
		document.title = '' + relData.album + ' - ' + relData.artist + '  | '+relData.cat.toUpperCase();
		$("#main").html(html)
				  .find('.play').on('click', function(){
						player.queue(relData.tracks);
					});
	}
});

router.on('about',function(){
	this.currentPage = 'about';
	document.title = 'About Us';
	list.remove();
	var content = about_tpl();
	$("#main").empty().html(content);
});

router.on('error',function(){
	Backbone.history.navigate('/');
});

router.on('home', function() {
	this.currentPage = 'home';
	document.title = 'Enough Records';
  	list.render();
  	document.title
	$("#main").empty().append(list.el);

});

var app = {
	rootURL: '/'
};

// search box stuff
var lastSearch = false;
var searchHandler = function(){
	if (router.currentPage !== 'home') {
		Backbone.history.navigate('/',{trigger:true});
	};
	if(this.value === lastSearch){
		return;
	} else {
		lastSearch = this.value;
	}

	if (this.value.length === 0) {
		releases.resetVisibility();
		return;
	} else {
		releases.search(this.value);
	}

}

$("#top-bar input").on('keyup', _.debounce(searchHandler,333));

// player

var controls = document.getElementById('bottom-bar');
var Player = function(elem){
	this.elem = elem;
	this.playing = false;
	this.widget = play([],elem).autoplay();
	this.playButton = $("#play-state");
	this.widget.volume(0.5);
	this.widget.on('play', this.togglePlayState.bind(this,true));
	this.widget.on('ended',this.advance.bind(this));

	$(".controls span").on('click',this.doControl.bind(this));
}

Player.prototype.doControl = function(evt) {
	if (!this.playlist) {return};
	var ctrl = evt.target.getAttribute('ctrl');

	switch (ctrl){
		case 'stop':
			this.widget.pause().currentTime(0);
			this.togglePlayState(false);
			break;
		case 'play':
			if (this.playing) this.widget.pause() && this.togglePlayState(false);
			else this.widget.play();
			break;
		case 'forward':
			this.advance(true);
			break;
		case 'back':
			this.advance(false);
			break;
	}

};

Player.prototype.togglePlayState = function(playing) {
	this.playButton.removeClass();

	if (playing) {
		this.playButton.addClass('fa fontawesome-pause');
		var name = path.basename(this.widget.src());
		$(".now-playing").removeClass('nothing').html(name);
		this.playing = true;
	} else {
		this.playButton.addClass('fa fontawesome-play');
		this.playing = false;
		$(".now-playing").html('nothing playing').addClass('nothing');
	}
};

Player.prototype.advance = function(fwd) {
	var mod = fwd ? 1 : -1;
	this.position = this.position + mod;
	if(this.position > this.playlist.length-1) this.position = 0;
	else if(this.position < 0) this.position = this.playlist.length-1;
	this.play();

};

Player.prototype.play = function() {
	var pos = this.position;
	this.widget.src(this.playlist[pos]);
};

Player.prototype.queue = function(files){
	if (files && files.length) {
		this.playlist = files;
		this.position = 0;
		this.play();
	} else {
		alert('This release has no playable files, sorry.');
	}
}

var player = window.player = new Player(controls);

// start routing
Backbone.history.start({ pushState: true, root: app.rootURL });

$(document).on("click", "a[href]:not([data-bypass])", function(evt) {
	// Get the absolute anchor href.
	var href = {
		prop: $(this).prop("href"),
		attr: $(this).attr("href")
	};
	// Get the absolute root.
	var root = location.protocol + "//" + location.host + app.rootURL;

	// Ensure the root is part of the anchor href, meaning it's relative.
	if (href.prop.slice(0, root.length) === root) {
		evt.preventDefault();
		// `Backbone.history.navigate` is sufficient for all Routers and will
		// trigger the correct events. The Router's internal `navigate` method
		// calls this anyways.  The fragment is sliced from the root.
		Backbone.history.navigate(href.attr, true);
	}
});
<|endoftext|>


<commit_before>(function($) {
    if (typeof acf === 'undefined' || typeof acf.conditional_logic === 'undefined') {
        return;
    }

    var _super = $.extend({}, acf.conditional_logic);

    acf.conditional_logic = $.extend(acf.conditional_logic, {
        calculate: function(rule, $trigger, $target) {
            var type = $trigger.data('type');

            // Return true if we are dealing with recaptcha field and it has been checked.
            if (type === 'recaptcha') {
                return $trigger.find('input[type=hidden]').val().length > 0;
            }

            // Otherwise, fallback to native ACF calculate().
            return _super.calculate(rule, $trigger, $target);
        }
    });
})(jQuery);

(function($) {

    var _root = this;
    var $el = null;
    var fieldname = "";

    if (typeof acf.add_action !== 'undefined') {

        acf.add_action('ready append', function($body) {
            _root.$el = acf.get_field({ type: 'recaptcha' }, $body);

            if (_root.$el) {
                _root.fieldname = _root.$el.attr("data-key");
            }
        });

        acf.add_filter('validation_complete', function(json, $form) {

            if (typeof(grecaptcha) === "undefined") {
                return json;
            }

            if (!_root.$el) {
                return json;
            }

            var validated_error = false;

            if (json.errors) {
                $.each(json.errors, function(index, val) {
                    if (val.input === "acf[" + _root.fieldname + "]") {
                        validated_error = true;
                        grecaptcha.reset();
                        json.errors[index].message = acf.l10n.recaptcha.error;
                    }
                });
            }

            if (!validated_error) {
                _root.$el.find("input[type=hidden]").remove();
            }

            return json;

        });

    }

})(jQuery);

function acf_captcha_called(input) {
    jQuery("[data-type=recaptcha]").find("input[type=hidden]").val(input).change();
}
<commit_msg>Allow checked and unchecked conditional logic<commit_after>(function($) {
    if (typeof acf === 'undefined' || typeof acf.conditional_logic === 'undefined') {
        return;
    }

    var _super = $.extend({}, acf.conditional_logic);

    acf.conditional_logic = $.extend(acf.conditional_logic, {
        calculate: function(rule, $trigger, $target) {
            var type = $trigger.data('type');

            // Return true if we are dealing with recaptcha field and it has been checked.
            if (type === 'recaptcha') {
                var is_operator_equals = rule.operator === "==";
                var is_value_1 = parseInt(rule.value) === 1;
                var show_when_checked = is_operator_equals === is_value_1; // Treat as XNOR
                var is_field_checked = $trigger.find('input[type=hidden]').val().length > 0;

                return show_when_checked === is_field_checked; // Treat as XNOR
            }

            // Otherwise, fallback to native ACF calculate().
            return _super.calculate(rule, $trigger, $target);
        }
    });
})(jQuery);

(function($) {

    var _root = this;
    var $el = null;
    var fieldname = "";

    if (typeof acf.add_action !== 'undefined') {

        acf.add_action('ready append', function($body) {
            _root.$el = acf.get_field({ type: 'recaptcha' }, $body);

            if (_root.$el) {
                _root.fieldname = _root.$el.attr("data-key");
            }
        });

        acf.add_filter('validation_complete', function(json, $form) {

            if (typeof(grecaptcha) === "undefined") {
                return json;
            }

            if (!_root.$el) {
                return json;
            }

            var validated_error = false;

            if (json.errors) {
                $.each(json.errors, function(index, val) {
                    if (val.input === "acf[" + _root.fieldname + "]") {
                        validated_error = true;
                        grecaptcha.reset();
                        json.errors[index].message = acf.l10n.recaptcha.error;
                    }
                });
            }

            if (!validated_error) {
                _root.$el.find("input[type=hidden]").remove();
            }

            return json;

        });

    }

})(jQuery);

function acf_captcha_called(input) {
    jQuery("[data-type=recaptcha]").find("input[type=hidden]").val(input).change();
}
<|endoftext|>


<commit_before>/* global jisho */
/* global $ */

var currentLanguage = "en";
var currentLocation = window.location.href;

$("document").ready(function() {
    var placeholderID = Math.floor(Math.random() * jisho.length);
    var phD = jisho[placeholderID];
    var placeholderName = phD.english
    if (phD.english !== phD.roumaji) {
        placeholderName += ", " + phD.roumaji
    }
    placeholderName += ", " + phD.japanese;
    if (phD.katakana !== phD.japanese) {
        placeholderName += ", " + phD.katakana
    }
    placeholderName += "...";
    $("#term").attr("placeholder", placeholderName);

    if (currentLocation.indexOf("/ja/") !== -1) {
        currentLanguage = "ja";
    }

    if (currentLanguage = "ja") {
        setCookie("lang", "ja", 365);
    } else {
        setCookie("lang", "en", 365)
    }

    $(".help-button").click(function(){
        $("#content").fadeIn(500);
        $(".help-button").fadeOut(500);
    });

    $("#term").keyup(function() {
        $("#content").fadeOut(500);
        $(".help-button").fadeIn(500);
        $("#priority").html("");
        $("#results").html("");
        if (this.value.length > 2) {
            $("#content").hide();
            $(".help-button").show();
            searchFor(this.value, true);
        }
    });

});

function searchFor(term, convertKana) {
    term = term.replace("é", "e");
    var katakanaTerm = toKatakana(term);
    if (convertKana) {
        for (i = 0; i < jisho.length; i++) {
            if (jisho[i].english.toLowerCase().includes(term.toLowerCase()) ||
                jisho[i].katakana.includes(katakanaTerm) ||
                jisho[i].roumaji.toLowerCase().includes(term.toLowerCase())) {
                var result = jisho[i];
                if (result.english.toLowerCase() === term.toLowerCase() ||
                    result.katakana === katakanaTerm ||
                    result.roumaji.toLowerCase() === term.toLowerCase()) {
                    result.priority = 1;
                }
                activeData.push(result);
            }
        }
    } else {

        for (i = 0; i < jisho.length; i++) {
            if (jisho[i].english.toLowerCase().includes(term.toLowerCase()) ||
                jisho[i].japanese.includes(term) ||
                jisho[i].roumaji.toLowerCase().includes(term.toLowerCase())) {
                var result = jisho[i];
                if (result.english.toLowerCase() === term.toLowerCase() ||
                    result.japanese === term ||
                    result.roumaji.toLowerCase() === term.toLowerCase()) {
                    result.priority = 1;
                }
                activeData.push(result);
            }
        }

    }
    renderResult(activeData);
    activeData = [];
}

function renderResult(array) {
    if (array.length === 0 &&
        $("#alert").text() === "") {
        $("#alert").hide();
        if (currentLanguage === "en") {
            $("#alert").html("Can't find what you're looking for? Tell us what's missing!");
        } else {
            $("#alert").html("見つけませんでしたか？　見つけられなかったものを教えてください！");
        }
        $("#alert").fadeIn(500);
    }
    if (array.length > 0) {
        $("#alert").html("");
    }
    for (i = 0; i < array.length; i++) {
        var result = array[i];
        result.us = result.english.replace(/ /g, "_"); // Underscored Result Name for URL
        result.urlJA = "http://wiki.xn--rckteqa2e.com/wiki/" + result.japanese;
        if (result.type === "move") {
            result.url = "http://bulbapedia.bulbagarden.net/wiki/" + result.us + "_(move)";
        } else if (result.type === "Pokémon") {
            result.url = "http://bulbapedia.bulbagarden.net/wiki/" + result.us + "_(Pok%C3%A9mon)";
        } else if (result.type === "item") {
            result.url = "http://bulbapedia.bulbagarden.net/wiki/" + result.us;
        } else if (result.type === "Ability") {
            result.url = "http://bulbapedia.bulbagarden.net/wiki/" + result.us + "_(Ability)";
        } else {
            result.url = result.type;
        }
        $resultRow = $('

')
        $resultRow.html('
' + result.english + '

' + result.japanese + '
')
        if (result.priority === 1) {
            $("#priority").append($resultRow);
        } else {
            $("#results").append($resultRow);
        }
    }
}

var activeData = [];<commit_msg>added debug line<commit_after>/* global jisho */
/* global $ */

var currentLanguage = "en";
var currentLocation = window.location.href;

$("document").ready(function() {
    var placeholderID = Math.floor(Math.random() * jisho.length);
    var phD = jisho[placeholderID];
    var placeholderName = phD.english
    if (phD.english !== phD.roumaji) {
        placeholderName += ", " + phD.roumaji
    }
    placeholderName += ", " + phD.japanese;
    if (phD.katakana !== phD.japanese) {
        placeholderName += ", " + phD.katakana
    }
    placeholderName += "...";
    $("#term").attr("placeholder", placeholderName);

    if (currentLocation.indexOf("/ja/") !== -1) {
        currentLanguage = "ja";
    }

    if (currentLanguage = "ja") {
        setCookie("lang", "ja", 365);
    } else {
        setCookie("lang", "en", 365)
    }

    var $debug = $('Temp debug info: Language is set to "' + getCookie("lang") + '"');
    $("#content").append($debug);

    $(".help-button").click(function(){
        $("#content").fadeIn(500);
        $(".help-button").fadeOut(500);
    });

    $("#term").keyup(function() {
        $("#content").fadeOut(500);
        $(".help-button").fadeIn(500);
        $("#priority").html("");
        $("#results").html("");
        if (this.value.length > 2) {
            $("#content").hide();
            $(".help-button").show();
            searchFor(this.value, true);
        }
    });

});

function searchFor(term, convertKana) {
    term = term.replace("é", "e");
    var katakanaTerm = toKatakana(term);
    if (convertKana) {
        for (i = 0; i < jisho.length; i++) {
            if (jisho[i].english.toLowerCase().includes(term.toLowerCase()) ||
                jisho[i].katakana.includes(katakanaTerm) ||
                jisho[i].roumaji.toLowerCase().includes(term.toLowerCase())) {
                var result = jisho[i];
                if (result.english.toLowerCase() === term.toLowerCase() ||
                    result.katakana === katakanaTerm ||
                    result.roumaji.toLowerCase() === term.toLowerCase()) {
                    result.priority = 1;
                }
                activeData.push(result);
            }
        }
    } else {

        for (i = 0; i < jisho.length; i++) {
            if (jisho[i].english.toLowerCase().includes(term.toLowerCase()) ||
                jisho[i].japanese.includes(term) ||
                jisho[i].roumaji.toLowerCase().includes(term.toLowerCase())) {
                var result = jisho[i];
                if (result.english.toLowerCase() === term.toLowerCase() ||
                    result.japanese === term ||
                    result.roumaji.toLowerCase() === term.toLowerCase()) {
                    result.priority = 1;
                }
                activeData.push(result);
            }
        }

    }
    renderResult(activeData);
    activeData = [];
}

function renderResult(array) {
    if (array.length === 0 &&
        $("#alert").text() === "") {
        $("#alert").hide();
        if (currentLanguage === "en") {
            $("#alert").html("Can't find what you're looking for? Tell us what's missing!");
        } else {
            $("#alert").html("見つけませんでしたか？　見つけられなかったものを教えてください！");
        }
        $("#alert").fadeIn(500);
    }
    if (array.length > 0) {
        $("#alert").html("");
    }
    for (i = 0; i < array.length; i++) {
        var result = array[i];
        result.us = result.english.replace(/ /g, "_"); // Underscored Result Name for URL
        result.urlJA = "http://wiki.xn--rckteqa2e.com/wiki/" + result.japanese;
        if (result.type === "move") {
            result.url = "http://bulbapedia.bulbagarden.net/wiki/" + result.us + "_(move)";
        } else if (result.type === "Pokémon") {
            result.url = "http://bulbapedia.bulbagarden.net/wiki/" + result.us + "_(Pok%C3%A9mon)";
        } else if (result.type === "item") {
            result.url = "http://bulbapedia.bulbagarden.net/wiki/" + result.us;
        } else if (result.type === "Ability") {
            result.url = "http://bulbapedia.bulbagarden.net/wiki/" + result.us + "_(Ability)";
        } else {
            result.url = result.type;
        }
        $resultRow = $('

')
        $resultRow.html('
' + result.english + '

' + result.japanese + '
')
        if (result.priority === 1) {
            $("#priority").append($resultRow);
        } else {
            $("#results").append($resultRow);
        }
    }
}

var activeData = [];<|endoftext|>