JSFiddle - React, Tailwind, and code Playground

by SimoneGianni

HTML

<html>
    <body>
        
    </body>
</html>

JavaScript

function DJBHash(str) {
    var hash = 51795381;
    
    //for(var i = 0; i < str.length; i++) {
        // Original DJB hash
        //hash = ((hash << 5) + hash) + str.charCodeAt(i);
        // Modified by me to create more movement in MSBs
        //hash = ((hash >> 5) + hash) + (str.charCodeAt(i) << 28);
        // SDBM hash
        //hash = str.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
        //Another hashing, derived from AP hash 
        /*
        var ch = str.charCodeAt(i);
        if ((ch & 1) == 0) {
            hash += ((hash <<  7) + ch * (hash >> 3));
        } else {
            hash += (~((hash << 11) + ch + (hash >> 5)));
        }
        */
        // Test of fully arithmetic hash
        //var ch = str.charCodeAt(i);
        //if ((ch & 1) == 0) {
            hash += ((hash * Math.pow(2.0,7.0)) + str.length * (hash / Math.pow(2.0,3.0)));
        //} else {
            var th = ((hash * Math.pow(2.0,11.0)) + (str.length*2) + (hash / Math.pow(2.0,5.0)));
            //th = -th - 1;
            var zh = ~th;
            th = -Math.floor(th%4294967296)-1;
            hash += th;
        //}
        hash = Math.floor(hash%4294967296);

    //}
    
    return hash;
}

$(function() {
    $('body').append('<div id="stop">STOP</div>');
    var stop = false;
    $('#stop').click(function() { stop = true; });
    
    $('body').append('<div id="str"/>');
    
    var bitcnt = [];
    for (var i = 0; i < 32; i++) {
        $('body').append('<div id="f' + i + '"/>');
        bitcnt[i] = 0;
    }

    var strbuff = 'a';
    var cnt = 0;
    
    function gonext() {
        var lc = strbuff.charAt(strbuff.length - 1);
        if (lc == 9) {
            strbuff += 'a';
        } else if (lc == 'z') {
            strbuff = strbuff.substr(0,strbuff.length -1);
            strbuff += 'A';
        } else if (lc == 'Z') {
            strbuff = strbuff.substr(0,strbuff.length -1);
            strbuff += '0';
        } else {
            strbuff =...