1jQuery( document ).ready( function( $ ) { 2 'use strict'; 3 4 // next pagination button is clicked 5 $( '.dk-speakup-signaturelist-next' ).click( function( e ) { 6 e.preventDefault(); 7 get_signaturelist( $( this ) ); 8 }); 9 10 // prev pagination button is clicked 11 $( '.dk-speakup-signaturelist-prev' ).click( function( e ) { 12 e.preventDefault(); 13 get_signaturelist( $( this ) ); 14 }); 15 16 // pagination: query new signatures and display results 17 function get_signaturelist( button, link ) { 18 // change button appearance to disabled while ajax request is processing 19 $( this ).addClass( 'dk-speakup-signaturelist-disabled' ); 20 21 var link = button.attr( 'rel' ).split( ',' ), 22 id = link[0], 23 start = link[1], 24 limit = link[2], 25 total = link[3], 26 status = link[4], 27 ajax = { 28 action: 'dk_speakup_paginate_signaturelist', 29 id: id, 30 start: start, 31 limit: limit, 32 dateformat: dk_speakup_signaturelist_js.dateformat 33 }; 34 35 if ( status === '1' ) { 36 // submit data and handle ajax response 37 $.post( dk_speakup_signaturelist_js.ajaxurl, ajax, 38 function( response ) { 39 var next_link = get_next_link( id, start, limit, total ); 40 var prev_link = get_prev_link( id, start, limit, total ); 41 42 toggle_button_display( id, next_link, prev_link ); 43 44 $( '.dk-speakup-signaturelist-' + id + ' tr:not(:last-child)' ).remove(); 45 $( '.dk-speakup-signaturelist-' + id ).prepend( response ); 46 $( '.dk-speakup-signaturelist-' + id + ' .dk-speakup-signaturelist-next' ).attr( 'rel', next_link ); 47 $( '.dk-speakup-signaturelist-' + id + ' .dk-speakup-signaturelist-prev' ).attr( 'rel', prev_link ); 48 } 49 ); 50 } 51 } 52 53 // format new link for next pagination button 54 function get_next_link( id, start, limit, total ) { 55 var start = parseInt( start ), 56 limit = parseInt( limit ), 57 total = parseInt( total ), 58 new_start = '', 59 status = '', 60 link = ''; 61 62 if ( start + limit < total ) { 63 new_start = start + limit; 64 status = '1'; 65 } 66 else { 67 new_start = total; 68 status = '0'; 69 } 70 71 link = id + ',' + new_start + ',' + limit + ',' + total + ',' + status; 72 return link; 73 } 74 75 // format new link for prev pagination button 76 function get_prev_link( id, start, limit, total ) { 77 var start = parseInt( start ), 78 limit = parseInt( limit ), 79 total = parseInt( total ), 80 new_start = '', 81 status = '', 82 link = ''; 83 84 if ( start - limit >= 0 ) { 85 new_start = start - limit; 86 status = '1'; 87 } 88 else { 89 new_start = total; 90 status = '0'; 91 } 92 93 link = id + ',' + new_start + ',' + limit + ',' + total + ',' + status; 94 return link; 95 } 96 97 function toggle_button_display( id, next_link, prev_link ) { 98 if ( next_link.split( ',' )[4] === '0' ) { 99 $( '.dk-speakup-signaturelist-' + id + ' .dk-speakup-signaturelist-next' ).addClass( 'dk-speakup-signaturelist-disabled' ); 100 } 101 else { 102 $( '.dk-speakup-signaturelist-' + id + ' .dk-speakup-signaturelist-next' ).removeClass( 'dk-speakup-signaturelist-disabled' ); 103 } 104 105 if ( prev_link.split( ',' )[4] === '0' ) { 106 $( '.dk-speakup-signaturelist-' + id + ' .dk-speakup-signaturelist-prev' ).addClass( 'dk-speakup-signaturelist-disabled' ); 107 } 108 else { 109 $( '.dk-speakup-signaturelist-' + id + ' .dk-speakup-signaturelist-prev' ).removeClass( 'dk-speakup-signaturelist-disabled' ); 110 } 111 } 112 113});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.