-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
76 lines (59 loc) · 2.53 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
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="faye.js"></script>
<script type="text/javascript">
Table = function(id) {
this.client = new Faye.Client('http://dice.no.de/faye');
this.id = id;
this.players = this.client.subscribe('/tables/'+ this.id + '/players', function(message) {
$('<div>'+message.username+' has joined the table.</div>').hide().prependTo('#log').slideDown();
});
this.rolls = this.client.subscribe('/tables/'+ this.id + '/rolls', function(message) {
$('<div>'+message.username+' rolls ' + message.roll + ' and gets ' + message.result + '</div>').hide().prependTo('#log').slideDown();
});
};
Table.prototype.roll = function(what) {
this.client.publish('/tables/'+this.id+'/rolls', {username: this.username, roll: what});
};
Table.prototype.login = function() {
this.username = $('#username').val();
this.client.publish('/tables/'+this.id+'/players', {username: this.username});
$('#login').fadeOut(function() {
$('#container').fadeIn();
});
}
myTable = new Table('asdf');
</script>
<style type="text/css">
footer {
font-size: 0.7em;
}
</style>
</head>
<body>
<div id="login">
<input id="username" placeholder="Enter your name" />
<input type="submit" onclick="myTable.login();" />
</div>
<div id="container" style="display:none;">
<div id="dice">
<input type="button" onclick="myTable.roll($(this).val());" value="1d2" />
<input type="button" onclick="myTable.roll($(this).val());" value="1d4" />
<input type="button" onclick="myTable.roll($(this).val());" value="1d6" />
<input type="button" onclick="myTable.roll($(this).val());" value="1d8" />
<input type="button" onclick="myTable.roll($(this).val());" value="1d10" />
<input type="button" onclick="myTable.roll($(this).val());" value="1d12" />
<input type="button" onclick="myTable.roll($(this).val());" value="1d20" />
<input type="button" onclick="myTable.roll($(this).val());" value="1d100" />
</div>
<div id="diceRequests">
<input name="roll" id="roll" placeholder="Enter your roll, e.g., 2d10+4" style="width: 20em;" />
<input type="button" onclick="myTable.roll($('input#roll').val()); $('input#roll').val('');" value="roll me some dice" />
</div>
<div id="log"></div>
<footer>© <a href="http://www.roleplaygateway.com/">RolePlayGateway</a></footer>
</div>
</body>
</html>