Back to Shut the Box Project

Shut the Box Project - JS, CSS, and HTML updates

Additional Scripts Six

Instructions:

Although this is the the sixth update to scripts, we need to make changes in multiple places on the HTML and CSS files as well. Let's start with our JS file. Copy and Paste the first block of code to put into the end of our JS file and follow the instructions in the comment. Copy and Paste the second block of code to put into each of the conditions for player=?. Also, copy and paste the HTML in the second block into the <p> tag in the scoreboard div to add round totals. Lastly, add the CSS at the bottom of our styles file.

// to be used with a body tag onload=...
function init() {
// loading up actions
$("#reset").hide();
$("#endBtn").hide();
}
            
        //total the player scores for both conditionals
        // change #p1 to #p2 and allScoresP1[i] to allScoresP2[i] if player=2
        var temp=0;
        for (var i = 0; i < games; i++) {
            temp += allScoresP1[i];
        };
        $("#p1").text(temp);
            
            <p><u>Player 1 Total</u><br><span id="p1">0</span>
                <span class="floatR"><u>Player 2 Total</u><br><span id="p2">0</span>
                </span> 
            </p>      


            .floatR {
                float:right;
                margin-top: -16px;
            }      
            
David Johns and Electric Teaching ~ All Rights Reserved 2015