JSFiddle

  • Jquery .addClass #3 is the latest revision

    help.

    $(document).ready(function() {
      $('.test').on('mouseenter', function() {
      	$(this).addClass("red");
      });
      
       $('.test').on('mouseleave', function() {
        $(this).removeClass('red');
      });
    });
    
    //Basically, I don ...
  • Number to String Converter

    Simply converts integers (up to 45-digits long) into their proper, written format. Accepts negative numbers and commas in the input.

    var $input, $output, $convertBtn;
    var writtenNum;
    
    function main() {
    	$input = $("#input");
    	$output = $("#output");
      $convertBtn = $("#convert-btn");
      writtenNum = {};
      
      // $input.bind("input", updateOutput);
      
      $convertBtn ...
  • 12 Days of Christmas

    jQuery (edge), HTML, CSS, JavaScript

    function main() {
    	enableConsole(600, 400);
      
      for (var day = 1; day <= 12; day++) {
      	var ord = getOrd(day);
        console.log("On the " + day + ord + " day of Christmas, my true love gave to me:");
        printDays(day);
        console.log();
      }
    }
    
    function printDays(day) {
    	switch(day) {
      	case 12: console.log("12 Drummers Drumming");
        case 11: console.log("11 Pipers Piping");
        case 10: console.log("10 Lords a' Leaping");
        case  9: console.log(" 9 Ladies Dancing");
        case  8: console.log(" 8 Maids a' Milking");
        case  7: console.log(" 7 Swans a' Swimming");
        case  6: console.log(" 6 Geese a' Laying");
        case  5: console.log(" FIIIIVE. GOLDEN RIIIIIIIINGS.\n ..........");
        case  4: console.log(" 4 Calling Birds");
        case  3: console.log(" 3 French Hens");
        case  2: console.log(" 2 Turtle Doves");
        case  1: console.log((day !== 1 ? " and" : "") + " a Partridge in a Pear Tree!");
        break;
        default: console.log("What. Have. You. Done...");
      }
    }
    
    function getOrd(num) {
    	if (num % 100 >= 11 && num % 100 <= 13) return "th";
      switch(num % 10) {
      	case 1: return "st";
        case 2 ...</=>
  • Rock Paper Scissors Lizard Spock

    Simple, class-based implementation of the classic Rock Paper Scissors Lizard Spock. Demonstrates JavaScript class inheritance. Has grammatically-correct outcome text. Shows win percentage. May add smarter AI in the future.

    // Rock Paper Scissors Lizard Spock
    // images from http://picoplex.net/
    
    var weapons = {};
    var p1Wins = 0;
    var compWins = 0;
    var numRounds ...
  • CappedAnimationFrames class and draw example

    A simple requestAnimationFrame() example that runs at a given maximum frame rate. This sample also demonstrates using an "update" function in your code that will update the visual elements based on the amount of time passed since the last update.

    /***
      CappedAnimationFrames(func[, fps = 0])
      desc: This class wraps up the boilerplate code for using the window.requestAnimationFrame() function
            with an ...
  • Roman Numeral Parser

    jQuery (edge), HTML, CSS, JavaScript

    /*
    	This Roman Numeral Parser is based on the following BNF:
      I'd like to continue to refine this as I ...
  • Sudoku Solving Algorithm (in progress)

    Knuth's DLX algorithm implemented in JavaScript

    function Solver()
    {
    	this.root = null;
      
      var solution = [];
      var solutions = [];
      
      var _self = this;
      var puzzleSize = 9;
      
      function Node(isHeader, headerType)
      {
        this ...
  • JS Tetris (New)

    Tetris powered by JS drawn on the HTML5 canvas element. Makes use of requestAnimationFrame in a throttled rendering loop.

    /////////// MAIN ///////////
    
    
    
    function main() 
    {
      enableConsole();
      var game = new Tet();
      game.start();
    }
    
    
    
    /////////// CLASSES ///////////
    
    
    
    /********** Vec2d Class **********/
    function Vec2d(newX, newY)
    {
      this.x = typeof ...
  • Sudoku with JQuery #30 is the latest revision

    jQuery (edge), HTML, CSS, JavaScript

    var easyPuzzleStr = "..6..73..\n.18..9.5.\n5......64\n92..8....\n...763...\n....9..75\n63......8\n ...
  • Conway's Game of Life #11 is the latest revision

    Ooh, pretty.

    var $board;
    var ctx;
    var data = [];
    var running = false;
    
    //var CANVAS_SIZE = {x: 600, y: 400};
    CANVAS_SIZE = {x: window.innerWidth, y ...