PageSourceSearch

https://freshup.space/assets/js/angular/controllers/commonCtrl.js?r=1790258009

js freshup.space collected 2026-09-24 13:54:43 UTC 12,484 bytes, 330 lines download raw bytes

1app.controller("commonCtrl", function ($scope, $timeout, $http, createReservationService, loaderService, appBrowser) {
2// alert(appBrowser.getVersion());
3
4
5    var browserError = "\
6<div class='browserError'>\
7<strong>\
8Your browser (" + appBrowser.getName() + " " + appBrowser.getVersion() + ") does not support this application!\
9</strong>\
10<p>Please update your browser now.</p>\
11</div>\
12";
13
14
15    if (appBrowser.getName() == "safari" && appBrowser.getVersion() < 10) {
16        $("body").html(browserError);
17    }
18
19    if (appBrowser.getName() == "msie" && appBrowser.getVersion() < 11) {
20        $("body").html(browserError);
21    }
22
23
24    if (appBrowser.getName() == "chrome" && appBrowser.getVersion() < 29) {
25        $("body").html(browserError);
26    }
27
28
29    if (appBrowser.getName() == "mozilla" && appBrowser.getVersion() < 22) {
30        $("body").html(browserError);
31    }
32
33    setInterval(function () {
34        if (window.localStorage.getItem("token") != null) {
35//            console.log($scope.isLoggedIn);
36            $scope.isLoggedIn = true;
37            $scope.$apply();
38        }
39    }, 5000);
40
41    $scope.doLogout = function () {
42        window.localStorage.removeItem("token");
43        loaderService.getLoading();
44        setTimeout(function () {
45            window.location.href = baseurl + "logout";
46        }, 1000);
47    };
48
49    // Notifications code Start Here ++++++++++++++++++++++++++++++
50    $scope.notyDisplay = false;
51    $scope.noty = function (type, title, message) {
52        $scope.notyDisplay = true;
53        $scope.notyType = type;
54        $scope.notyTitle = title;
55        $scope.notyMessage = message;
56        $timeout(function () {
57            $scope.notyDisplay = false;
58        }, 3000);
59    };
60    
61    // Notifications code ends Here ++++++++++++++++++++++++++++++
62    // Alertbox code starts Here ++++++++++++++++++++++++++++++
63    $scope.sweetyDisplay = false;
64    $scope.sweety = function (title, yesFn) {
65        $scope.sweetyDisplay = true;
66        $scope.sweetyTitle = title;
67        $scope.action = function (id) {
68            if (id === true) {
69                $scope.type = yesFn;
70                $scope.type();
71                $scope.sweetyDisplay = false;
72            } else {
73                $scope.sweetyDisplay = false;
74            }
75        };
76    };
77    
78    // Alertbox code ends Here ++++++++++++++++++++++++++++++
79    // spinner code starts Here ++++++++++++++++++++++++++++++
80    $scope.spinny = function (state) {
81        $scope.spinnyLoader = false;
82        if (state == true) {
83            $scope.spinnyLoader = true;
84        } else {
85            $scope.spinnyLoader = false;
86        }
87    };
88    
89    // spinner code ends Here ++++++++++++++++++++++++++++++
90    app.directive("filesInput", function () {
91        return {
92            require: "ngModel",
93            link: function postLink(scope, elem, attrs, ngModel) {
94                elem.on("change", function (e) {
95                    var files = elem[0].files;
96                    ngModel.$setViewValue(files);
97                });
98            }
99        };
100    });
101    $scope.tags = [{
102            text: '[email protected]'
103        }, {
104            text: '[email protected]'
105        }];
106    $scope.convertTagsInputObjectToString = function (obj) {
107//        console.log(obj);
108        var $str = "";
109        for (var $i = 0; $i < obj.length; $i++) {
110            $str += obj[$i].text + ",";
111        }
112        $str = $str.slice(0, -1);
113        return $str;
114    };
115    $scope.hasPermission = function (id) {
116        for (var i = 0; i < $scope.permission_enabled_modules.length; i++) {
117            if ($scope.permission_enabled_modules[i] === id) {
118                return true;
119            }
120        }
121    };
122
123    $scope.UpdateCityDetails = function (cityObj, selecteCenterId) {
124        for (var i = 0; i < cityObj.length; i++) {
125            if (cityObj[i].center_code == selecteCenterId) {
126                $scope.city_details = cityObj[i];
127            }
128        }
129    };
130
131
132    $(document).on("blur", "#check_in_date", function () {
133        var arr = $("#search_form").serializeArray();
134//        console.log(arr[0].value);
135        $scope.CheckCenterStatus($(this).val(), arr[0].value);
136    });
137    function initializeAvailabilitySearchObject() {
138        $scope.availabilitySearchObj = {
139            check_in_date: '',
140            check_in_time: '',
141            duration: '',
142            persons: ''
143        };
144    }
145    initializeAvailabilitySearchObject();
146
147    $scope.CheckCenterStatus = function (selected_date, centers_id) {
148        //console.log($scope.search);
149        var selected_time;
150        if (selected_date.length > 0) {
151            selected_time = selected_date.substring(11);
152            selected_date = selected_date.substring(0, 10);
153        }
154        if (selected_time === undefined) {
155            return;
156        }
157
158        $scope.availabilitySearchObj.centers_id = centers_id;
159        $scope.availabilitySearchObj.availability_type = 1;
160        $scope.availabilitySearchObj.staying_types_id = 2;
161        $scope.availabilitySearchObj.check_in_date = selected_date;
162        $scope.availabilitySearchObj.check_in_time = selected_time;
163        $scope.availabilitySearchObj.duration = 3;
164        $scope.availabilitySearchObj.persons = 1;
165        //loaderService.getLoading();
166        createReservationService.getStayAvailabilityByCentersId($scope.availabilitySearchObj).then(function (response) {
167            loaderService.closeLoading();
168            if (response.data.err_code === "valid") {
169
170            } else if (response.data.err_code === "invalid_form") {
171                //$scope.noty('warning', response.data.title, response.data.message);
172            } else if (response.data.err_code === "invalid") {
173                if (angular.isDefined(response.data.err_type)) {
174                    $scope.unavailabilityObjMessage = response.data.message;
175                    angular.element("#bookingFormMessage").modal("show");
176                }
177                //  $scope.noty('warning', response.data.title, response.data.message);
178            }
179        });
180
181    };
182
183    // Multiselect code starts Here ++++++++++++++++++++++++++++++
184
185    app.directive("selectbox", function () {
186        return {
187            restrict: 'EA',
188            template: "<input type='text' />"
189        };
190    });
191
192    // Multiselect code ends Here ++++++++++++++++++++++++++++++
193
194
195
196    //geo location code starts here
197    $scope.getLocation = function () {
198
199        if (navigator.geolocation) {
200
201        } else {
202            swal("Oops", "Geolocation is not supported by this browser.", 'error');
203            return;
204        }
205
206        navigator.geolocation.getCurrentPosition(function (position) {
207//            console.log(position);
208            var coords = position.coords;
209
210            localStorage.setItem("currentLocationLat", coords.latitude);
211            localStorage.setItem("currentLocationLng", coords.longitude);
212
213            localStorage.getItem("currentLocationLat");
214            localStorage.getItem("currentLocationLng");
215            var latLng = new google.maps.LatLng(localStorage.getItem("currentLocationLat"), localStorage.getItem("currentLocationLng"));
216            var geocoder = new google.maps.Geocoder;
217            geocodeLatLng(geocoder, latLng);
218        }, function (error) {
219            console.error(`ERROR(${error.code}): ${error.message}`);
220//            alert(error.code);
221//            swal("oops", error.message, 'error');
222        });
223    };
224    $scope.getLocation();
225
226
227    function geocodeLatLng(geocoder, latLng) {
228//        console.trace();
229//        console.log(latLng);
230        geocoder.geocode({
231            'location': latLng,
232        }, function (results, status) {
233            if (status === 'OK') {
234                if (results[0]) {
235//                    console.log(results[0]);
236                    /*$scope.customerAddress.address = results[0].formatted_address;
237                     $scope.customerAddress.latitude = latLng.lat();
238                     $scope.customerAddress.longitude = latLng.lng();
239                     $scope.customerAddress.name = results[0].address_components[1].long_name;
240                     $scope.customerAddress.location = results[0].address_components[1].long_name;*/
241                    $scope.$apply();
242                } else {
243                    swal("oops", "No results found", 'error');
244                }
245            } else {
246                swal("oops", 'Geocoder failed due to: ' + status, 'error');
247            }
248        });
249    }
250
251
252    var geocoder = new google.maps.Geocoder;
253    //Create the search box and link it to the UI element.
254    const options = {
255        componentRestrictions: {country: "in"}
256    };
257
258    var fromLocationInput = document.getElementsByClassName('from-location-pac-input')[0];
259    var fromLocationSearchBox = new google.maps.places.Autocomplete(fromLocationInput, options);
260    // Listen for the event fired when the user selects a prediction and retrieve
261    // more details for that place.
262    fromLocationSearchBox.addListener('place_changed', function () {
263        var place = fromLocationSearchBox.getPlace();
264//        console.log(place);
265        if (!place.geometry) {
266            console.log("Returned place contains no geometry");
267            return;
268        }
269        var latLng = place.geometry.location;
270        localStorage.setItem("fromLat", latLng.lat());
271        localStorage.setItem("fromLng", latLng.lng());
272        localStorage.setItem("fromLocationName", place.name);
273        localStorage.setItem("fromLocationNameFormated", place.formatted_address);
274    });
275
276
277    var toLocationInput = document.getElementsByClassName('to-location-pac-input')[0];
278    var toLocationSearchBox = new google.maps.places.Autocomplete(toLocationInput, options);
279    // Listen for the event fired when the user selects a prediction and retrieve
280    // more details for that place.
281    toLocationSearchBox.addListener('place_changed', function () {
282        var place = toLocationSearchBox.getPlace();
283        if (!place.geometry) {
284            console.log("Returned place contains no geometry");
285            return;
286        }
287        var latLng = place.geometry.location;
288        localStorage.setItem("toLat", latLng.lat());
289        localStorage.setItem("toLng", latLng.lng());
290        localStorage.setItem("toLocationName", place.name);
291        localStorage.setItem("toLocationNameFormated", place.formatted_address);
292    });
293
294
295    var locationInput = document.getElementsByClassName('from-location-pac-input-stay-execlusive')[0];
296    var locationSearchBox = new google.maps.places.Autocomplete(locationInput, options);
297
298    locationSearchBox.addListener('place_changed', function () {
299        var place = locationSearchBox.getPlace();
300//        console.log(place);
301        if (!place.geometry) {
302            console.log("Returned place contains no geometry");
303            return;
304        }
305        var latLng = place.geometry.location;
306        localStorage.setItem("stayExclusiveFromLat", latLng.lat());
307        localStorage.setItem("stayExclusiveFromLng", latLng.lng());
308        localStorage.setItem("stayExclusiveFromLocationName", place.name);
309        localStorage.setItem("stayExclusiveFromLocationNameFormated", place.formatted_address);
310    });
311    var locationInputModel = document.getElementsByClassName('from-location-pac-input-stay-execlusive-model')[0];
312    var locationSearchBoxModel = new google.maps.places.Autocomplete(locationInputModel, options);
313
314    locationSearchBoxModel.addListener('place_changed', function () {
315        var place = locationSearchBox.getPlace();
316        console.log(place);
317        if (!place.geometry) {
318            console.log("Returned place contains no geometry");
319            return;
320        }
321        //alert();
322        var latLng = place.geometry.location;
323        localStorage.setItem("stayExclusiveFromLat", latLng.lat());
324        localStorage.setItem("stayExclusiveFromLng", latLng.lng());
325        localStorage.setItem("stayExclusiveFromLocationName", place.name);
326        localStorage.setItem("stayExclusiveFromLocationNameFormated", place.formatted_address);
327    });
328
329
330});

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.