JSFiddle

  • Style Sheet Insights

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

    var styleSheets = document.head.querySelectorAll('link[rel*="stylesheet"]');
    
    logStyleSheetDetails(styleSheets);
    
    populateStyleSheetsTable(styleSheets);
    
    function logStyleSheetDetails(styleSheets) {
    
        console.log("document.styleSheets: %o ...
  • For Stack Overflow Question #23757338

    This is for my answer to question #23757338 on Stack Overflow. http://stackoverflow.com/questions/23757338/add-gradient-to-canvas

    var canvas = document.getElementById('test-canvas');
    var ctx = (canvas !== null ? canvas.getContext('2d') : null);
    var grd = (ctx !== null ? ctx.createLinearGradient(0 ...
  • For Stack Overflow Question #2507127

    This is for my answer to question #2507127 on Stack Overflow. http://stackoverflow.com/questions/25071272/what-is-the-best-way-to-extract-the-numbers-out-of-this-text

    var justNumbers = "P1W2DT6H21M32S".replace(/^\D|\D$/g, "").split(/\D+/);
    
    var keys = ["weeks", "days", "hours", "minutes", "seconds"];
    
    var time = {};
    
    for (var ...
  • Circle, Arc, and Ring Experiments

    I want to figure out how to draw ring (a.k.a. donut/doughnut) or pie segments.

    /*
        Reference
    
        https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Canvas_tutorial/Drawing_shapes#Arcs
    
        arc(x, y, radius, startAngle, endAngle, anticlockwise ...
  • IP Address Validation #13 is the latest revision

    I want to try some different ways of validating IP addresses to find how they work comparatively.

    /*  Let's validate IP address formats!
    
        I was thinking about avoiding regular expressions or using only a simple regular expression ...