08/12/2010 Development / java script
    function Protect() {
        this.arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
        this.arrsenha = [];
        this.vSenhaOk = true;
    };

    Protect.prototype.makeRandom = function() {
        for (var j, x, i = this.arr.length; i; j = parseInt(Math.random() * i), x = this.arr[--i], this.arr[i] = this.arr[j], this.arr[j] = x);
        return this.arr;
    };

    Protect.prototype.makeButtons = function() {

        this.makeRandom();

        for (var b = 0; b < 10; b += 2) {
            var btn = document.createElement("button");
            btn.setAttribute("value", this.arr[b] + " ou " + this.arr[b + 1]);
            var p = this.arrsenha;
            btn.onclick = function() { p.push(this.value.toString().replace(" ou ", "")) }
            document.getElementById('teclado').appendChild(btn);
        }

        this.makePass();
    };

    Protect.prototype.makePass = function() {
        document.getElementById('senha').value = (this.makeRandom()).toString().substring(0, 7).replace(",", "").replace(",", "").replace(",", "");
    };

    Protect.prototype.checkPass = function() {
        var vUserPassword = document.getElementById('senha').value;
        if (this.arrsenha.length > 0) {
            for (var i = 0; i < this.arrsenha.length; i++) {
                if (vUserPassword.substr(i, 1) != this.arrsenha[i].substr(0, 1) && vUserPassword.substr(i, 1) != this.arrsenha[i].substr(1, 1)) {
                    this.vSenhaOk = false;
                    break;
                }
            }
            alert('Sua senha está: ' + this.vSenhaOk);
        }
    };

    var pass = new Protect();
    pass.makeButtons();