-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
97 lines (74 loc) · 2.36 KB
/
index.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
<html>
<head>
<title>Dice Result Breakdown Page </title>
<style>
</style>
<script src="https://peterolson.github.io/BigInteger.js/BigInteger.min.js"></script>
<style type="text/css">
body {
background-color: White;
text-align: center;
color: Black;
font-family: Arial, Helvetica, sans-serif;
}
.main {
margin-top: 10em;
}
.fiddle {
margin-top:20px;
}
.hash-input {
width: 450px;
height: 25px;
}
.seperator {
margin: 20px 0 20px 0;
}
</style>
<script type="text/javascript">
function executeResultBreakdown() {
const get64 = (value, n = 0) => (value.shiftRight(bigInt(64 * n))).and(bigInt("ffffffffffffffff", 16));
const toNumber = value => +value.toString();
var hash = bigInt(document.getElementById("resultHash").value, 16)
var dice1 = toNumber(get64(hash, 0).mod(bigInt(6)).plus(bigInt(1)));
var dice2 = toNumber(get64(hash, 1).mod(bigInt(6)).plus(bigInt(1)));
document.getElementById("dice1").innerHTML = "<strong>Dice 1:</strong> " + dice1;
document.getElementById("dice2").innerHTML = "<strong>Dice 2:</strong> " + dice2;
}
</script>
</head>
<body>
<div class="main">
<table align="center">
<tr>
<td colspan="2">
<p>Enter Dice Result Hash here:</p>
</td>
</tr>
<tr>
<td colspan="2"> <input type="text" value="" class="hash-input" id="resultHash" /> </td>
</tr>
<tr>
<td colspan="2"><input type="button" value="Execute Result Breakdown" onclick="executeResultBreakdown()" />
</td>
</tr>
<tr>
<td colspan="2">
<hr class="seperator" />
</td>
</tr>
<tr>
<td>
<label id="dice1">Dice1 : 2 </label>
</td>
<td>
<label id="dice2">
Dice2: 3
</label>
</td>
</tr>
</table>
<p class="fiddle">jsfiddle link: <a href="https://jsfiddle.net/hashgoal/4mb9fd5x/2/" > https://jsfiddle.net/hashgoal/4mb9fd5x/2/ </a> </p>
</div>
</body>
</html>