PageSourceSearch

https://tarbutu.co.il/wp-content/themes/Avada-child02/js/datatable_custom_discount.js

js tarbutu.co.il collected 2026-10-02 22:49:25 UTC 9,435 bytes, 192 lines download raw bytes

1jQuery(document).ready(function($) {
2
3/* Creating Select boxes for every column code starts here */
4console.log("ppp");
5var table =  $('#discount_example').DataTable( {
6        initComplete: function () {
7            this.api().columns([0,1, 2, 3, 4, 5]).every( function () {
8                var column = this;
9                var select = $('<select></select>')
10                    .appendTo( $(column.footer()).empty() )
11                    .on( 'change', function () {
12                        var val = $.fn.dataTable.util.escapeRegex(
13                            $(this).val());
14                        column
15                            .search( val ? '^'+val+'$' : '', true, false )
16                            .draw();
17                    } );
18
19                    var sel_loop = 0;
20		                column.data().unique().sort().each( function ( d, j ) {
21		                  sel_loop++;
22		                  if(sel_loop == 1)
23		                  {
24		                  	 select.append( '<option data-test="test1" value="'+d+'">הכל</option>' )
25		                    select.append( '<option data-test="test1" value="'+d+'">'+d+'</option>' )
26		                  } 
27		                  else
28		                  {
29		                    select.append( '<option data-test="test2" value="'+d+'">'+d+'  </option>' )                    
30		                  }
31                } );
32
33		        // Number of days HTML starts here         
34                  $("#discount_example_wrapper .number_days").html("<select><option  data-test='test3' value=''>הכל</option><option value='1-6'>1-6</option><option value='7-10'>7-10</option><option value='11-15'>11-15</option><option value='16-20'>16-20</option><option value='21-25'>21-25</option><option value='26-99'>26-99</option></select>");
35                // Number of days HTML ends here         
36
37            } );
38
39				 /* FOR DATES (OUTPUT) COLUMN 3, MONTH VALUE CODE STARTS HERE   */
40				 var colMonthArr = [];
41				 this.api().columns([3]).every( function () {
42				              var column = this;
43				              var select = $('<select><option  data-test="test3" value="">הכל</option></select>')
44				                  .appendTo( $(column.footer()).empty() )
45				                  .on( 'change', function () {
46				                      var val = $.fn.dataTable.util.escapeRegex(
47				                          $(this).val());
48				                      if(val) {
49				                        var val_month = '-'+val+'-';
50				                      } else {
51				                        var val_month = '';
52				                      }
53				                      column
54				                          .search( val_month )
55				                          .draw();
56				                  } );
57
58				              column.data().unique().sort().each( function ( d, j ) {
59				                  var d_arr = d.split(', ');
60				                  if(d_arr[0]) {
61				                    $.each(d_arr, function(key, value){
62				                      var rest_month = value.split('-');
63				                      if(colMonthArr.indexOf(rest_month[1]) === -1) {
64				                        colMonthArr.push(rest_month[1]);
65
66				                        if(rest_month[1] == 01) {
67				                          var rest_month_html = "ינואר";
68				                        } else if(rest_month[1] == 02) {
69				                          var rest_month_html = "פברואר";
70				                        } else if(rest_month[1] == 03) {
71				                          var rest_month_html = "מרץ";
72				                        } else if(rest_month[1] == 04) {
73				                          var rest_month_html = "אפריל";
74				                        } else if(rest_month[1] == 05) {
75				                          var rest_month_html = "מאי";
76				                        } else if(rest_month[1] == 06) {
77				                          var rest_month_html = "יוני";
78				                        } else if(rest_month[1] == 07){
79				                          var rest_month_html = "יולי";
80				                        } else if(rest_month[1] == 08) {
81				                          var rest_month_html = "אוגוסט";
82				                        } else if(rest_month[1] == 09) {
83				                          var rest_month_html = "ספטמבר";
84				                        } else if(rest_month[1] == 10) {
85				                          var rest_month_html = "אוקטובר";
86				                        } else if(rest_month[1] == 11) {
87				                          var rest_month_html = "נובמבר";
88				                        } else if(rest_month[1] == 12) {
89				                          var rest_month_html = "דצמבר";
90				                        }
91				                        select.append( '<option value="'+rest_month[1]+'">'+rest_month_html+'</option>' );
92				                      }
93				                    });
94				                  }
95				              } );
96				});
97				/* FOR DATES (OUTPUT) COLUMN 3, MONTH VALUE CODE ENDS HERE   */
98				
99 /* FOR DATES (OUTPUT) COLUMN 5, MONTH VALUE CODE STARTS HERE   */
100				 var colMonthArr = [];
101				 this.api().columns([5]).every( function () {
102				              var column = this;
103				              var select = $('<select><option  data-test="test4" value="">הכל</option></select>')
104				                  .appendTo( $(column.footer()).empty() )
105				                  .on( 'change', function () {
106				                      var val = $.fn.dataTable.util.escapeRegex(
107				                          $(this).val());
108				                      if(val) {
109				                        var val_month = '-'+val+'-';
110				                      } else {
111				                        var val_month = '';
112				                      }
113				                      column
114				                          .search( val_month )
115				                          .draw();
116				                  } );
117
118				              column.data().unique().sort().each( function ( d, j ) {
119				                  var d_arr = d.split(', ');
120				                  if(d_arr[0]) {
121				                    $.each(d_arr, function(key, value){
122				                      var rest_month = value.split('-');
123				                      if(colMonthArr.indexOf(rest_month[1]) === -1) {
124				                        colMonthArr.push(rest_month[1]);
125
126				                        if(rest_month[1] == 01) {
127				                          var rest_month_html = "ינואר";
128				                        } else if(rest_month[1] == 02) {
129				                          var rest_month_html = "פברואר";
130				                        } else if(rest_month[1] == 03) {
131				                          var rest_month_html = "מרץ";
132				                        } else if(rest_month[1] == 04) {
133				                          var rest_month_html = "אפריל";
134				                        } else if(rest_month[1] == 05) {
135				                          var rest_month_html = "מאי";
136				                        } else if(rest_month[1] == 06) {
137				                          var rest_month_html = "יוני";
138				                        } else if(rest_month[1] == 07){
139				                          var rest_month_html = "יולי";
140				                        } else if(rest_month[1] == 08) {
141				                          var rest_month_html = "אוגוסט";
142				                        } else if(rest_month[1] == 09) {
143				                          var rest_month_html = "ספטמבר";
144				                        } else if(rest_month[1] == 10) {
145				                          var rest_month_html = "אוקטובר";
146				                        } else if(rest_month[1] == 11) {
147				                          var rest_month_html = "נובמבר";
148				                        } else if(rest_month[1] == 12) {
149				                          var rest_month_html = "דצמבר";
150				                        }
151				                        select.append( '<option  data-test="test5" value="'+rest_month[1]+'">'+rest_month_html+'</option>' );
152				                      }
153				                    });
154				                  }
155				              } );
156				});
157				/* FOR DATES (OUTPUT) COLUMN 5, MONTH VALUE CODE ENDS HERE   */
158        },
159      "pageLength": 100
160    } );
161
162  table.draw();
163/* Creating Select boxes for every column code ends here */
164
165
166 $(document).on("change", "#discount_example_wrapper .number_days select", function(){
167                    var selected_days = $(this).val();
168                     var daysArray = new Array();
169                    daysArray = selected_days.split("-");
170                    days_1 = daysArray[0];
171                    days_2 = daysArray[1];
172                          $.fn.dataTable.ext.search.push(
173                        function( settings, data, dataIndex ) {
174                            var min = days_1;
175                            var max = days_2;
176                            var age = parseFloat( data[2] ) || 0; // use data for the age column
177
178                            if ( ( isNaN( min ) && isNaN( max ) ) ||
179                                 ( isNaN( min ) && age <= max ) ||
180                                 ( min <= age   && isNaN( max ) ) ||
181                                 ( min <= age   && age <= max ) ) 
182                            {
183                                return true;
184                            }
185                            return false;
186                        }
187                    );   
188                    table.draw();
189                });
190
191
192});

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.