Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript convert from reading an array to reading from a database in javascript

Can someone please help me? the current code is reading through an array and im already storing this in a database. if i can read from the database, at lease i can save it and come back.. right now since its in an array, if i lose my connection or just leave and it times out, it doesnt save my progress. lines 514 and 515 are where its populating the highlighted areas. the first line with the score will be different. i already can pull that from the database, i just dont understand how to replace the arrays with a string return. i was thinking of using something like:
Code:
xmlhttp.open('GET',"save_pool_history.php?action=update&updatehistory=" + this.teams[player1id][0].value + "|||"     + this.teams[player2id][0].value + "|||" + score1 + "|||" + score2 , true);
        xmlhttp.send();

like im already using but dont understand 1, how to replace the actual array part, and 2 how to get the return so it populates that area. here is the entire code:

JavaScript:
/*
 *    Tournament Administration Sheet
 *
 *  Copyright (C) 2008  Jan Gassen
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
var groupCounter = 0;
var finishCounter = 0;
var allFinished = false;
var modeConnector;
var groupList = new Array();
var members = 0;

function Connector(playerCounter, groupCounter) {
    this.table = document.createElement("table");
    this.table.setAttribute("id", "playerInputWindow");
    this.table.setAttribute("width", "450");
    this.table.style.position = "absolute";
    this.table.style.left = document.body.clientWidth / 2 - 125;
    this.table.style.top = "30";

     this.groups = groupCounter;

    var instance = this;

    this.table.style.display = "none";

    var tbody = document.createElement("tbody");
    this.table.appendChild(tbody);

    this.dropDown = document.createElement("select");
    for (var x = 0; x < members; x++) {
        var option = document.createElement("option");
        //option.text = (x + 1) + " Player";
        option.text = (x + 1) + " Team";
        option.value = x + 1;
        this.dropDown.options.add(option);
    }

    this.modes = document.createElement("select");
    var opt1 = document.createElement("option");
       opt1.text = "Single Elimination";
    opt1.value = "ko.html";
    this.modes.options.add(opt1);

    var opt2 = document.createElement("option");
       opt2.text = "Double Elimination";
    opt2.value = "dko.html";
    this.modes.options.add(opt2);

   this.partner = document.createElement("select");
 /*    var opt1 = document.createElement("option");
       opt1.text = "als DYP";
    opt1.value = "1";
    this.partner.options.add(opt1);
*/
    var opt2 = document.createElement("option");
       opt2.text = "als Teams";
    opt2.value = "0";
    this.partner.options.add(opt2);

    var btn = document.createElement("input");
    btn.type = "button";
    btn.value = "Next";
    btn.onclick = function () {
        Connector.prototype.go(instance);
    };

    var btn2 = document.createElement("input");
    btn2.type = "button";
    btn2.value = "Cancel";
    btn2.onclick = function () {
        Connector.prototype.stop(instance);
    };

    this.setInput = document.createElement("input");
    this.setInput.type = "text";
    this.setInput.value = "1";
    this.setInput.size = "2";
    this.setInput.setAttribute("MAXLENGTH", "1");

    this.shuffleInput = document.createElement("input");
    this.shuffleInput.type = "checkbox";


    var row = this.table.insertRow(0);
    var cell = row.insertCell(0);
    cell.setAttribute("colspan", "2");
    cell.setAttribute("valign", "middle");
    cell.innerHTML = "<div id='popupTitle'><table><tr><td>Continue...</td></tr></table></div>";

    row = this.table.insertRow(1);
    cell = row.insertCell(0);
    cell.setAttribute("colspan", "2");
    cell.innerHTML = "Time for bracket play:";

    // Row 2
    row = tbody.insertRow(2);

    cell = row.insertCell(0);
    cell.innerHTML = "Continue with: ";

    cell = row.insertCell(1);
    cell.appendChild(this.modes);

    // Row 3
    row = tbody.insertRow(3);

    cell = row.insertCell(0);
    cell.innerHTML = "How many teams: ";

    cell = row.insertCell(1);
    cell.appendChild(this.dropDown);

    // Row 4
    row = tbody.insertRow(4);

    cell = row.insertCell(0);

    cell = row.insertCell(1);
    cell.appendChild(this.partner);

    // Row 5
    row = tbody.insertRow(5);

    cell = row.insertCell(0);
    cell.innerHTML = "Profit rates: ";

    cell = row.insertCell(1);
    cell.appendChild(this.setInput);

    // Row 6
    row = tbody.insertRow(6);

    cell = row.insertCell(0);
    cell.innerHTML = "Losing round shuffle?";

    cell = row.insertCell(1);
    cell.appendChild(this.shuffleInput);

    // Row 7
    row = tbody.insertRow(7);

    cell = row.insertCell(0);
    cell.appendChild(btn2);

    cell = row.insertCell(1);
    cell.appendChild(btn);
}

