jsprint fiddle

by brigand

HTML

<script src="http://brigand.github.io/jsprint/build/output/jsprint.min.js"></script>

JavaScript

function login(callback) {
    if (login.loggedIn) {
        if (typeof callback === "function") {
            callback();
        }
    } else {
        // display modal
        // handle form submission
        // log in user

        // pretend this is called when all of that is done
        // and the user is logged in
        setTimeout(function (userName) {
            login.loggedIn = true;
            if (typeof callback === "function") {
                callback();
            }
        }, 1000);
    }
}

login(function(){
    jsprint("we're logged in now after waiting a while, and can press the button");
});