updated to use new $.action
[limo.git] / modules / custom / techwars / templates / select_player.tpl
blobdc31a49ba81af4833ed2892addefba000d0d9eb4
1 Please select a player:
2 <select id="select-player">
3 %( ("<option value='%d'>%s</option>" % (int(p[0]),p[1]) for p in players) )s
4 </select>
5 <button id="btn-select-player">select</button>
6 <hr>
7 Or Create a player:
8 <input type="text" id="new-name">
9 <button id="btn-create-player">create</button>
11 <script type="text/javascript">
12         $(document).ready(function() {
13                 $("#btn-select-player").click(function() {
14                         $.action("selectPlayer"
15                                 , { player: $("#select-player").val(), }
16                                 , function(data) {
17                                         location.reload();
18                                 }
19                         );
20                 });
21                 $("#btn-create-player").click(function() {
22                         $.action( "createPlayer"
23                                 , { player: $("#new-name").val() }
24                                 , function(data) {
25                                         location.reload();
26                                 }
27                                 , function(error) {
28                                         $("#btn-create-player").after("<div class='error'>"+error.toString()+"</div>");
29                                 }
30                         );
31                 });
32         });
33 </script>