Connector.prototype.show = function () {
    this.table.style.display = "block";

    document.getElementById("dimmer").style.display = "block";
    document.getElementById("dimmer").style.width = document.body.clientWidth + "px";
    document.getElementById("dimmer").style.height = (document.body.scrollHeight || document.body.offsetHeight) + "px";
}

Connector.prototype.get = function () {
    return this.table;
}

Connector.prototype.stop = function (instance) {
    instance.table.style.display = "none";
    document.getElementById("dimmer").style.display = "none";
}

Connector.prototype.go = function (instance) {
    pageUrl = instance.modes.options[instance.modes.selectedIndex].value;
    pageTxt = instance.modes.options[instance.modes.selectedIndex].text;

    player = instance.dropDown.options[instance.dropDown.selectedIndex].value;

    top.GLOBALS["teams"] = instance.groups * parseInt(player);
    top.GLOBALS["sets"] = parseInt(instance.setInput.value);
    top.GLOBALS["groups"] = 1;
    top.GLOBALS["modeVal"] = pageUrl;
    top.GLOBALS["modeTxt"] = pageTxt;
    top.GLOBALS["shuffleLooser"] = instance.shuffleInput.checked;

    var list = new Array();

    var len = groupList.length;
    for (var i = 0; i < len; i++) {
        var grp = groupList[i];

        var teams = grp.getTeams();

        for (var j = 0; (j < teams.length && j < parseInt(player)); j++) {
            list.push(teams[j][0]);
        }
    }

    top.GLOBALS["playerList"] = list;
    top.GLOBALS["dyp"] = instance.partner.options[instance.partner.selectedIndex].value;

    top.FILL_FROM_GRP = true;

    window.location = pageUrl;
}

function Score(size) {
    this.rows = new Array();
    this.size = size;
    this.data;

    this.table = document.createElement("table");
    this.table.setAttribute("border", "0");
    this.table.setAttribute("width", "100%");
    this.table.setAttribute("cellspacing", "0");
    this.table.setAttribute("cellpadding", "2");

    var tbody = document.createElement("tbody");
    this.table.appendChild(tbody);

    this.table.style.display = "none";
    this.table.style.cursor = "pointer";

    var row = tbody.insertRow(0);
    this.detailCell = row.insertCell(0);
    this.detailCell.setAttribute("width", "100%");
    this.detailCell.setAttribute("class", "groupDetail");
    this.detailCell.colSpan = "4";
    this.detailCell.innerHTML="&nbsp;";
    this.detailCell.style.display = "none";
    this.detailCell.onclick = function () {
        this.style.display = "none";
    }

    var instance = this;
    var x = 1;

    for (x = 1; x <= size; x++) {
        var row = tbody.insertRow(x);
        row.setAttribute("id", x-1);

        row.onclick = function () {
            Score.prototype.detail(this.id, instance);
        };

        if (x % 2) {
            row.setAttribute("class", "odd");
        } else {
            row.setAttribute("class", "even");
        }

        var cellName = row.insertCell(0);
        var cellPoints = row.insertCell(1);
        cellPoints.setAttribute("align", "right");
        var cellGames = row.insertCell(2);
        cellGames.setAttribute("align", "right");
        var cellDiff = row.insertCell(3);
        cellDiff.setAttribute("align", "right");

        this.rows.push(new Array(cellName, cellPoints, cellGames, cellDiff));
    }
}

