summaryrefslogtreecommitdiff
path: root/webcards/scripts/gui/table.js
blob: 2776f8027903db1b802ecf6cb922a7f3a71be924 (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
// Table represents and manages the actual game.  It accepts inputs from the server and tries to query 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();
    }
}