JSFiddle

  • Sine thing #1 is the latest revision

    Sine function with variable accuracy, plotted next to the built-in Math.sin()

    function pow(a, b){
    	var total = 1;
        
        while(b){
        	total *= a;
            b--;
        }
        
        return total;
    }
    
    function factorial(n){
        if(n <= 1 ...
  • Javascript String.format() #25 is the latest revision

    A cheap implementation that supports basic escaping and abuses JavaScript's duck typing

    if(!String.format){
        String.format = function(){
            var argv = Array.prototype.slice.call(arguments),
                string = argv[0],
                i = 0;
    
            string = string ...
  • QuerystringTable demo #3 is the latest revision

    A demo of a constructor I wrote for parsing and accessing querystrings

    function main(){
        var imaginaryUrl = "http://example.com/webapp/?search=how%20to%20use%20Google&the_answer=42",
            qs = new QuerystringTable(imaginaryUrl);
    
        urlbox.innerHTML = "url: " + imaginaryUrl;
        
        logButton(
            "qs.getKeys ...
  • Input example #1 is the latest revision

    Example implementation of Input as a class.

    function Input(DOMObject){
        var keyMap = [],
            lastKey = 0;
        
        function updateKeys(event){
            keyMap[event.keyCode] = event.type == "keydown";
            lastKey = event.type == "keydown ...
  • Playing with gravity simulation #15 is the latest revision

    Simple gravity simulation/demo to show how simple the concept is

    var ctx = canvas.getContext('2d');
    canvas.width = 500;
    canvas.height = 500;
    
    function Ball(_x, _y, _w, _h){
        var x = _x ...
  • HTML5 Breakout #7 is the latest revision

    Breakout in HTML5. https://youtu.be/0MNkmIzxENs

    /* constants.js */
    var Constant = {/*{{{*/
        Ball: {
            WIDTH  : 10,
            HEIGHT : 10,
            Velocity: {
                X:           5,
                Y:          -5,
                INCREMENT:   0.5,
                MULTIPLIER: -1.01 ...
  • HTML5 Snake #29 is the latest revision

    Using a module/namespace pattern. https://gitlab.com/bradenbest/html5-snake

    // game.js
    var game_settings = {
        fps:     15,  /* The game's framerate */
        cellw:   10,  /* Width of a cell. Snake pieces, food, and ...
  • Congratulations. You're colorblind.

    Well, more so than a computer.

    <p>Can you distinguish between <span class="red1">red</span> and <span class="red2">slightly redder red?</span></p>
    <p>Didn't think so.</p>
    <p class="ohmygod">Can you read this without highlighting it ...</p>
  • Quick alpha mixing demo

    No-Library (pure JS), HTML, CSS, JavaScript

    var ctx = display.getContext("2d");
    
    function log(s){
        _console.value += s + "\n";
    }
    
    function combine(c1, c2){
        /* Algorithm courtesy of http ...
  • HTML5 On-screen Keyboard #12 is the latest revision

    Improved version of http://jsfiddle.net/B1KMusic/GVqEA/

    /* Functions */
    function char_inserter(chr){
        return function(){
            display_chars.push(chr);
        };
    }
    function char_remove(){
        display_chars.pop();
    }
    function display_clear(){
        display_chars = [];
    }
    function display_render(s){
        var ...