Score.prototype.diff = function (id) {
    var val = this.data[id][6] - this.data[id][7];

    if (val > 0) {
        val = "+" + val;
    }

    return val;
}

Score.prototype.detail = function (id, instance) {
    instance.detailCell.style.display = "table-cell";

    instance.detailCell.innerHTML = "<div><b>" + instance.data[id][0] + "</b><br>";
    instance.detailCell.innerHTML += "Points: " + instance.data[id][1] + "<br>";
    instance.detailCell.innerHTML += "Games: " + instance.data[id][2] + "<br>";
    instance.detailCell.innerHTML += "S/U/N: " + instance.data[id][3] + "/" + instance.data[id][4] + "/" + instance.data[id][5] + "<br>";
    instance.detailCell.innerHTML += "Goals: " + instance.data[id][6] + ":" + instance.data[id][7]
                                    + " Diff: " + (instance.diff(id)) + "</div>";

}

Score.prototype.set = function (scores) {
    this.data = scores;


    for (var x = 0; x < this.rows.length; x++) {
        var row = this.rows[x];

        row[0].innerHTML = scores[x][0];
        row[1].innerHTML = scores[x][1];
        row[2].innerHTML = scores[x][2];
        row[3].innerHTML = this.diff(x);
    }
}

Score.prototype.show = function () {
    this.table.style.display = "table";
}

Score.prototype.hide = function () {
    this.table.style.display = "none";
}

Score.prototype.get = function () {
    return this.table;
}


var groupMap = new Array();

function Group(size, id, matches) {
    this.teams = new Array();
    this.games = new Array();
    this.scores = new Array();

    this.size = size;

    this.scoreTable = new Score(size);

    var instance = this;

    this.table = this.create(size, id, instance);
    this.innerTable;
    this.historyCell;

    this.player1name;
    this.player1points;

    this.player2name;
    this.player2points;

    this.id = id;

    this.gameCounter = 0;

    this.isFinish = false;

    this.showHistory = false;
    this.history = "";

    groupMap["Group_"+id] = new Array();
    groupCounter++;

    for (var i = 0; i < matches; i++) {
        this.createGames(size);
    }
}

Group.prototype.showAllGames = function()
{
    var allGames = "";


    for (var x = this.gameCounter; x < this.games.length; x++)
    {
        var id1 = this.games[x][0];
        var id2 = this.games[x][1];

        var name1 = this.teams[id1][0].value;
        var name2 = this.teams[id2][0].value;

        allGames += name1 + " - " + name2 + "<br>";


        var xmlhttp;

                if (window.XMLHttpRequest)
                    xmlhttp = new XMLHttpRequest();
                else
                    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

            /*    xmlhttp.onreadystatechange = function()
                {
                    if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
                    {
                            // Do something with the result, like post a notification
                       // $('#notice').html('<p class="success">'+xmlhttp.responseText+'</p>');
                    }
                }
                */

                xmlhttp.open('GET',"save_pool_history.php?action=insert&history=" + name1 + "|||" + name2 + "&history2=spot2", true);
        xmlhttp.send();

    }

    return allGames;
}



Group.prototype.shuffle = function () {
    this.games.sort(function() {
            return 0.5 - Math.random();
    });
}

Group.prototype.createGames = function (size) {
    for (var x = 0; x < size; x++) {
        for (var y = x+1; y < size; y++) {
            this.games.push(new Array(x, y));
        }
    }

    this.shuffle();
}

Group.prototype.sort = function () {
    this.scores.sort(function(a, b) {
            return (b[6] - b[7]) - (a[6] - a[7]);
    });

    this.scores.sort(function(a, b) {
            return (a[5] - b[5]);
    });

    this.scores.sort(function(a, b) {
            return (b[3] - a[3]);
    });

    this.scores.sort(function(a, b) {
            return (b[1] - a[1]);
    });
}

