-
Notifications
You must be signed in to change notification settings - Fork 0
/
1player.html
68 lines (52 loc) · 1.67 KB
/
1player.html
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!DOCTYPE html>
<html lang="en">
<head>
<title>Dice</title>
<link rel="stylesheet" href="diceStyle.css">
<script type="text/javascript" src="dice.js"></script>
<style>
.controls {
margin-top: 30px;
clear: both;
}
.diceArea {
width: 100%;
float: left;
}
</style>
<script type="text/javascript">
var initDiceArea = function(name) {
//diceAreaDiv should be a div containing another div with class 'diceHolder'.
//You're welcome to add elements into th diceArea div, but not the diceHolder div (or they may get clobbered).
var diceAreaDiv = document.getElementById(name);
//The name can be used later to access the object with DiceArea.Areas[name].
var diceArea = new DiceArea(diceAreaDiv, name);
//Optional: this function is called whenever the sum of the values on the dice change.
diceArea.displaySum = function(sum) {
diceAreaDiv.getElementsByClassName('diceTotal')[0].innerHTML = sum;
}
diceArea.addDie();
return;
}
var init = function() {
initDiceArea('diceArea1');
}
</script>
</head>
<body onload="init()">
<h1 id="heading">Dice</h1>
<div id="diceArea1" class="diceArea">
<h2>Player 1</h2>
<h2>Total: <span class="diceTotal"></span></h2>
<div id="diceHolder" class="diceHolder">
</div>
<div class="controls">
<button type="button" onClick="DiceArea.Areas['diceArea1'].rollDice()">roll</button>
<button type="button" onClick="DiceArea.Areas['diceArea1'].addDie()">add die</button>
<button type="button" onClick="DiceArea.Areas['diceArea1'].removeLast()">remove die</button>
</div>
</div>
<footer>
</footer>
</body>
</html>