PageSourceSearch

https://www.imperial-rac.com/wp-content/plugins/ng-filter/assets/js/atmf-app.js?ver=7.1.2

js imperial-rac.com collected 2026-10-04 02:41:37 UTC 13,636 bytes, 519 lines download raw bytes

1
2 var Atmf = angular.module('atmf',['ngSanitize','ui.bootstrap','angularUtils.directives.dirPagination','angular-loading-bar']);
3
4
5    Atmf.filter('html',function($sce){
6        return function(input){
7            return $sce.trustAsHtml(input);
8        }
9    });
10
11
12    Atmf.filter('orderObjectBy', function() {
13
14        return function(items, field, reverse) {
15            
16            var filtered = [];
17            angular.forEach(items, function(item) {
18                filtered.push(item);
19            });
20
21            filtered.sort(function (a, b) {
22                return (a.charAt(0).toLowerCase() > b.charAt(0).toLowerCase() ? 1 : -1);
23            });
24
25            if(reverse) filtered.reverse();
26                return filtered;
27        };
28
29    });
30
31
32
33
34    Atmf.directive("slider", function() {
35        return {
36            restrict: 'A',
37            scope: {
38                start: "=",
39                end : "=",
40                min : "=",
41                max:  "=",
42                key : "=",
43                onchnage : "&",
44                onend : "&",
45
46            },
47
48            link: function(scope, elem, attrs ) {
49
50                jQuery(elem).slider({
51                    range: true ,
52                    min: parseInt(scope.min),
53                    max: parseInt(scope.max),
54                    values: [ scope.start , scope.end ],
55            
56                    slide: function(event, ui) { 
57                        scope.$apply(function() {
58                            scope.start = ui.values[0];
59                            scope.end = ui.values[1];
60                            scope.onchnage( scope.key , ui.values[0] , ui.values[1] );
61                        });
62                    },
63                    stop: function( event, ui ) {
64                        scope.$apply(function(){
65                            scope.onend();    
66                        });
67                    }
68                });
69            }
70        }
71    });
72
73
74
75    Atmf.config(['cfpLoadingBarProvider', function( cfpLoadingBarProvider ) {
76         cfpLoadingBarProvider.includeSpinner = false;
77    }]);
78
79
80
81
82    Atmf.controller('AtmfFrontEnd', ['$scope','$filter','$http', '$location', function( $scope , $filter , $http,$location ){
83
84
85   // var search_page =  JSON.parse(angular.element('#dso').text());
86
87
88
89    var loc_data = $location.search();
90    
91    var loc_length = Object.keys(loc_data).length;
92
93    if (loc_length > 0) {
94
95        do_url_search(loc_data);
96    }
97
98
99
100   
101
102
103
104    if(  angular.isDefined(search_page) ){      
105
106        $scope.list =  search_page.metadata.list;
107        $scope.seachPostType = search_page.metadata.search_post_type;
108        $scope.postsPerPage = search_page.metadata.post_per_page;
109        $scope.contentLimit = search_page.metadata.contentLimit;
110        $scope.sortData = search_page.metadata.sort_meta;
111    }
112
113	$scope.formData = {};
114	$scope.formMeta = {};
115
116    $scope.addTometa = function(key, start , end){
117      
118        $scope.formMeta[key] = {
119            start : start , 
120            end  : end
121        }
122    }
123
124	if( angular.isObject(search_page.post) ){
125
126		$scope.posts = search_page.post;
127        $scope.totalItems = $scope.posts.length;        
128        
129        // @all for sorting purpose start
130        $scope.options = [];
131
132        var title = {
133            'name' :'Sort By',
134            'value' : 'post_id' 
135        }
136        $scope.options.push(title);
137
138        if(atmf.default_option){
139            var default_sort = {
140                'name' : atmf.default_option.replace(/_/g,' '),
141                'value' : atmf.default_option 
142            }
143            $scope.options.push(default_sort); 
144        }
145         
146
147        if(atmf.option_data.indexOf('post_title') > -1){
148            var title = {
149                'name' :'Title',
150                'value' : 'post_title' 
151            }
152            $scope.options.push(title);
153        }       
154
155        if(atmf.option_data.indexOf('post_id') > -1){
156            var id = {
157                'name' :'ID',
158                'value' : 'post_id' 
159            }
160            $scope.options.push(id);
161        }
162
163        if(atmf.option_data.indexOf('price') > -1){
164            var price = {
165                'name' :'Price',
166                'value' : 'price' 
167            }
168            $scope.options.push(price);
169        }
170
171        if(atmf.option_data.indexOf('max_speed') > -1){
172            var max_speed = {
173                'name' :'Speed',
174                'value' : 'max_speed' 
175            }
176            $scope.options.push(max_speed);
177        }
178
179        if(atmf.option_data.indexOf('additional_people') > -1){
180            var additional_people = {
181                'name' :'Person',
182                'value' : 'additional_people' 
183            }
184            $scope.options.push(additional_people);
185        }
186
187        if(atmf.option_data.indexOf('post_date') > -1){
188            var post_date = {
189                'name' :'Date',
190                'value' : 'post_date' 
191            }
192            $scope.options.push(post_date);
193        }        
194
195        if(atmf.option_data.indexOf('fuel_capacity') > -1){
196            var fuel_capacity = {
197                'name' :'Fuel',
198                'value' : 'fuel_capacity' 
199            }
200            $scope.options.push(fuel_capacity);
201        }
202
203        if(atmf.option_data.indexOf('max_weight') > -1){
204            var max_weight = {
205                'name' :'Weight',
206                'value' : 'max_weight' 
207            }
208            $scope.options.push(max_weight);
209        }
210
211        if(atmf.option_data.indexOf('min_pilots') > -1){
212            var min_pilots = {
213                'name' :'Drivers',
214                'value' : 'min_pilots' 
215            }
216            $scope.options.push(min_pilots);
217        }
218
219        if(atmf.option_data.indexOf('vehicle_age') > -1){
220            var vehicle_age = {
221                'name' :'Age',
222                'value' : 'vehicle_age' 
223            }
224            $scope.options.push(vehicle_age);
225        }       
226
227        console.log($scope); 
228
229        $scope.orderByData=  $scope.options[1].value;
230        $scope.orderByTitle=  $scope.options[2].value;
231
232        // @all for sorting purpose start
233
234	}
235
236
237
238    function do_url_search(loc_data){
239
240        $scope.filterData = {};
241        $scope.filterData.alltaxonomies = {};
242
243        if(loc_data.pickUpDate != undefined){
244            $scope.filterData.hireon = loc_data.pickUpDate;           
245        }
246
247        if(loc_data.returnDate != undefined){
248            $scope.filterData.returnon = loc_data.returnDate;      
249        }
250
251        if(loc_data.type != undefined){
252            $scope.filterData.alltaxonomies['reservation_type'] = loc_data.type;             
253        }      
254
255        if(loc_data.location != undefined){
256            $scope.filterData.alltaxonomies[loc_data.locationTax] = loc_data.location;             
257        }
258
259        if(loc_data.returnLocation != undefined){
260            $scope.filterData.alltaxonomies[loc_data.returnLocationTax] = loc_data.returnLocation;             
261        }
262
263        if(loc_data.carType != undefined){
264            $scope.filterData.alltaxonomies[loc_data.carTypeTax] = loc_data.carType;             
265        }
266
267        if(loc_data.reservationTypeTax != undefined){
268            $scope.filterData.alltaxonomies[loc_data.reservationTypeTax] = loc_data.searchTerm;            
269        }
270
271        $scope.filterData.post_type = search_page.metadata.search_post_type;
272        $scope.filterData.sort_meta = search_page.metadata.sort_meta;
273
274        $scope.loading = true;
275
276         
277
278        $http({
279
280            method: 'POST',
281            url: atmf.ajaxurl+'?action=atmf_do_filter_url' ,
282            data: jQuery.param({ 'filter': $scope.filterData }),
283            headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
284            
285        }).then(function(e){ 
286            console.log(loc_data);    
287            $scope.posts = [];
288            $scope.posts = e.data;
289            $scope.hireonDate   = loc_data.pickUpDate;
290            $scope.hireonTime   = loc_data.pickUpTime;
291            $scope.returnDate   = loc_data.returnDate;
292            $scope.returnTime   = loc_data.returnTime;
293            $scope.pickUpCity   = loc_data.pickUpCity;
294            $scope.pickupArae   = loc_data.location;
295            $scope.retrunCity   = loc_data.returnCity;
296            $scope.returnArea   = loc_data.returnLocation;
297            $scope.totalItems   = $scope.posts.length;
298            $scope.loading      = false;
299
300            //$location.url($location.path());
301        });
302
303
304    }
305
306
307
308    $scope.save_date = function($event, post_id , hireon , hireontime, returnon, returntime, pickupCity, pickupArea, returnCity, returnArea, permalink){
309
310       
311
312        $scope.saveDate = {}; 
313
314        $scope.saveDate = {
315            'arrival_date' : hireon,
316            'arrival_time' : hireontime,
317            'departure_date' : returnon,
318            'departure_time': returntime,
319            'post_id' : post_id,
320            'pickupcity': pickupCity,
321            'pickuparea' : pickupArea,
322            'retruncity' : returnCity,
323            'returnarea' : returnArea,
324        }
325
326
327        $http({
328            method: 'POST',
329            url: atmf.ajaxurl+'?action=atmf_do_save_date' ,
330            data: jQuery.param({ 'save_date': $scope.saveDate }),
331            headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
332        }).then(function(e){
333            window.location.href = permalink;
334        });
335      
336        $event.preventDefault();
337
338    }
339
340
341
342
343
344
345
346    function throughItem(item , id ){
347
348
349        //if( item.parent_taxonomy ){
350
351            angular.forEach( item.alloption , function(option , key){
352
353                if ( $scope.blankarray.indexOf( parseInt(key) ) == -1) {
354                    $scope.blankarray.push( parseInt(key) );
355                }
356
357            });
358
359
360        //}
361
362
363        if( angular.isArray(item.items)){
364            throughItem(item.items[0] , parseInt(id) );
365        }
366
367 
368    }
369
370
371	$scope.selected_taxonomy = [];
372
373	
374	$scope.grabResult = function(scope,model, ngitem){
375
376
377
378		if( model == true && scope.key != undefined ) {
379
380            if ( $scope.selected_taxonomy.indexOf( parseInt(scope.key) ) == -1) {
381                $scope.selected_taxonomy.push( parseInt(scope.key) );
382            }
383
384        }else {
385
386            $scope.blankarray = [];
387            var taxonomy_name = [];
388            if( angular.isArray(ngitem.items) ){
389
390                taxonomy_name.push(ngitem.taxonomy);
391                throughItem( ngitem.items[0] , parseInt(scope.key) );
392
393            }
394           $scope.selected_taxonomy.splice( $scope.selected_taxonomy.indexOf(parseInt(scope.key)  ), 1 );
395
396           angular.forEach( $scope.blankarray , function(blank_key) {
397
398               if(jQuery.inArray(blank_key ,$scope.selected_taxonomy) != -1){
399                   $scope.selected_taxonomy.splice( $scope.selected_taxonomy.indexOf(parseInt(blank_key)  ), 1 );
400               }
401
402               // true / false change in the formdata
403               angular.forEach($scope.formData , function(cat,taxonomy){
404
405                    if( jQuery.inArray(taxonomy ,taxonomy_name) != -1 ){
406
407                        angular.forEach(cat,function(category,category_key){
408
409                            if( category_key == blank_key ){
410
411                                cat[category_key] = false;
412                            }
413                        });
414                    }
415                });
416
417           });
418
419
420
421        }
422
423        $scope.doFilter();
424
425	}
426
427
428
429    $scope.grabDate = function(dateData){
430        
431        console.log(dateData);
432
433        $scope.filterData = {
434            'hireon': dateData.starton_date ,
435            'returnon' : dateData.returnon_date
436        }; 
437
438
439        $scope.filterData.alltaxonomies = {};
440        $scope.filterData.post_type = search_page.metadata.search_post_type;
441        $scope.filterData.sort_meta = search_page.metadata.sort_meta;
442
443        $scope.loading = true;
444
445        $http({
446            method: 'POST',
447            url: atmf.ajaxurl+'?action=atmf_do_filter_url' ,
448            data: jQuery.param({ 'filter': $scope.filterData }),
449            headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
450        }).then(function(e){
451
452            console.log(e);
453            $scope.posts = [];
454            $scope.posts = e.data;
455
456            $scope.totalItems = $scope.posts.length;
457            $scope.loading = false;
458        });
459
460
461    }
462
463
464
465
466
467
468
469    $scope.grabMeta = function(){
470       $scope.doFilter();
471    }
472
473
474    $scope.isObject = function(scope){
475
476	   	if(angular.isObject(scope))
477	   		return true;
478	   	else
479	   		return false;
480    }
481
482
483    $scope.filterData = {};
484
485
486    $scope.doFilter = function(){
487
488    	$scope.filterData.taxonomy = $scope.selected_taxonomy;
489    	$scope.filterData.metadata = $scope.formMeta;
490    	$scope.filterData.alltaxonomies = $scope.formData;
491    	$scope.filterData.post_type = search_page.metadata.search_post_type;
492        $scope.filterData.sort_meta = search_page.metadata.sort_meta;
493
494        $scope.loading = true;
495
496        $http({
497            method: 'POST',
498            url: atmf.ajaxurl+'?action=atmf_do_filter' ,
499            data: jQuery.param({ 'filter': $scope.filterData }),
500            headers : { 'Content-Type': 'application/x-www-form-urlencoded' }
501        }).then(function(e){
502            $scope.posts = [];
503            $scope.posts = e.data;
504
505            $scope.totalItems = $scope.posts.length;
506            $scope.loading = false;
507        });
508    }
509
510    $scope.doReset = function(){
511        location.reload();
512    }
513
514
515    $scope.postView = angular.element("#selectView").val();
516
517}]);
518
519 

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.