summaryrefslogtreecommitdiff
path: root/webcards/scripts/gui/table.js
blob: db67529038ebdd2e6c903b1c03c9d22e48de2d33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// Table represents and manages the actual game.  It accepts inputs from the server and tries to queries the server when the player makes a move.
function Table(el, soc) {
    this.root = el;
    this.soc = soc;
}

Table.prototype = {
    
    openTable: function(){
        let state = this.root.getAttribute("state")
        if((state == "close" || state == "closed") && state != "") {
            this.root.setAttribute("state", "closed");
            setTimeout(this.root.setAttribute.bind(this.root), 50, "state", "open");
        }
    },

    closeTable: function(){
        let state = this.root.getAttribute("state")
        if(state != "close" && state != "closed") {
            this.root.setAttribute("state", "");
            setTimeout(this.root.setAttribute.bind(this.root), 50, "state", "close");
        }
    },

    

    handleClose: function() {
        this.reset();
    },

    reset: function() {
        this.closeTable();
    }
}