$(function(){
-
+
init_menus();
init_checkboxes();
init_radiobuttons();
init_datatables();
});
-
+
$.fn.hoverClass = function(c) {
return this.each(function(){
- $(this).hover(
+ $(this).hover(
function() { $(this).addClass(c); },
function() { $(this).removeClass(c); }
);
function init_menus() {
$("#menu li").hover(
- function(){ $("ul", this).fadeIn("fast"); },
- function() { }
+ function(){ $("ul", this).fadeIn("fast"); },
+ function() { }
);
if (document.all) {
$("#menu li").hoverClass("sfHover");
$(".radio-selected:not(:checked)").removeClass("radio-selected");
$(this).next("label").addClass("radio-selected");
}
- });
+ });
}
function init_datatables() {
/* lazy test to see if exists,
"bAutoWidth": false,
"oLanguage": {
"sSearch": "_INPUT_"
- }
+ },
+ "aaSorting": [[ 0, "desc" ]]
});
}
if ($("table.scoreboard").length) {
--- /dev/null
+jQuery.fn.dataTableExt.oSort['num-html-asc'] = function(a,b) {
+ var x = a.replace( /<.*?>/g, "" );
+ var y = b.replace( /<.*?>/g, "" );
+ x = parseFloat( x );
+ y = parseFloat( y );
+ return ((x < y) ? -1 : ((x > y) ? 1 : 0));
+};
+
+jQuery.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) {
+ var x = a.replace( /<.*?>/g, "" );
+ var y = b.replace( /<.*?>/g, "" );
+ x = parseFloat( x );
+ y = parseFloat( y );
+ return ((x < y) ? 1 : ((x > y) ? -1 : 0));
+};
+
+jQuery.fn.dataTableExt.aTypes.unshift( function ( sData )
+{
+ sData = typeof sData.replace == 'function' ?
+ sData.replace( /<.*?>/g, "" ) : sData;
+ sData = $.trim(sData);
+
+ var sValidFirstChars = "0123456789-";
+ var sValidChars = "0123456789.";
+ var Char;
+ var bDecimal = false;
+
+ /* Check for a valid first char (no period and allow negatives) */
+ Char = sData.charAt(0);
+ if (sValidFirstChars.indexOf(Char) == -1)
+ {
+ return null;
+ }
+
+ /* Check all the other characters are valid */
+ for ( var i=1 ; i<sData.length ; i++ )
+ {
+ Char = sData.charAt(i);
+ if (sValidChars.indexOf(Char) == -1)
+ {
+ return null;
+ }
+
+ /* Only allowed one decimal place... */
+ if ( Char == "." )
+ {
+ if ( bDecimal )
+ {
+ return null;
+ }
+ bDecimal = true;
+ }
+ }
+
+ return 'num-html';
+} );
\ No newline at end of file
</%block>
</head>
<body>
- <div id="container">
- <div id="home" class="window">
- <h1 id="title">Player Statistics for Xonotic</h1>
+ <div id="container">
+ <div id="home" class="window">
+ <h1 id="title">Player Statistics for Xonotic</h1>
<ul id="menu" class="nav clearfix">
<li><a href="${request.route_url('main_index')}" title="Leaderboard">leaderboard</a></li>
<li><a href="${request.route_url('player_index')}" title="Player Index">players</a></li>
<script>window.jQuery || document.write( '<script src="/static/js/scripts/jquery-1.6.1.min.js"><\/script>' )</script>-->
<script src="/static/js/jquery-1.6.1.min.js"></script>
<script src="/static/js/jquery.dataTables.min.js"></script>
+ <script src="/static/js/jquery.dataTables.numHtml.js"></script>
<script src="/static/js/default.js"></script>
</%block>
</body>