Subversion Repositories ALCASAR

Rev

Details | Last modification | View Log

Rev Author Line No. Line
3264 rexy 1
/*! © SpryMedia Ltd, Dominique Fournier, Brad Wasson, Peter Vilhan, Kevin Gilkey-Graham - datatables.net/license */
2
 
3
(function( factory ){
4
	if ( typeof define === 'function' && define.amd ) {
5
		// AMD
6
		define( ['jquery', 'datatables.net'], function ( $ ) {
7
			return factory( $, window, document );
8
		} );
9
	}
10
	else if ( typeof exports === 'object' ) {
11
		// CommonJS
12
		var jq = require('jquery');
13
		var cjsRequires = function (root, $) {
14
			if ( ! $.fn.dataTable ) {
15
				require('datatables.net')(root, $);
16
			}
17
		};
18
 
19
		if (typeof window === 'undefined') {
20
			module.exports = function (root, $) {
21
				if ( ! root ) {
22
					// CommonJS environments without a window global must pass a
23
					// root. This will give an error otherwise
24
					root = window;
25
				}
26
 
27
				if ( ! $ ) {
28
					$ = jq( root );
29
				}
30
 
31
				cjsRequires( root, $ );
32
				return factory( $, root, root.document );
33
			};
34
		}
35
		else {
36
			cjsRequires( window, jq );
37
			module.exports = factory( jq, window, window.document );
38
		}
39
	}
40
	else {
41
		// Browser
42
		factory( jQuery, window, document );
43
	}
44
}(function( $, window, document ) {
45
'use strict';
46
var DataTable = $.fn.dataTable;
47
 
48
 
49
/**
50
 * Sorts a column containing IP addresses (IPv4 and IPv6) or IPv4 address and port delimited by ':' in typical dot
51
 * notation / colon. This can be most useful when using DataTables for a
52
 * networking application, and reporting information containing IP address.
53
 *
54
 *  @name IP addresses
55
 *  @summary Sort IP addresses numerically
56
 *  @author Dominique Fournier
57
 *  @author Brad Wasson
58
 *  @author Peter Vilhan
59
 *  @author Kevin Gilkey-Graham
60
 *
61
 *  @example
62
 *    $('#example').dataTable( {
63
 *       columnDefs: [
64
 *         { type: 'ip-address', targets: 0 }
65
 *       ]
66
 *    } );
67
 */
68
DataTable.ext.type.order['ip-address-pre'] = function (a) {
69
    var i, item;
70
    var m, n, t, p;
71
    var x, xa;
72
    if (!a) {
73
        return '000000000000';
74
    }
75
    a = a.replace(/<[\s\S]*?>/g, '');
76
<[\s\S]*?>    //IPv4:Port
77
<[\s\S]*?>    t = a.split(':');
78
<[\s\S]*?>    if (t.length == 2) {
79
<[\s\S]*?>        m = t[0].split('.');
80
<[\s\S]*?>        p = t[1];
81
<[\s\S]*?>    }
82
<[\s\S]*?>    else {
83
<[\s\S]*?>        m = a.split('.');
84
<[\s\S]*?>    }
85
<[\s\S]*?>    n = a.split(':');
86
<[\s\S]*?>    x = '';
87
<[\s\S]*?>    xa = '';
88
<[\s\S]*?>    if (m.length == 4) {
89
<[\s\S]*?>        // IPV4
90
<[\s\S]*?>        for (i = 0; i < m.length; i++) {
91
<[\s\S]*?>            item = m[i];
92
<[\s\S]*?>            x += '000'.substr(item.length) + item;
93
<[\s\S]*?>        }
94
<[\s\S]*?>        if (p) {
95
<[\s\S]*?>            x += ':' + '00000'.substr(p.length) + p;
96
<[\s\S]*?>        }
97
<[\s\S]*?>    }
98
<[\s\S]*?>    else if (n.length > 0) {
99
<[\s\S]*?>        // IPV6
100
<[\s\S]*?>        var count = 0;
101
<[\s\S]*?>        for (i = 0; i < n.length; i++) {
102
<[\s\S]*?>            item = n[i];
103
<[\s\S]*?>            if (i > 0) {
104
<[\s\S]*?>                xa += ':';
105
<[\s\S]*?>            }
106
<[\s\S]*?>            if (item.length === 0) {
107
<[\s\S]*?>                count += 0;
108
<[\s\S]*?>            }
109
<[\s\S]*?>            else {
110
<[\s\S]*?>                xa += '0000'.substr(item.length) + item;
111
<[\s\S]*?>                count += 4;
112
<[\s\S]*?>            }
113
<[\s\S]*?>        }
114
<[\s\S]*?>        // Padding the ::
115
<[\s\S]*?>        n = xa.split(':');
116
<[\s\S]*?>        var paddDone = 0;
117
<[\s\S]*?>        for (i = 0; i < n.length; i++) {
118
<[\s\S]*?>            item = n[i];
119
<[\s\S]*?>            if (item.length === 0 && paddDone === 0) {
120
<[\s\S]*?>                for (var padding = 0; padding < 32 - count; padding++) {
121
<[\s\S]*?>                    x += '0';
122
<[\s\S]*?>                    paddDone = 1;
123
<[\s\S]*?>                }
124
<[\s\S]*?>            }
125
<[\s\S]*?>            else {
126
<[\s\S]*?>                x += item;
127
<[\s\S]*?>            }
128
<[\s\S]*?>        }
129
<[\s\S]*?>    }
130
<[\s\S]*?>    return x;
131
<[\s\S]*?>};
132
 
133
 
134
<[\s\S]*?>return DataTable;
135
<[\s\S]*?>}));