@@ -119,62 +119,73 @@ function auto_search($dt){
119119 }
120120}
121121
122- // define a table
123- let table = new DataTable ( '#packageList' , {
124- // get the json file
125- "ajax" : {
126- "url" : "../assets/package-infos.json" ,
127- "dataSrc" : function ( dictData ) {
128- // as the json file is a dict for every package it is necessary it put all values into an array for Datatables to understand it
129- var arr = [ ] ;
130- for ( var key in dictData ) {
131- arr . push ( dictData [ key ] ) ;
122+ // delay until page load
123+ $ ( function ( ) {
124+
125+ // hide the no-javascript version of the table
126+ $ ( '#packageList-no-js' ) . hide ( ) ;
127+
128+ // show the javascript version of the table
129+ $ ( '#packageList' ) . show ( ) ;
130+
131+ // define a table
132+ let table = new DataTable ( '#packageList' , {
133+ // get the json file
134+ "ajax" : {
135+ "url" : "../assets/package-infos.json" ,
136+ "dataSrc" : function ( dictData ) {
137+ // as the json file is a dict for every package it is necessary it put all values into an array for Datatables to understand it
138+ var arr = [ ] ;
139+ for ( var key in dictData ) {
140+ arr . push ( dictData [ key ] ) ;
141+ }
142+ return arr ;
132143 }
133- return arr ;
134- }
135- } ,
136- // define the columns shown in the table
137- columns : [
138- {
139- class : 'dt-control' ,
140- orderable : false ,
141- data : null ,
142- defaultContent : ''
143144 } ,
144- { "data" : "PackageName" } ,
145- { "data" : "Version" , width : '7em' } ,
146- { "data" : "Date" ,
147- render : function ( data , type , row ) {
148- return convertDateFormat ( data )
149- }
145+ // define the columns shown in the table
146+ columns : [
147+ {
148+ class : 'dt-control' ,
149+ orderable : false ,
150+ data : null ,
151+ defaultContent : ''
152+ } ,
153+ { "data" : "PackageName" } ,
154+ { "data" : "Version" , width : '7em' } ,
155+ { "data" : "Date" ,
156+ render : function ( data , type , row ) {
157+ return convertDateFormat ( data )
158+ }
159+ } ,
160+ // the following column is set to invisible and only there so the search picks up the additional text as well
161+ { data : null , render : ( data , type , row ) => format ( data ) , visible : false } ,
162+ { "data" : "Subtitle" } ,
163+ ] ,
164+ // change the text for the search function to make it distinct to the page search function
165+ language : {
166+ search : 'Search table:'
150167 } ,
151- // the following column is set to invisible and only there so the search picks up the additional text as well
152- { data : null , render : ( data , type , row ) => format ( data ) , visible : false } ,
153- { "data" : "Subtitle" } ,
154- ] ,
155- // change the text for the search function to make it distinct to the page search function
156- language : {
157- search : 'Search table:'
158- } ,
159- searchHighlight : true ,
160- initComplete : function ( settings , json ) {
161- auto_search ( this ) ;
162- } ,
163- // set default number of packages shown
164- pageLength : 25 ,
165- } ) ;
166-
167- // Add event listener for opening and closing details
168- table . on ( 'click' , 'td.dt-control' , function ( e ) {
169- let tr = e . target . closest ( 'tr' ) ;
170- let row = table . row ( tr ) ;
168+ searchHighlight : true ,
169+ initComplete : function ( settings , json ) {
170+ auto_search ( this ) ;
171+ } ,
172+ // set default number of packages shown
173+ pageLength : 25 ,
174+ } ) ;
175+
176+ // Add event listener for opening and closing details
177+ table . on ( 'click' , 'td.dt-control' , function ( e ) {
178+ let tr = e . target . closest ( 'tr' ) ;
179+ let row = table . row ( tr ) ;
180+
181+ if ( row . child . isShown ( ) ) {
182+ // This row is already open - close it
183+ row . child . hide ( ) ;
184+ }
185+ else {
186+ // Open this row
187+ row . child ( format ( row . data ( ) ) ) . show ( ) ;
188+ }
189+ } ) ;
171190
172- if ( row . child . isShown ( ) ) {
173- // This row is already open - close it
174- row . child . hide ( ) ;
175- }
176- else {
177- // Open this row
178- row . child ( format ( row . data ( ) ) ) . show ( ) ;
179- }
180191} ) ;
0 commit comments