Longest Serving GMs
Wayne Embry
1987-99
13 years
Chris Grant
2011-17
7 years
Bill Fitch
1974-79
6 years
Jim Paxson
2000-05
6 years
Loading stats...
'+tableLegend; } else { return '
Showing ' + total + ' of ' + max + ' records.
Change filters or adjust season slider to modify results.
Click on column headings to sort table.
'+tableLegend;} } , fnFooterCallback: function ( nRow, aaData, iStart, iEnd, aiDisplay ) { //cant get actual 2+ row footers to work below or elsewhere, so just using
on footer results var api = this.api(); $('tr:eq(1) th:eq(3)', api.table().footer()).html((34)); $('tr:eq(1) th:eq(4)', api.table().footer()).html((53)); $('tr:eq(1) th:eq(5)', api.table().footer()).html((12)); // var secondRow = $(nRow).next()[0]; // var nCells = secondRow.getElementsByTagName('th'); // nCells[1].innerHTML = 55; // nCells[2].innerHTML = 47.01; // console.log(nCells); }, // ========================================================== // Functions that automatically calculate sum/average/etc on footer of each column // // each column's class attribute is tagged as to what type of subtotal should be calculated // ========================================================== drawCallback: function () { //sums the footer values var api = this.api(); var ct=0; //index counter var rowCt=0; //count number of rows in particular column var seaCt=0; //number of seasons visible //counts the rows in first column and shows as ## Totals api.columns('.tot', { page: 'current' }).every(function () { var sum = this .data() .reduce(function (a, b) { if (b!='') { ct++; } return ''; }, 0); seaCt = ct; ct=0; //console.log('=='+sum+'/'+ct+'/'+seaCt); // Update footer of first column if (seaCt>1 && !1) { //season totals and average $(this.footer()).html(seaCt+" GMs
Average" ); }else if (seaCt>1 ) { $(this.footer()).html(seaCt+" GMs" ); }else{ $(this.footer()).html(seaCt+" GM" ); } }); // ============================================================ // Calculate Averages on columns that are already averages by grabbing data // from other column Totals // e.g. FG%, Batting Average, SLG, etc // ============================================================ // call from each page , for example: // var colclass = '.3Ppct-calc' // var numerFld = '3Ptot:name' // var denomFld = '3PAtot:name' // var sigfig = 1 // var decPct = 100 // var strip0 = true //strip leading "0." from results 0.500 -> .500 // var numerVal = parseFloat(api.column( numerFld, {page:'current'} ).data().sum(0)) // var denomVal = parseFloat(api.column( denomFld, {page:'current'} ).data().sum(0)) // customFooterVal(); //=================================================================================== // Simple integer columns are automatically averaged by using the .sumave class on the column // Below calls are to Calculate Averages on columns that are already averages or ratios // e.g. FG%, Batting Average, SLG, PPG, etc //=================================================================================== //=================================================================================== var colclass = '.WinPct-calc'; var numerFld = 'wins:name'; var denomFld = 'losses:name'; var sigfig = 3; var decPct = 1; var strip0 = true; //strip leading 0. from results 0.500 -> .500 var numerVal = parseFloat(api.column( numerFld, {page:'current'} ).data().sum(0)); var denomVal = numerVal + parseFloat(api.column( denomFld, {page:'current'} ).data().sum(0)); customFooterVal(); function customFooterVal() { // some columns may have null stats, so cant include those in averages. // This javascript technique iterates one column at a time // So it becomes problematic to count rows in a _different_ column to get accurate averages/per-game totals. // so instead, we'll just get a ratio of the rows with/without null in _current_ column // and then multiply subtotal by that ratio to get a best estimate. // Mostly accurate unless game counts vary from season to season. // var numerCt = parseFloat(api.column( numerFld, {page:'current'} ).data().filter( function ( value, index ) {return value !='' ? true : false; } ).count()+0.00001); //counts non-nulls var denomCt = parseFloat(api.column( denomFld, {page:'current'} ).data().filter( function ( value, index ) {return value !='' ? true : false; } ).count()); //counts non=nulls var subave = ( (denomCt / numerCt) * numerVal / ( denomVal + 0.00001 ) * decPct ).toFixed(sigfig); //create footer if (numerCt<1) { subave='-'; //no stats in column }else if (strip0) { subave=subave.replace(/^(0\.)/,'.') ; //strip leading "0." from results 0.500 -> .500 } if (seaCt>1 && !1) { subave = subave + '
' + subave } jQuery( api.table().column( colclass ).footer() ).html( ( subave ) ); } // console.log('---------') // console.log ('1:'+ parseFloat(api.column( '3Ptot:name', {page:'current'} ).data().filter( // function ( value, index ) {return value !='' ? true : false; } ).count())) // console.log ('2:'+ parseFloat(api.column( '3PAtot:name', {page:'current'} ).data().filter( // function ( value, index ) {return value !='' ? true : false; } ).count())) // the sigfig and 'leading 0' are stored in database also creates // a custom class. for use in javascript calcuations of dynamic footer calculations // not currently used // ========================= // footer with sum and average // ========================= api.columns('.sumave00', { page: 'current' }).every(function () { var strip0 =0; var sigfig =0; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } sum = parseInt(sum); $(this.footer()).html(sum + ave ); }); api.columns('.sumave01', { page: 'current' }).every(function () { var strip0 =0; var sigfig =1; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } sum = parseInt(sum); $(this.footer()).html(sum + ave ); }); api.columns('.sumave02', { page: 'current' }).every(function () { var strip0 =0; var sigfig =2; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } sum = parseInt(sum); $(this.footer()).html(sum + ave ); }); api.columns('.sumave03', { page: 'current' }).every(function () { var strip0 =0; var sigfig =3; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } sum = parseInt(sum); $(this.footer()).html(sum + ave ); }); api.columns('.sumave11', { page: 'current' }).every(function () { var strip0 =1; var sigfig =1; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } sum = parseInt(sum); $(this.footer()).html(sum + ave ); }); api.columns('.sumave12', { page: 'current' }).every(function () { var strip0 =1; var sigfig =2; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } sum = parseInt(sum); $(this.footer()).html(sum + ave ); }); api.columns('.sumave13', { page: 'current' }).every(function () { var strip0 =1; var sigfig =3; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } sum = parseInt(sum); $(this.footer()).html(sum + ave ); }); // ========================= // footer with two averages // ========================= api.columns('.aveave00', { page: 'current' }).every(function () { var strip0 =0; var sigfig =0; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } $(this.footer()).html( sumAlt + ave ); }); api.columns('.aveave01', { page: 'current' }).every(function () { var strip0 =0; var sigfig =1; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } $(this.footer()).html( sumAlt + ave ); }); api.columns('.aveave02', { page: 'current' }).every(function () { var strip0 =0; var sigfig =2; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } $(this.footer()).html( sumAlt + ave ); }); api.columns('.aveave03', { page: 'current' }).every(function () { var strip0 =0; var sigfig =3; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } $(this.footer()).html( sumAlt + ave ); }); api.columns('.aveave11', { page: 'current' }).every(function () { var strip0 =1; var sigfig =1; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } $(this.footer()).html( sumAlt + ave ); }); api.columns('.aveave12', { page: 'current' }).every(function () { var strip0 =1; var sigfig =2; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } $(this.footer()).html( sumAlt + ave ); }); api.columns('.aveave13', { page: 'current' }).every(function () { var strip0 =1; var sigfig =3; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } $(this.footer()).html( sumAlt + ave ); }); //these two should be obsolete, but keeping them here for legacy purposes api.columns('.aveave', { page: 'current' }).every(function () { var strip0 =1; var sigfig =1; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } $(this.footer()).html( sumAlt + ave ); }); //these two should be obsolete, but keeping them here for legacy purposes api.columns('.sumave', { page: 'current' }).every(function () { var strip0 =1; var sigfig =1; var sum = this .data() .reduce(function (a, b) { var x = parseFloat($(''+a+'').text()) || 0; //encase it so html is always stripped var y = parseFloat($(''+b+'').text()) || 0; if (y!='') { ct++; } return x + y; }, 0); var rowCt = ct; ct=0; // Update footer if (rowCt==0) { sum='-'; sumAlt='-'; }else{ sum = parseFloat(sum).toFixed(4) sumAlt = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) if (strip0==1){ sumAlt = sumAlt.replace(/^(0\.)/,'.'); } } if (rowCt==0 && seaCt>1 && !1*1) { ave = '
-'; }else if (seaCt>1 && !1*1) { ave = parseFloat(sum/(rowCt+.000001)).toFixed(sigfig) ; if (strip0==1){ ave = ave.replace(/^(0\.)/,'.'); } ave = '
'+ ave ; }else{ ave = ''; //dont show second row when there's only 1 season } sum = parseInt(sum); $(this.footer()).html(sum + ave ); }); //dont really use these anymore because two-rowed footer code above places average after the sum //other columns are autocalculated based for average or sum based on class tag // api.columns('.sumonly', { page: 'current' }).every(function (rowIdx, tableLoop, rowLoop) { // var sum = this // .data() // .reduce(function (a, b) { // var x = parseFloat(a) || 0; // var y = parseFloat(b) || 0; // return x + y; // }, 0); // //console.log(sum); // // Update footer // $(this.footer()).html(parseFloat(sum).toFixed(0) ); // }); // api.columns('.avg3', { page: 'current' }).every(function () { // var sum = this // .data() // .reduce(function (a, b) { // var x = parseFloat(a) || 0; // var y = parseFloat(b) || 0; // if (b!='') { // ct++; // } // return x + y; // }, 0); // var rowCt = ct; // ct=0; // //console.log('=='+sum+'/'+ct+'/'+rowCt); // // Update footer // $(this.footer()).html( parseFloat(sum/(rowCt+.000001)).toFixed(3).replace('0.','.') ); // }); //api.fixedHeader.adjust(); }, buttons: [ // ========================================================== // Build VIEWS dropdown menu // ========================================================== // // ========================================================== // Build SPLITS dropdown menu // ========================================================== // { // extend: 'collection', // text: " Splits", // fade: 0, // autoClose: true, // buttons: // [ // // ] // }, // ========================================================== // Build COLUMN visibility dropdown menu // ========================================================== // checkboxes at // https://infra.clarin.eu/content/libs/DataTables-1.10.4/extensions/ColVis/examples/text.html // { extend: 'colvis', fade: 0, className: 'btn-group-child pull-left', //collectionLayout: 'fixed two-column', columns: ":not(.notInMenu)", //':gt(0)', titleAttr: 'Hide/Show Columns', text: "Columns" }, // ========================================================== // Build EXPORT/SHARE dropdown menu // ========================================================== // { extend: "collection", text: "Share", fade: 0, titleAttr: 'Export Table to another location', className: 'btn-group-child', autoClose: true, buttons: [ { extend: 'copy', className: 'pullLeft', messageTop: 'RetroSeasons Data', messageBottom: "https://www.retroseasons.com/teams/cleveland-cavaliers/history/general-managers/", header: true, footer: true, text: "Copy/Paste", key: { key: 'c', ctrlKey: true, }, exportOptions: { columns: ':visible' }, }, { extend: 'csv', className: 'pullLeft', title: "retroseasons-teams-cleveland-cavaliers-history-general-managers-export", messageBottom: "https://www.retroseasons.com/teams/cleveland-cavaliers/history/general-managers/", messageTop: "This data was exported from https://www.retroseasons.com", text: "Download", titleAttr: 'Download Stats', header: true, footer: true, key: { key: 'x', ctrlKey: true, }, exportOptions: { columns: ':visible' }, }, // { // text: " Facebook Share", // titleAttr: 'Share Page', // }, // { // text: " Share Page", // titleAttr: 'Share Page', // }, // { // text: " Embed Table", // titleAttr: 'Embed Table', // }, ] }, // ========================================================== // Build FILTERS dropdown menu // ========================================================== // { extend: "collection", text: "Filter", autoClose: true, titleAttr: 'Filter statistics to show a subset of data', className: 'btn-group-child', fade: 0, buttons: [ // ========================================================== // FILTER paramater variables are set on each page depending on data // ========================================================== { className: "pullLeft", text: " Championships ", action: function ( e, dt, node, config ) { $('.champs').remove(); $('#crumbCell').append('Champs '); table.columns('champs:name').search('^[1-9]+', true, false).draw(); } }, { className: "pullLeft", text: " Playoff Appearances ", action: function ( e, dt, node, config ) { $('.playoffs').remove(); $('#crumbCell').append('Playoffs '); table.columns('playoffs:name').search('^[1-9]+', true, false).draw(); } }, { className: "pullLeft", text: " 5+ years tenure ", action: function ( e, dt, node, config ) { $('.tenure').remove(); $('#crumbCell').append('5+ years '); table.columns('tenure:name').search('^([5-9]|[0-9]{2,})$', true, false).draw(); } }, { className: "pullLeft", text: " Over .500 ", action: function ( e, dt, node, config ) { $('.winningPct').remove(); $('#crumbCell').append('Over .500 '); table.columns('winningPct:name').search('^\.5|^\.6|^\.7|^\.8|^\.9|^1\.', true, false).draw(); } }, { className: "pullLeft", text: " Under .500 ", action: function ( e, dt, node, config ) { $('.winningPct').remove(); $('#crumbCell').append('Under .500 '); table.columns('winningPct:name').search('^\.0|^\.1|^\.2|^\.3|^\.4', true, false).draw(); } }, ] }, //end of collection dropdown menu ], }); //redraws header/footer on colviz changes so that its correctly formatted jQuery('#mainTable').on( 'column-visibility.dt', function ( e, settings, column, state ) { //console.log( 'Column '+ column +' has changed to '+ (state ? 'visible' : 'hidden') ); table.fixedHeader.adjust(); } ); jQuery('#mainTable').show(); // ================================================================= // draw table filtering fields to allow filtering of ranges // (this technique is then piggybacked by the range slider) // ================================================================= jQuery.fn.dataTable.ext.search.push( function( settings, data, dataIndex ) { var min = parseInt( jQuery('#slider-min').val(), 10 ); var max = parseInt( jQuery('#slider-max').val(), 10 ); var age = parseFloat( data[0] ) || 0; // use data for the age column if ( ( isNaN( min ) && isNaN( max ) ) || ( isNaN( min ) && age <= max ) || ( min <= age && isNaN( max ) ) || ( min <= age && age <= max ) ) { return true; } return false; } ); // ================================================================= // Event listener to the two range filtering inputs to redraw on input. // don't really need this anymore, since they're hidden and // i'm triggering redraw on slider but leaving it here for legacy // ================================================================= jQuery('#slider-min, #slider-max').change( function() { table.draw(); } ); // ================================================================= // Avtandil mod: throttle slide change events // ================================================================= var throttle_inst = null; var throttle = function( wait, func, options) { var context, args, result; var timeout = null; var previous = 0; if (!options) options = {}; var later = function() { previous = options.leading === false ? 0 : Date.now(); timeout = null; result = func.apply(context, args); if (!timeout) context = args = null; }; return function() { var now = Date.now(); if (!previous && options.leading === false) previous = now; var remaining = wait - (now - previous); context = this; args = arguments; if (remaining <= 0 || remaining > wait) { if (timeout) { clearTimeout(timeout); timeout = null; } previous = now; result = func.apply(context, args); if (!timeout) context = args = null; } else if (!timeout && options.trailing !== false) { timeout = setTimeout(later, remaining); } return result; }; } var update_model_throttle = function() { if (null === throttle_inst) { throttle_inst = throttle(500, function(){ demo._handleSliderChange(); }); } throttle_inst(); } // ================================================================= // Avtandil End: throttle slide change events // ================================================================= // ================================================================= // set config parameters for slider range // http://ionden.com/a/plugins/ion.rangeSlider/demo_interactions.html // ================================================================= var $range = jQuery("#slider-range"); jQuery(function () { $range.ionRangeSlider({ type: 'double', step: 1, min: 1971, max: 2025, from: 1971, to: 2021, from_min: 1971, to_min: 1971, from_max: 2021, to_max: 2021, hide_min_max: false, keyboard: false, from_shadow:true, grid: false, skin: "round", // skin: "big", force_edges: true, drag_interval: true, prettify_enabled: false }); }); $('div.dataTables_filter input').addClass('focus:border-blue-500 focus:border-2'); // <-- add this line $('div.dataTables_filter input').addClass('rounded rounded-lg border border-gray-400'); // <-- add this line $('div.dataTables_filter input').addClass('text-black'); // <-- add this line // ================================================================= // change min/max input fields and redraw table when slider changes // ================================================================= $range.on("change", function () { var $this = $(this), value = $this.prop("value").split(";"); //console.log(value[0] + " - " + value[1]); document.getElementById('slider-min').value=value[0]; document.getElementById('slider-max').value=value[1]; table.draw(); }); //fixedHeader.adjust(); //breaks wordpress table.draw(); $('#crumbCell').html(' General Managers '); } );