var generator = null;

function clear() {
    $('#output').empty();
}

function fill() {
    var $output = $('#output'),
        $w = $(window),
        $b = $('body');
    while (generator && $w.scrollTop() + $w.height() > $b.height()) {
        $output.append($('<li>' + generator + '</li>'));
    }
}

function group(n) {
    var string = n.toString();
    if (/^\d+$/.test(string)) {
        return string.split('').reverse().join('')
            .split(/(\d\d\d)/).filter(function(s) {
                return s !== '';
            }).map(function(s) {
                return s.split('').reverse().join('');
            }).reverse().join(',');
    } else {
        return string;
    }
}

function update(event) {
    if (event) event.preventDefault();
    clear();
    try {
        generator = NameGen.compile($('#spec').val());
        $('#spec').removeClass('invalid');
        if (generator.max() === 0) {
            generator = null;
            $('#count').text('');
        } else {
            var count = group(generator.combinations());
            if (count === 1) {
                $('#count').text(count + ' possibility');
            } else {
                $('#count').text(count + ' possibilities');
            }
        }
        fill();
    } catch (e) {
        $('#spec').addClass('invalid');
        $('#count').text('invalid');
    }
}

$(document).ready(function() {
    $('#input').on('submit input change', update);
    $(window).on('scroll', fill);
    $('#help').on('click', function(event) {
        event.preventDefault();
        $('#reference').slideToggle();
    });
});

@@ -785,51 +785,125 @@
     
-generator = NameGen.compile($('#spec').val(
+var spec = $('#spec').val();%0A        generator = NameGen.compile(spec);%0A        location.replace('#' + encodeURI(spec
 ));%0A
@@ -1674,12 +1674,124 @@
     %7D);%0A
+    if (location.hash) %7B%0A        $('#spec').val(decodeURI(location.hash.substring(1)));%0A        update();%0A    %7D%0A
 %7D);%0A

Update the page fragment with the pattern (#14)