Group.prototype.refresh = function () {
    var player1id = this.games[this.gameCounter][0];
    var player2id = this.games[this.gameCounter][1];

    this.player1name.setAttribute("value", this.teams[player1id][0].value);
    this.player2name.setAttribute("value", this.teams[player2id][0].value);

    if ("" !== this.player1points.value && "" !== this.player2points.value) {
        var score1 = parseInt(this.player1points.value);
        var score2 = parseInt(this.player2points.value);

        if (score1 == score2) {
            this.teams[player1id][1].value = parseInt(this.teams[player1id][1].value) + 1;
            this.teams[player2id][1].value = parseInt(this.teams[player2id][1].value) + 1;

            this.teams[player1id][4].value = parseInt(this.teams[player1id][4].value) + 1;
            this.teams[player2id][4].value = parseInt(this.teams[player2id][4].value) + 1;
        } else if (score1 > score2) {
            this.teams[player1id][1].value = parseInt(this.teams[player1id][1].value) + 3;

            this.teams[player1id][3].value = parseInt(this.teams[player1id][3].value) + 1;
            this.teams[player2id][5].value = parseInt(this.teams[player2id][5].value) + 1;
        } else {
            this.teams[player2id][1].value = parseInt(this.teams[player2id][1].value) + 3;

            this.teams[player1id][5].value = parseInt(this.teams[player1id][5].value) + 1;
            this.teams[player2id][3].value = parseInt(this.teams[player2id][3].value) + 1;
        }

        this.teams[player1id][2].value = parseInt(this.teams[player1id][2].value) + 1;
        this.teams[player2id][2].value = parseInt(this.teams[player2id][2].value) + 1;

        this.teams[player1id][6].value = parseInt(this.teams[player1id][6].value) + score1;
        this.teams[player2id][6].value = parseInt(this.teams[player2id][6].value) + score2;

        this.teams[player1id][7].value = parseInt(this.teams[player1id][7].value) + score2;
        this.teams[player2id][7].value = parseInt(this.teams[player2id][7].value) + score1;

        this.player1points.value = "";
        this.player2points.value = "";



        this.history += this.teams[player1id][0].value + " - "     + this.teams[player2id][0].value + " " + score1 + ":" + score2 + "<br>";

        var xmlhttp;

        if (window.XMLHttpRequest)
            xmlhttp = new XMLHttpRequest();
        else
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

    /*    xmlhttp.onreadystatechange = function()
        {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
            {
                    // Do something with the result, like post a notification
               // $('#notice').html('<p class="success">'+xmlhttp.responseText+'</p>');
            }
        }
        */
          // send info to php to save to database
        xmlhttp.open('GET',"save_pool_history.php?action=update&updatehistory=" + this.teams[player1id][0].value + "|||"     + this.teams[player2id][0].value + "|||" + score1 + "|||" + score2 , true);
        xmlhttp.send();

        // window.location.href("save_pool_history.php?history=" + this.teams[player1id][0].value + " - "     + this.teams[player2id][0].value + " " + score1 + ":" + score2);

        this.calculate();
        this.next();
        this.refresh();
    }

    this.sort();
    this.scoreTable.set(this.scores);
    if (this.showHistory) {
        this.historyCell.innerHTML ="<div><table><tr><td align='right'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type='button'>OK</button></td></tr></table></div>"+
                                    "<div id=\"history_title\">History:</div>" +
                                    "<div id=\"history_past\">" + this.history + "</div>"  +
                                    "<div id=\"history_future\">"+ this.showAllGames() + "</div>";
    } else {
        this.historyCell.innerHTML = "<div><table><tr><td align='right'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button type='button'>OK</button></td></tr></table></div>"+
                                      "Show History";
    }
}

Group.prototype.finish = function () {
    this.player1points.disabled = true;
    this.player1name.disabled = true;
    this.player2points.disabled = true;
    this.player2name.disabled = true;

    this.isFinish = true;
    finishCounter++;
}

