]> de.git.xonotic.org Git - xonotic/xonstat.git/blob - xonstat/static/js/default.js
Fixed sorting of leaderboard table (Bug #738) with a datatables plugin.
[xonotic/xonstat.git] / xonstat / static / js / default.js
1 $(function(){
2
3         init_menus();
4         init_checkboxes();
5         init_radiobuttons();
6         init_datatables();
7
8 });
9
10 $.fn.hoverClass = function(c) {
11     return this.each(function(){
12         $(this).hover(
13             function() { $(this).addClass(c);  },
14             function() { $(this).removeClass(c); }
15         );
16     });
17 };
18
19 function init_menus() {
20         $("#menu li").hover(
21         function(){ $("ul", this).fadeIn("fast"); },
22         function() { }
23     );
24     if (document.all) {
25         $("#menu li").hoverClass("sfHover");
26     }
27 }
28 function init_checkboxes() {
29         $(".checkbox").change(function(){
30                 if($(this).is(":checked")){
31                         $(this).next("label").addClass("checkbox-selected");
32                 }else{
33                         $(this).next("label").removeClass("checkbox-selected");
34                 }
35         });
36 }
37 function init_radiobuttons() {
38         $(".radio").change(function(){
39                 if($(this).is(":checked")){
40                         $(".radio-selected:not(:checked)").removeClass("radio-selected");
41                         $(this).next("label").addClass("radio-selected");
42                 }
43         });
44 }
45 function init_datatables() {
46         /* lazy test to see if exists,
47          * setup proper routing in document ready */
48         if ($("#sidebar table").length) {
49                 $("#sidebar table").dataTable({
50                         "bPaginate": false,
51                         "bLengthChange": false,
52                         "bFilter": false,
53                         "bSort": true,
54                         "bInfo": false,
55                         "bAutoWidth": false
56                 });
57         }
58         if ($("#recent-games").length) {
59                 $("#recent-games").dataTable({
60                         "bPaginate": false,
61                         "bLengthChange": false,
62                         "bFilter": true,
63                         "bSort": true,
64                         "bInfo": false,
65                         "bAutoWidth": false,
66                         "oLanguage": {
67                                 "sSearch": "_INPUT_"
68                         },
69                         "aaSorting": [[ 0, "desc" ]]
70                 });
71         }
72         if ($("table.scoreboard").length) {
73                 $("table.scoreboard").dataTable({
74                         "bPaginate": false,
75                         "bLengthChange": false,
76                         "bFilter": false,
77                         "bSort": true,
78                         "bInfo": false,
79                         "bAutoWidth": false
80                 });
81         }
82         if ($("table.accuracy").length) {
83                 $("table.accuracy").dataTable({
84                         "bPaginate": false,
85                         "bLengthChange": false,
86                         "bFilter": false,
87                         "bSort": true,
88                         "bInfo": false,
89                         "bAutoWidth": false
90                 });
91         }
92         if ($(".recent_game_box").length) {
93                 $("").colorbox({width:"80%", height:"80%", iframe:true});
94         }
95         //$("#recent-games_filter input").attr("placeholder","filter names");
96 }