1import Helpers from './helpers.class.js'; 2 3$(document).ready(function () { 4 5 const helpers = new Helpers(); 6 var changeCityId = 0; 7 var changeCountryId = 0; 8 var changePurpose; 9 var geoId = 0; 10 var geoLink = ''; 11 var searchTimeout = null; 12 13 if(helpers.config("geo_autodetect") && $.cookie("geo-autodetect") != "disabled"){ 14 if ("geolocation" in navigator) { 15 16 $.cookie("geo-autodetect", "disabled", {expires: 30, path: '/'}); 17 18 navigator.geolocation.getCurrentPosition( 19 function (position) { 20 21 helpers.request({url:"geo-coordinates-detect", data: {lat:position.coords.latitude, lon:position.coords.longitude, url:encodeURIComponent(helpers.getUrl())}}, function(data) { 22 23 if(data["status"] == true){ 24 location.reload(); 25 } 26 27 }); 28 29 }, 30 function (error) { 31 } 32 ); 33 34 } 35 } 36 37 $(document).on('click', function(e) { 38 39 if(!$(e.target).closest(".modal-geo-search > input").length && !$(e.target).closest(".modal-geo-search-results").length) { 40 $(".modal-geo-search-results").hide(); 41 } 42 43 if(!$(e.target).closest(".input-geo-search-container > input").length && !$(e.target).closest(".input-geo-search-container-result").length) { 44 $(".input-geo-search-container-result").hide(); 45 } 46 47 e.stopPropagation(); 48 49 }); 50 51 $(document).on('click','.link-geo-item', function (e) { 52 53 var _this = this; 54 geoLink = $(_this).attr("href"); 55 changePurpose = $(_this).data("purpose"); 56 geoId = $(_this).data("id"); 57 58 $(".modal-geo-form input[name=geo_alias]").val(geoLink); 59 60 $(".modal-geo-search-results").hide(); 61 62 if($(_this).data("purpose") == "all"){ 63 64 helpers.hideModal("geoModal"); 65 $(".modal-geo-container-content").html(""); 66 apply(); 67 68 }else{ 69 70 if($(_this).data("purpose") == "city"){ 71 changeCityId = $(_this).data("id"); 72 }else{ 73 changeCityId = 0; 74 } 75 76 helpers.request({url:"geo-change", data: {id:$(_this).data("id"), purpose:$(_this).data("purpose")}}, function(data) { 77 78 if(data["content"]){ 79 80 $(".modal-geo-search > input").val($(_this).html()); 81 $(".modal-geo-container-content").html(data["content"]); 82 83 }else{ 84 85 helpers.hideModal("geoModal"); 86 $(".modal-geo-container-content").html(""); 87 apply(); 88 89 } 90 91 }); 92 93 } 94 95 e.preventDefault(); 96 97 }); 98 99 function apply(){ 100 101 helpers.request({url:"geo-change-options", data: helpers.paramsForm('.live-filters, .modal-geo-form')+"&url="+encodeURIComponent(window.location.pathname)}, function(data) { 102 103 location.href = data["link"]; 104 105 }); 106 107 } 108 109 $(document).on('click','.actionApplyGeoModal', function (e) { 110 111 helpers.startProcessLoadButton($('.actionApplyGeoModal')); 112 113 apply(); 114 115 e.preventDefault(); 116 117 }); 118 119 $(document).on('click','.actionClearGeoModal', function (e) { 120 121 helpers.startProcessLoadButton($(this)); 122 123 helpers.request({url:"geo-clear-options", data: {url:encodeURIComponent(helpers.getUrl())}}, function(data) { 124 125 if(data["link"]){ 126 location.href = data["link"]; 127 }else{ 128 location.reload(); 129 } 130 131 }); 132 133 e.preventDefault(); 134 135 }); 136 137 $(document).on('click','.link-geo-country-item', function (e) { 138 139 $('.link-geo-country-item').removeClass("active"); 140 $(this).addClass("active"); 141 142 changeCountryId = $(this).data("id"); 143 144 helpers.request({url:"geo-change-country", data: {id:$(this).data("id")}}, function(data) { 145 146 $(".modal-geo-container-content").html(data["content"]); 147 148 }); 149 150 e.preventDefault(); 151 152 }); 153 154 $(document).on('click','.modal-geo-tabs > div', function (e) { 155 156 $('.modal-geo-tabs > div').removeClass("active"); 157 $(this).addClass("active"); 158 159 $(".modal-geo-tab-1,.modal-geo-tab-2").hide(); 160 161 if($(this).data("tab") == 1){ 162 $(".modal-geo-tab-1").show(); 163 }else if($(this).data("tab") == 2){ 164 $(".modal-geo-tab-2").show(); 165 } 166 167 e.preventDefault(); 168 169 }); 170 171 $(document).on('input click','.modal-geo-search > input', function (e) { 172 173 var query = $(this).val(); 174 175 if (searchTimeout != null) { 176 clearTimeout(searchTimeout); 177 } 178 179 if($(this).val().length != 0){ 180 searchTimeout = setTimeout(function() { 181 searchTimeout = null; 182 helpers.request({url:"geo-search-combined", data: {query: query, country_id: changeCountryId}}, function(data) { 183 184 if(data["status"]){ 185 $(".modal-geo-search-results").html(data["answer"]).fadeIn(100); 186 }else{ 187 $(".modal-geo-search-results").html("").hide(); 188 } 189 190 }); 191 }, 200); 192 }else{ 193 $(".modal-geo-search-results").html("").hide(); 194 } 195 196 e.preventDefault(); 197 198 }); 199 200 201});
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.