Group.prototype.next = function () {
    if (this.gameCounter >= this.games.length - 1) {
        this.finish();
    } else {
        this.gameCounter++;
    }

    if (finishCounter == groupCounter) {
        modeConnector.show();
    }
}

Group.prototype.onchange = function (instance) {
    instance.refresh();
}

Group.prototype.calculate = function () {
    this.scores = new Array();

    for (var x = 0; x < this.size; x++) {
        var name = this.teams[x][0].value
        var score = this.teams[x][1].value
        var nog = this.teams[x][2].value;
        var wins = this.teams[x][3].value;
        var ties = this.teams[x][4].value;
        var loose = this.teams[x][5].value;
        var goals = this.teams[x][6].value;
        var caughts = this.teams[x][7].value;

        this.scores.push(new Array(name, score, nog, wins, ties, loose, goals, caughts));
    }
}

Group.prototype.button = function (box, instance) {
    if(box.checked) {

        instance.calculate();
        instance.scoreTable.show();
        instance.hide();
    } else {
        instance.scoreTable.hide();
        instance.show();
    }
    instance.refresh();
}

Group.prototype.show = function () {
    this.innerTable.style.display = "block";
}

Group.prototype.hide = function () {
    this.innerTable.style.display = "none";
}


Group.prototype.create = function (size, id, instance) {
    var table = document.createElement("table");
    table.setAttribute("border", "0");
    table.setAttribute("id", "machbox");

    var tbody = document.createElement("tbody");
    table.appendChild(tbody);

    var row = tbody.insertRow(0);
    var cell = row.insertCell(0);
    cell.setAttribute("id", "marker");
    cell.setAttribute("colspan", "2");
    cell.innerHTML = "Pool " + id;

    var row = tbody.insertRow(1);
    var cell = row.insertCell(0);
    cell.setAttribute("colspan", "2");
    cell.appendChild(this.scoreTable.get());

    var row = tbody.insertRow(2);
    var cell = row.insertCell(0);
    cell.setAttribute("colspan", "2");

    var offset = 3;

    this.innerTable = document.createElement("table");
    var innerBody = document.createElement("tbody");
    this.innerTable.appendChild(innerBody);
    cell.appendChild(this.innerTable);


    for (var x = 0; x < size; x++) {
        var row = innerBody.insertRow(x);
        row.setAttribute("valign", "middle");

        var cellName = row.insertCell(0);

        var teamInput = document.createElement("input");
        teamInput.setAttribute("type", "text");
        teamInput.setAttribute("size", "64");
        teamInput.setAttribute("id", "team_" + id + "_input_" + x);
        teamInput.onchange = function() {
            Group.prototype.onchange (instance);
        }

        cellName.appendChild(teamInput);

        var cellPoints = row.insertCell(1);

        var pointInput = document.createElement("input");
        pointInput.setAttribute("type", "text");
        pointInput.setAttribute("size", "2");
        pointInput.setAttribute("maxlength", "2");
        pointInput.setAttribute("value", "0");
        pointInput.setAttribute("id", "result_" + id + "_input_" + x);
        pointInput.onchange = function() {
            Group.prototype.onchange (instance);
        }
        cellPoints.appendChild(pointInput);

        var gamesInput = document.createElement("input");
        gamesInput.setAttribute("value", "0");
        gamesInput.setAttribute("id", "games_" + id + "_input_" + x);

        var winInput = document.createElement("input");
        winInput.setAttribute("value", "0");
        winInput.setAttribute("id", "win_" + id + "_input_" + x);

        var tieInput = document.createElement("input");
        tieInput.setAttribute("value", "0");
        tieInput.setAttribute("id", "tie_" + id + "_input_" + x);

        var looseInput = document.createElement("input");
        looseInput.setAttribute("value", "0");
        looseInput.setAttribute("id", "loose_" + id + "_input_" + x);

        var goalsInput = document.createElement("input");
        goalsInput.setAttribute("value", "0");
        goalsInput.setAttribute("id", "goals_" + id + "_input_" + x);

        var caughtsInput = document.createElement("input");
        caughtsInput.setAttribute("value", "0");
        caughtsInput.setAttribute("id", "caughts_" + id + "_input_" + x);

        this.teams.push(new Array(teamInput, pointInput, gamesInput, winInput, tieInput, looseInput, goalsInput, caughtsInput));
    }

    this.calculate();

    var row = tbody.insertRow(offset);
    var cell = row.insertCell(0);
    cell.setAttribute("colspan", "2");

    var chkbox = document.createElement('input');
    chkbox.setAttribute("type", "checkbox");
    chkbox.onchange = function () {
        Group.prototype.button (this, instance);
    }
    cell.appendChild(chkbox);

    var row = tbody.insertRow(1 + offset);
    var cell = row.insertCell(0);
    cell.setAttribute("id", "marker");
    cell.setAttribute("colspan", "2");
    cell.innerHTML = "Current Game:";

    var row = tbody.insertRow(2 + offset);

    var cell = row.insertCell(0);
       this.player1name = document.createElement("input");
    this.player1name.setAttribute("type", "text");
    this.player1name.setAttribute("size", "60");
    cell.appendChild(this.player1name);

    var cell = row.insertCell(1);
    this.player1points = document.createElement("input");
    this.player1points.setAttribute("type", "text");
    this.player1points.setAttribute("size", "2");
    this.player1points.setAttribute("maxlength", "2");
    this.player1points.onchange = function() {
        Group.prototype.onchange (instance);
    }
       cell.appendChild(this.player1points);

    var row = tbody.insertRow(3 + offset);

    var cell = row.insertCell(0);
       this.player2name = document.createElement("input");
    this.player2name.setAttribute("type", "text");
    this.player2name.setAttribute("size", "60");
    cell.appendChild(this.player2name);

    var cell = row.insertCell(1);
    this.player2points = document.createElement("input");
    this.player2points.setAttribute("type", "text");
    this.player2points.setAttribute("size", "2");
    this.player2points.setAttribute("maxlength", "2");
    this.player2points.onchange = function() {
        Group.prototype.onchange (instance);
    }
       cell.appendChild(this.player2points);


       var row = tbody.insertRow(4 + offset);
    this.historyCell = row.insertCell(0);
    this.historyCell.setAttribute("colspan", "2");
    this.historyCell.setAttribute("class", "history");
    this.historyCell.innerHTML = "View History / Start";
    this.historyCell.onclick = function() {
        Group.prototype.toggleHistory (instance);
    }

    return table;
}

