-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
97 lines (72 loc) · 2.11 KB
/
index.php
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
<?php
include 'rps.php';
include 'stats.php';
?>
<html>
<head>
<script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="jumbotron" style="background-repeat: no-repeat; background-color: #E0EEEE; height: auto;">
<h1>Rock Paper Scissors</h1>
<p> funfunfun</p>
</div>
<div class="container">
<div id="left" style="margin-left:10%; width: auto; float:left;">
<div id="buttons">
<div class="row" style="padding-bottom: 20px;">
<button type="button" id="rock" >Rock</button>
<button type="button" id="paper" >Paper</button>
<button type="button" id="scissors" >Scissors</button>
</div>
</div>
<div id="result">
<!--rps goes here-->
</div>
</div>
<div id="right" style="width: 20%; float:right; margin-right: 10%;">
<!--stats go here-->
</div>
</div>
</body>
</html>
<script type='text/javascript'>
$(document).ready(function()
{
//on button click, pass ajax request
$("#buttons").find("button").click(function(event){
event.preventDefault();
$("#result").html('');
var $data = this.id + "=1&action=rps";
$.ajax({
url: 'rps.php',
type: 'POST',
datatype: 'http',
data: $data,
success: function(message){
$("#result").hide().html(message).fadeIn(1000);}
}).done(function(){
$.ajax({
url: 'stats.php',
type: 'GET',
data: {action: 'stats'},
datatype: 'json',
success: function(message){
$("#right").html(message);}
});
});
});
});
//clears current games on session
$(window).unload(function(){
$.ajax({
url: 'unload.php',
type: 'POST',
async: false,
success: function(message){alert(message);}
});
});
</script>