3 var list_rules = function( args ) {
5 var fn_create_row = function( rowData ) {
6 var clone = $('.rule_row.template').clone().removeClass('template');
7 var anchor = clone.find('.rule_title a');
8 anchor.text( rowData.title );
9 anchor.attr('href', anchor.attr('href') + "&id=" + rowData.id);
11 anchor = clone.find('.rule_type a');
12 anchor.text( rowData.type );
13 anchor.attr('href', anchor.attr('href') + "&id=" + rowData.id);
14 $('.rule_container').append(clone);
18 var fn_work = function( sort ) {
24 $.getJSON('index.php?action=browse!getrows',
26 data.sort(function(a, b) {
27 if ( sort == 'title' ) {
28 return (a.title < b.title) ? -1 : (a.title > b.title) ? 1 : 0;
29 } else if ( sort == 'type' ) {
30 return (a.type < b.type) ? -1 : (a.type > b.type) ? 1 : 0;
35 fn_create_row( data[i]);
41 var fn_sort = function( field ) {
42 $('.rule_row.data').sortElements( function(a,b) {
43 var x = $(a).find('.' + field).text();
44 var y = $(b).find('.' + field).text();
45 return (x < y) ? -1 : (x > y) ? 1 : 0;
49 var fn_wire_events = function() {
50 $('.header_title').click( function() {
51 fn_sort( 'rule_title' );
54 $('.header_type').click( function() {
55 fn_sort( 'rule_type' );
61 $( document ).ready( function() {