1/** 2 * To determine base_url so that it can be used in all pages 3 */ 4 5//alert(window.location.host); 6if (typeof APP_BASE_URL !== "undefined") { 7 //Demo 8 window.base_url = APP_BASE_URL; 9} else { 10 if (window.location.host == "localhost") { 11 window.base_url = "http://localhost/sssbr/ncm"; 12 } else if (window.location.host == "178.79.143.182") { 13 window.base_url = "http://178.79.143.182/demo/sssbr/ncm"; 14 } else if(window.location.host == "demo.misericordiabadia.it"){ 15 window.base_url = "http://demo.misericordiabadia.it"; //Demo git 16 } 17 else { 18 window.base_url = "https://erp.misericordiadibadia.it"; //Production 19 } 20} 21$(document).ajaxError(function (event, jqxhr, settings, thrownError) { 22 //console.log(event); 23 //console.log(jqxhr.status); 24 //console.log(settings); 25 //console.log(thrownError); 26 27 if (jqxhr.status == 401) { 28 alert("La sessione è scaduta. Verrai indirizzato alla pagina di accesso"); 29 location.href = window.base_url + "/logout"; 30 } 31}); 32 33// base_url='http://178.79.143.182/sssbr/ncm'; 34 35function it_formatNumber(num, fixed) { 36 var decimalPart; 37 38 var array = Math.floor(num).toString().split(""); 39 var index = -3; 40 while (array.length + index > 0) { 41 array.splice(index, 0, "."); 42 index -= 4; 43 } 44 45 if (fixed > 0) { 46 decimalPart = num.toFixed(fixed).split(".")[1]; 47 return array.join("") + "," + decimalPart; 48 } 49 return array.join(""); 50} 51 52function en_formatNumber(numberString) { 53 numberString = numberString.replace(/\./, "").replace(/,/, "."); 54 parsed = parseFloat(numberString); 55 return parsed.toFixed(2); 56} 57 58function currentDate(delimiter) { 59 var today = new Date(); 60 var currentDate = ("0" + today.getDate()).slice(-2) + delimiter + ("0" + (today.getMonth() + 1)).slice(-2) + delimiter + today.getFullYear(); 61 return currentDate; 62} 63 64function currentDateTime(delimiter) { 65 var today = new Date(); 66 var currentDate = ("0" + today.getDate()).slice(-2) + delimiter + ("0" + (today.getMonth() + 1)).slice(-2) + delimiter + today.getFullYear(); 67 var time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds(); 68 var dateTime = currentDate + " " + time; 69 return dateTime; 70} 71 72function createFormatWiseDate(date) { 73 // 11/08/2017 74 var split_date = date.split("/"); 75 var day = split_date[0]; 76 var month = split_date[1]; 77 var year = split_date[2]; 78 var new_date = year + "-" + month + "-" + day; 79 return new_date; 80} 81 82$(document).on("click", ".btn-add", function (event) { 83 event.preventDefault(); 84 85 var field = $(this).closest(".plus-filed"); 86 var field_new = field.clone(); 87 88 $(this).toggleClass("btn-default").toggleClass("btn-add").toggleClass("btn-danger").toggleClass("btn-remove").html('<i class="fa fa-minus"></i>'); 89 field_new.find("input").val(""); 90 field_new.find("input.hasDatepicker").removeClass("hasDatepicker").attr("id", ""); 91 field_new.find(".periodicityType").val("").change(); 92 field_new.find(".buy-month").hide(); 93 field_new.find(".buy-from-to").hide(); 94 field_new.insertAfter(field); 95 field_new.find(".date-own").datepicker({ 96 dateFormat: "dd-mm-yy", 97 autoclose: true, 98 }); 99}); 100 101$(document).on("click", ".btn-remove", function (event) { 102 event.preventDefault(); 103 $(this).closest(".plus-filed").remove(); 104}); 105 106$(document).on("click", ".btn-add1", function (event) { 107 event.preventDefault(); 108 109 //var field = $(this).parents('div:first').find('.plus-filed:last'); 110 var field = $(this).parents(".repeater1").find(".plus-filed:last"); 111 var field_new = field.clone(); 112 113 field_new.find("input").val(""); 114 field_new.find("input.hasDatepicker").removeClass("hasDatepicker").attr("id", ""); 115 field_new.find(".periodicityType").val("").change(); 116 field_new.find(".buy-month").hide(); 117 field_new.find(".buy-from-to").hide(); 118 field_new.find(".date-own").datepicker({ 119 dateFormat: "dd-mm-yy", 120 autoclose: true, 121 }); 122 123 field_new.insertAfter(field); 124}); 125 126$(document).on("click", ".btn-remove1", function (event) { 127 event.preventDefault(); 128 129 var total_field = $(this).parents(".repeater1").find(".plus-filed").length; 130 131 if (total_field > 1) { 132 $(this).closest(".plus-filed").remove(); 133 } else { 134 bootbox.alert("You can't delete all rows"); 135 //swal("", "You can't delete all rows", 'warning'); 136 } 137}); 138 139$(document).on("click", ".btn-add-multi1", function (event) { 140 event.preventDefault(); 141 142 var field = $(this).parents(".multi_repeater1").find(".plus-filed-multi:last"); 143 var time_slot_name = $(".time-slot:last").attr("name"); 144 var regExp = /\[([^)]+)\]\[\]/; 145 var matches = regExp.exec(time_slot_name);
146 console.log(matches); 147 if (matches != null) { 148 var current_slot = parseInt(matches[1]); 149 } else { 150 current_slot = 1; 151 } 152 153 current_slot++; 154 155 //console.log(current_slot); 156 157 var field_new = field.clone(); 158 159 field_new.find(".time-slot").attr("name", "time_slot_type[" + current_slot + "][]"); 160 field_new.find(".time-slot-amount").attr("name", "time_slot_amount[" + current_slot + "][]"); 161 162 field_new.find("input").val(""); 163 field_new.find("input.hasDatepicker").removeClass("hasDatepicker").attr("id", ""); 164 field_new.find(".periodicityType").val("").change(); 165 field_new.find(".buy-month").hide(); 166 field_new.find(".buy-from-to").hide(); 167 field_new.find(".date-own").datepicker({ 168 dateFormat: "dd-mm-yy", 169 autoclose: true, 170 }); 171 field_new.find(".forfaitORhourly").val(""); 172 field_new.find(".box-forfait-hourly").hide(); 173 174 field_new.find(".btn-remove-multi1").remove(); 175 field_new.find(".service_type_lebel").append('<button class="btn btn-sm btn-danger btn-remove-multi1" type="button"><i class="fa fa-minus"></i></button>'); 176 177 field_new.insertAfter(field); 178 179 //field_new.find('.input-group').append('<span class="input-group-addon padding-0" ><button class="btn btn-sm btn-danger btn-remove1" type="button"><i class="fa fa-minus"></i></button></span>'); 180}); 181 182$(document).on("click", ".btn-remove-multi1", function (event) { 183 event.preventDefault(); 184 185 var total_field = $(".btn-add-multi1").parents(".multi_repeater1").find(".plus-filed").length; 186 187 if (total_field > 1) { 188 $(this).closest(".plus-filed-multi").remove(); 189 } else { 190 bootbox.alert("You can't delete all rows"); 191 //swal("", "You can't delete all rows", 'warning'); 192 } 193}); 194 195function changeCountry(country_div_id, county_div_id) { 196 var country_id = $("#" + country_div_id).val(); 197 198 if (country_id == 119) { 199 $("#" + county_div_id).attr("disabled", false); 200 } else { 201 $("#" + county_div_id).attr("disabled", true); 202 203 $.ajax({
204 url: base_url + "/common/" + country_id + "/getCityListByCountry", 205 type: "get", 206 success: function (result) { 207 $("#city_id").html(result); 208 }, 209 }); 210 } 211} 212 213function changeCounty(div_id) { 214 var county_id = $("#" + div_id).val(); 215 216 $.ajax({ 217 url: base_url + "/common/" + county_id + "/getCityListByCounty", 218 type: "get", 219 success: function (result) { 220 $("#city_id").html(result); 221 }, 222 }); 223} 224 225$(document).on("change", ".country_list", function () { 226 var country_id = $(this).val(); 227 var that = $(this); 228 if (country_id == 119) { 229 $(this).parents(".well").find(".county_list").attr("disabled", false); 230 $(this).parents(".well").find(".city_list").html("").val(""); 231 } else if (country_id == "") { 232 $(this).parents(".well").find(".county_list").val("").attr("disabled", true); 233 $(this).parents(".well").find(".city_list").html("").val(""); 234 } else { 235 $(this).parents(".well").find(".county_list").val("").attr("disabled", true); 236 $.ajax({
237 url: base_url + "/common/" + country_id + "/getCityListByCountry", 238 type: "get", 239 success: function (result) { 240 that.closest(".well").find(".city_list").html(result); 241 }, 242 }); 243 } 244}); 245 246$(document).on("change", ".county_list", function () { 247 var county_id = $(this).val(); 248 var that = $(this); 249 250 if (county_id == "") { 251 that.closest(".well").find(".city_list").html(""); 252 } else { 253 $.ajax({ 254 url: base_url + "/common/" + county_id + "/getCityListByCounty", 255 type: "get", 256 success: function (result) { 257 that.closest(".well").find(".city_list").html(result); 258 }, 259 }); 260 } 261}); 262 263var that_address_input; 264$(document).on("focus", ".address-input", function () { 265 //console.log('test3'); 266 //var zip_code; 267 that_address_input = $(this); 268 //console.log($(that_address_input).parents(".address_section").find(".zip-input").val()); 269 initGoogleAutocomplete(); 270}); 271 272function initGoogleAutocomplete() { 273 var input = $(".address-input:focus")[0]; 274 275 if (input) { 276 //console.log(input); 277 /*var defaultBounds = new google.maps.LatLngBounds( 278 new google.maps.LatLng(-33.8902, 151.1759), 279 new google.maps.LatLng(-33.8474, 151.2631)); 280 281 var searchBox = new google.maps.places.SearchBox(input, { 282 bounds: defaultBounds 283 }); 284 var searchBox = new google.maps.places.SearchBox(input, { 285 bounds: defaultBounds 286 });*/ 287 var searchBox = new google.maps.places.SearchBox(input); 288 //var searchBox = new google.maps.places.Autocomplete(input); 289 //searchBox.setComponentRestrictions({'country': ['ita']}); 290 //console.log(searchBox); 291 var markers = []; 292 293 setTimeout(function () { 294 $(".address-input").attr("placeholder", ""); 295 }, 10); 296 setTimeout(function () { 297 $(".address-input").attr("placeholder", ""); 298 }, 50); 299 setTimeout(function () { 300 $(".address-input").attr("placeholder", ""); 301 }, 100); 302 303 searchBox.addListener("places_changed", function () { 304 var places = searchBox.getPlaces(); 305 var lat = places[0].geometry.location.lat(); 306 var lon = places[0].geometry.location.lng(); 307 //console.log(places[0].geometry.location.lng()); 308 //console.log(places[0].address_components); 309 310 $(that_address_input).closest(".address_section").find(".lat-input").val(lat); 311 $(that_address_input).closest(".address_section").find(".lon-input").val(lon); 312 313 /*if(zip_code){ 314 $(that_address_input).closest(".address_section").find(".zip-input").val(zip_code); 315 }*/ 316 317 var zip_code = ""; 318 319 for (var i = 0; i < places[0].address_components.length; i++) { 320 if (places[0].address_components[i]["types"][0] == "locality") { 321 var city_name = places[0].address_components[i]["long_name"]; 322 //console.log('city' + city_name); 323 } 324 325 if (places[0].address_components[i]["types"][0] == "country") { 326 var country_name = places[0].address_components[i]["long_name"]; 327 $(that_address_input).closest(".address_section").find(".country_list").find("option:selected").attr("selected", false); 328 $(that_address_input) 329 .closest(".address_section") 330 .find(".country_list") 331 .find("option:contains(" + country_name + ")") 332 .attr("selected", true); 333 334 //var city_list = getCityList(country_name); 335 //console.log('city2' + city_name); 336 if (country_name == "Italia") { 337 $(that_address_input).closest(".well").find(".county_list").attr("disabled", false); 338 339 $.ajax({
340 async: false, 341 url: base_url + "/common/" + city_name + "/getCountyCityListByCityName", 342 type: "get", 343 success: function (result) { 344 var county_info = JSON.parse(result); 345 //console.log(county_info); 346 if (county_info.length) { 347 console.log(county_info[0]["county_name"]); 348 if (typeof county_info[0]["county_name"] != "undefined") { 349 $(that_address_input) 350 .closest(".address_section") 351 .find(".county_list") 352 .find("option:contains(" + county_info[0]["county_name"] + ")") 353 .attr("selected", true); 354 } 355 356 if (county_info[0]["city_html"]) { 357 $(that_address_input).closest(".well").find(".city_list").html(county_info[0]["city_html"]); 358 $(that_address_input) 359 .closest(".address_section") 360 .find(".city_list") 361 .find("option:contains(" + city_name + ")") 362 .attr("selected", true); 363 } 364 } 365 }, 366 }); 367 } else { 368 $.ajax({
369 async: false, 370 url: base_url + "/common/" + country_name + "/getCityListByCountryName", 371 type: "get", 372 success: function (result) { 373 $(that_address_input).closest(".well").find(".city_list").html(result); 374 $(that_address_input) 375 .closest(".address_section") 376 .find(".city_list") 377 .find("option:contains(" + city_name + ")") 378 .attr("selected", true); 379 $(that_address_input).closest(".well").find(".county_list").find("option:selected").attr("selected", false); 380 //$(that_address_input).closest(".well").find(".county_list").find('option:contains(" ")').attr("selected", true); 381 $(that_address_input).closest(".well").find(".county_list").attr("disabled", true); 382 }, 383 }); 384 } 385 386 //$(that_address_input).closest(".address_section").find(".city_list").html(city_list); 387 //$('select[name="options"]').find('option:contains('+ country_name+ ')').attr("selected",true); 388 } 389 390 if (places[0].address_components[i]["types"][0] == "postal_code") { 391 var zip_code = places[0].address_components[i]["short_name"]; 392 } 393 394 //console.log(places[0].address_components[i]['types'][0]); 395 } 396 397 $(that_address_input).closest(".address_section").find(".zip-input").val(zip_code); 398 399 /*$('select[name="options"]').find('option:contains("Blue")').attr("selected",true); 400 var country = parseInt(places[0].address_components[places[0].address_components.length-2]); 401 .each(function(index, element){ 402 403 });*/ 404 405 //console.log(zip_code); 406 if (places.length == 0) { 407 return; 408 } 409 }); 410 } 411 412 var pacContainerInitialized = false; 413} 414 415function valueChanged() { 416 $(".client-opt").hide(); 417 418 if ($(".branch-check").is(":checked")) { 419 $(".client-type-branch").show("500").find("input").attr("required", true); 420 } else { 421 $(".client-type-branch").hide("500").find("input").attr("required", false); 422 } 423} 424 425$(document).on("click", ".add-table-row", function (e) { 426 e.preventDefault(); 427 var $tableBody = $("#yard-contact-people-table").find("tbody"), 428 $trLast = $tableBody.find("tr:last"), 429 $trNew = $trLast.clone(); 430 $trNew.find(":text").val(""); 431 $trLast.after($trNew); 432}); 433 434$(document).on("click", ".ycp-remove-row", function (e) { 435 e.preventDefault(); 436 var rows = $("#yard-contact-people-table tr").length; 437 if (rows > 2) { 438 $(this).closest("tr").remove(); 439 } else { 440 bootbox.alert("Sorry, You can not remove all the rows. To remove this row Insert a new one"); 441 } 442}); 443 444function getCityList(country_name) { 445 $.ajax({ 446 async: false, 447 url: base_url + "/common/" + country_name + "/getCityListByCountryName", 448 type: "get", 449 success: function (result) { 450 return result; 451 //that.closest('.well').find(".city_list").html(result); 452 }, 453 }); 454} 455 456$(document).on("click", ".form-delete", function (e) { 457 e.preventDefault(); 458 // console.log($(this).closest('form')); 459 // console.log(selectedLanguage); 460 swal({ 461 title: delete_confirmation, 462 text: are_you_sure_to_delete, 463 type: "warning", 464 showCancelButton: true, 465 confirmButtonColor: "#3085d6", 466 cancelButtonColor: "#d33", 467 confirmButtonText: yes_delete_it, 468 cancelButtonText: lang_cancel, 469 }).then((result) => { 470 if (result.value) { 471 $(this).closest("form").submit(); 472 return true; 473 } else { 474 return false; 475 } 476 }); 477}); 478 479$(document).on("input", ".decimalOnly", function (evt) { 480 //$(".decimalOnly").on("input", function(evt) { 481 if ($(this).val().includes(",")) { 482 swal(comma_not_allowed); 483 } 484 var value = $(this).val().toString().replace(/\,/g, "."); 485 $(this).val(value); 486 var self = $(this); 487 self.val(self.val().replace(/[^0-9\.]/g, "")); 488 if ((evt.which != 46 || self.val().indexOf(".") != -1) && (evt.which < 48 || evt.which > 57)) { 489 evt.preventDefault(); 490 } 491}); 492 493$(document).on("input", ".decimalOnlyWithNegative", function (evt) { 494 if ($(this).val().includes(",")) { 495 swal(comma_not_allowed); 496 } 497 var value = $(this).val().toString().replace(/\,/g, "."); 498 $(this).val(value); 499 var self = $(this); 500 self.val(self.val().replace(/[^-0-9\.]/g, "")); 501 if ((evt.which != 46 || self.val().indexOf(".") != -1) && (evt.which < 48 || evt.which > 57)) { 502 evt.preventDefault(); 503 } 504}); 505 506$(document).on("input", ".numberOnly", function (evt) { 507 //$(".decimalOnly").on("input", function(evt) { 508 var self = $(this); 509 self.val(self.val().replace(/[^0-9]/g, "")); 510 if ((evt.which != 46 || self.val().indexOf(".") != -1) && (evt.which < 48 || evt.which > 57)) { 511 evt.preventDefault(); 512 } 513});
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.