Group.prototype.getTeams = function () {
    return this.scores;
}

Group.prototype.toggleHistory = function (instance) {
    instance.showHistory = !instance.showHistory;

    instance.refresh();
}

Group.prototype.get = function () {
    return this.table;
}

function createTable(player, groups, matches) {

    var table = document.createElement("table");
    var tbody = document.createElement("tbody");

    table.appendChild(tbody);
    table.setAttribute("border", "0");
    table.setAttribute("width", "100%");
    table.setAttribute("id", "sheet");

    var size = Math.ceil(Math.sqrt(groups));
    members = Math.ceil(player / groups);
    var counter = 1;

    for(var line = 0; line < size; line++) {
        var row = tbody.insertRow(line);
        row.setAttribute("valign", "top");

        for (var x = 0; x < size; x++) {
            var cell = row.insertCell(x);
            cell.setAttribute("align", "center");

            if (counter <= groups) {
                var groupInstance = new Group(members, counter, matches);

                groupList.push(groupInstance);
                cell.appendChild(groupInstance.get());
            }

            counter++;
        }
    }

    document.body.appendChild(table);

    modeConnector = new Connector(player, groups);
    document.body.appendChild(modeConnector.get());
}

attached is the image what i want populated..
 

Attachments

  • pp.JPG
    pp.JPG
    42.8 KB · Views: 3

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom