-
Notifications
You must be signed in to change notification settings - Fork 0
/
standalone.html
124 lines (96 loc) · 2.97 KB
/
standalone.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
<html>
<!--
<script type="text/javascript" src="game_hex.js">
game_name='hex';
</script>
-->
<script>
// -------------------------------------Initialization--------------------------------------
players=['erfan','kasra'];
var session=window['new_'+game_name](players);
setup=session.setup;
state=session.state;
</script>
<head>
<style>
body {font-family: Arial;}
/* Style the tab */
.tab {
overflow: hidden;
border: 1px solid #ccc;
background-color: #f1f1f1;
}
/* Style the buttons inside the tab */
.tab button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
}
/* Change background color of buttons on hover */
.tab button:hover {
background-color: #ddd;
}
/* Create an active/current tablink class */
.tab button.active {
background-color: #ccc;
}
/* Style the tab content */
.tabcontent {
display: none;
padding: 6px 12px;
border: 1px solid #ccc;
border-top: none;
}
</style>
</head>
<body>
<script>
body=document.getElementsByTagName('BODY')[0];
</script>
<!------------------------------------------------------------------------------------>
<!-- Users Tabs -->
<!------------------------------------------------------------------------------------>
<div class="tab">
<button id="player1tab" class="tablinks" onclick="preview(event, 'player1')" >Player 1</button>
<button id="player2tab" class="tablinks" onclick="preview(event, 'player2')" >Player 2</button>
</div>
<div id="playercontent" class="tabcontent">
</div>
<script>
function preview(evt, player) {
// alert(JSON.stringify(state));
// alert(player);
document.getElementById("player1tab").style.backgroundColor=(player=='player1') ? 'gray':'';
document.getElementById("player2tab").style.backgroundColor=(player=='player2') ? 'gray':'';
content=document.getElementById("playercontent");
content.innerHTML='';
content.style.display="block";
content.appendChild(window['setupContent_'+game_name](setup,player));
content.appendChild(window['stateContent_'+game_name](setup,state,player));
action_content=window['actionContent_'+game_name](setup,state,player);
action_div=action_content.action_div;
input=action_content.input;
content.appendChild(action_div);
otherplayer=(player=='player1') ? 'player2' : 'player1';
submit_but=document.getElementById("submit_but");
if(submit_but!=null) {
submit_but.type='button';
submit_but.style.visibility = "hidden";
submit_but.onclick=function() {
action=window['getAction_'+game_name](input);
// alert(JSON.stringify(window['newState_'+game_name](setup,state,player,action)));
if(window['validate_'+game_name](setup,state,player,action)) {
state=window['newState_'+game_name](setup,state,player,action);
// alert(JSON.stringify(state));
preview(evt, otherplayer);
} else {alert('Input is not valid.')}};
}
}
</script>
</body>
</html>