-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtestgame.html
128 lines (100 loc) · 2.74 KB
/
testgame.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html lang="en">
<head>
<title>RPG dice roller</title>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="Author" content="Czigler Ferenc"/>
<meta name="Copyright" content="(C) Copyright Czigler Ferenc"/>
<link rel="stylesheet" href="u87.css" type="text/css" />
<style>
html {
background-color: #333;
}
body {
width: 100%;
max-width: 300px;
font-size: 17px;
background-color: #333;
}
article {
background-color: #fff;
display: block;
border: 1px solid #333;
padding: 5px;
border-radius: 8px;
}
table, tr, td { border: 0; }
td { vertical-align: center; padding: 0.5rem; }
span { padding: 0 0.5rem; }
input {
width: 80px;
padding: 3px;
}
button {
padding: 3px 5px 3px 5px;
min-width: 100px;
}
input, button {
background-color: transparent;
color: #333;
border: 1px solid #333;
font-size: 18px;
border-radius: 4px;
}
input:hover, input:focus, button:hover {
background-color: #333;
color: white;
}
</style>
</head>
<body>
<article>
<h1 class="center">RPG dice roller</h1>
<table>
<tr>
<td>Dice:</td>
<td><input type="number" id="dice" name="number" value="6"/></td>
<td><button id="resetButton">Reset</button></td>
</tr>
<tr>
<td>Rolls:</td>
<td><input type="number" id="rolls" name="number" value="1"/></td>
<td><button id="getButton">Get rolls</button></td>
</tr>
</table>
<h2 class="center">Results</h2>
<div id="results" class="padding"></div>
<footer id="footer" class="center"><small>
<p>Contact me on <a href="http://github.com/Serrin" target="_blank">Github</a></p>
<p>© Copyright 2018 Ferenc Czigler</p>
</small></footer>
</article>
<script src="celestra.min.js"></script>
<script>
CEL.domReady(function () {
window.results = CEL.qs("#results");
window.dice = CEL.qs("#dice");
window.rolls = CEL.qs("#rolls");
function getResults () {
CEL.qsa("span",results).forEach(function (e) { e.remove(); });
//results.innerHTML = "";
var diceValue = parseInt(dice.value),
repeat = parseInt(rolls.value);
for (var i=0; i<repeat; i++) {
results.append( CEL.domCreate("span",{},"<i>#"+(i+1)+":</i> <b>"+CEL.randomInt(1,diceValue)+"</b>") );
}
}
function reset () {
CEL.qsa("span",results).forEach(function (e) { e.remove(); });
//results.innerHTML = "";
dice.value = 6;
rolls.value = 1;
}
CEL.qs("#getButton").addEventListener("click", getResults);
CEL.qs("#resetButton").addEventListener("click", reset);
});
</script>
</body>
</html>