1/* 2* @autor = Departamento de Investigación y desarrollo de sistemas web y móviles, 3* @nombre del componente = cmbSelect, 4* @descripción = Este componente muestra combos de áreas geográficas con buscador. 5* @versión = 1.0.0, 6* @fecha de creación = 07/02/2019, 7 * @modificación = 09/03/2023, se agrega numero de municipios del catálogo único de cves geoestadÃsticas 8*/ 9var globalCatalogo = []; 10var globalIdioma = "es"; 11var globalRecursos = "localhost" === document.domain ? "http://desarrollowww.inegi.org.mx/componentes/biinegi/cmbSelect/plugin/" : "/componentes/biinegi/cmbSelect/plugin/"; 12var globalAgeo = ""; 13var globalNLocalidad = ""; 14var globalMunicipal = ""; 15var globalTem = ""; 16var globalDeSearch = false; 17var globalLocalidad = false; 18var globalFlag = false; 19var entAcromino = [ 20 { "id": "0", "name": "EUM", "capital": "", "municipios": "" }, 21 { "id": "01", "name": "AGU", "capital": "Aguascalientes", "municipios": "11" }, 22 { "id": "02", "name": "BCN", "capital": "Mexicalli", "municipios": "7" }, 23 { "id": "03", "name": "BCS", "capital": "La Paz", "municipios": "5" }, 24 { "id": "04", "name": "CAM", "capital": "San Francisco de Campeche", "municipios": "13" }, 25 { "id": "05", "name": "COA", "capital": "Saltillo", "municipios": "38" }, 26 { "id": "06", "name": "COL", "capital": "Colima", "municipios": "10" }, 27 { "id": "07", "name": "CHP", "capital": "Tuxtla Gutiérrez", "municipios": "124" }, 28 { "id": "08", "name": "CHH", "capital": "Chihuahua", "municipios": "67" }, 29 { "id": "09", "name": "DIF", "capital": "Ciudad de México", "municipios": "16" }, 30 { "id": "10", "name": "DUR", "capital": "Victoria de Durango", "municipios": "39" }, 31 { "id": "11", "name": "GUA", "capital": "Guanajuato", "municipios": "46" }, 32 { "id": "12", "name": "GRO", "capital": "Chilpancingo de los Bravo", "municipios": "85" }, 33 { "id": "13", "name": "HID", "capital": "Pachuca de Soto", "municipios": "84" }, 34 { "id": "14", "name": "JAL", "capital": "Guadalajara", "municipios": "125" }, 35 { "id": "15", "name": "MEX", "capital": "Toluca de Lerdo", "municipios": "125" }, 36 { "id": "16", "name": "MIC", "capital": "Morelia", "municipios": "113" }, 37 { "id": "17", "name": "MOR", "capital": "Cuernavaca", "municipios": "36" }, 38 { "id": "18", "name": "NAY", "capital": "Tepic", "municipios": "20" }, 39 { "id": "19", "name": "NLE", "capital": "Monterrey", "municipios": "51" }, 40 { "id": "20", "name": "OAX", "capital": "Oaxaca de Juárez", "municipios": "570" }, 41 { "id": "21", "name": "PUE", "capital": "Puebla de Zaragoza", "municipios": "217" }, 42 { "id": "22", "name": "QUE", "capital": "Santiago de Querétaro", "municipios": "18" }, 43 { "id": "23", "name": "ROO", "capital": "Chetumal", "municipios": "11" }, 44 { "id": "24", "name": "SLP", "capital": "San Luis PotosÃ", "municipios": "58" }, 45 { "id": "25", "name": "SIN", "capital": "Culiacán Rosales", "municipios": "18" }, 46 { "id": "26", "name": "SON", "capital": "Hermosillo", "municipios": "72" }, 47 { "id": "27", "name": "TAB", "capital": "Villahermosa", "municipios": "17" }, 48 { "id": "28", "name": "TAM", "capital": "Ciudad Victoria", "municipios": "43" }, 49 { "id": "29", "name": "TLA", "capital": "Tlaxcala de Xicohténcatl", "municipios": "60" }, 50 { "id": "30", "name": "VER", "capital": "Xalapa-EnrÃquez", "municipios": "212" }, 51 { "id": "31", "name": "YUC", "capital": "Mérida", "municipios": "106" }, 52 { "id": "32", "name": "ZAC", "capital": "Zacatecas", "municipios": "58" }]; 53 54(function () { 55 var about = function () { 56 this.autor = 'Departamento de Investigación y desarrollo de sistemas web y móviles - AMCR'; 57 this.name = 'cmbSelect'; 58 this.descripcion = 'Este componente muestra combos de áreas geográficas con buscador'; 59 this.version = '1.0.0';
60 this.fecha_creacion = '07/02/2019'; 61 this.modificacion = '23/04/2019, se agrega temática'; 62 } 63 var cmbSelect = function (params) { 64 return new Library(params); 65 }; 66 var Library = function (params) { 67 if (params) { 68 configura(params).init(); 69 var selector = document.querySelectorAll(params), 70 i = 0; 71 this.length = selector.length; 72 this.id = selector[this.length - 1].id; 73 this.dominio = C_dominio; 74 this.tk = C_token; 75 //this.servicio = "http://desarrollowww.inegi.org.mx/app/api/indicadores/interna_V1_1"; 76 //this.servicio = C_direccionServicio; 77 //this.servicioLocalidades = "http://desarrollowww.inegi.org.mx/app/api/indicadores/internalocalidades_v1_1/catalog?cvegeo={ag}"; 78 79 this.servicio = C_direccionServicio_V + "_" + API_V; 80 this.servicioLocalidades = C_direccionServicio_V + "localidades_v1_1/catalog?cvegeo={ag}"; 81 this.container = params; 82 this.mapa = "#mapaComponent"; 83 for (; i < this.length; i++) { 84 this[i] = selector[i]; 85 } 86 return this; 87 } 88 else { 89 return about(); 90 } 91 }; 92 cmbSelect.fn = Library.prototype = 93 { 94 loadMapa: function (idioma) { 95 var _this = this; 96 if (globalFlag === false) { 97 mapaComponent(_this.mapa).init(idioma); 98 globalFlag = true; 99 } 100 }, 101 startComponente: function (visualizacion, idioma, ageo, tematica) { 102 var _this = this; 103 //Borrar elementos si existen del div municipios 104 var myNode = document.getElementById(_this.id); 105 while (myNode.firstChild) { 106 myNode.removeChild(myNode.firstChild); 107 } 108 109 globalIdioma = idioma; 110 globalAgeo = ageo === undefined ? "" : ageo; 111 globalLocalidad = globalAgeo.length === 9 ? true : false; 112 globalTem = tematica !== undefined ? tematica : "6"; 113 114 if (_this.servicio.toUpperCase().indexOf("V1_2") !== -1) { 115 globalTem = globalTem === "0" ? "3" : globalTem; 116 } 117 118 if (_this.servicio.toUpperCase().indexOf("V1_1") !== -1) { 119 globalTem = globalTem === "3" ? "0" : globalTem; 120 } 121 122 _this.evento(); 123 _this.eventocmb(); 124 _this.eventoMapa(); 125 _this.cargaEstructura(visualizacion); 126 }, 127 init: function (visualizacion, idioma, ageo, tematica) { 128 var _this = this; 129 _this.cargaLibrerias(); 130 131 //setTimeout(function () { 132 _this.loadMapa(idioma); 133 _this.startComponente(visualizacion, idioma, ageo, tematica); 134 //}, 1500); 135 }, 136 137 cargaEstructura: function (visualizacion) { 138 var _this = this; 139 var html = ""; 140 document.getElementById(_this.id).innerHTML = html; 141 _this.visualizacionHorizontal(visualizacion); 142 }, 143 144 visualizacionHorizontal: function (visualizacion) { 145 var _this = this; 146 var div1 = ""; 147 var div2 = ""; 148 149 div1 = document.createElement("div"); 150 div1.className = "col-xs-12 col-md-5"; 151 152 div2 = document.createElement("div"); 153 div2.className = "col-xs-12 col-md-5"; 154 155 var textoBoton = globalIdioma === "en" ? "Consult" : "Consultar"; 156 var divC = document.createElement("div"); 157 divC.className = "col-xs-12 col-md-2"; 158 var a = document.createElement("a"); 159 160 var txt = document.createTextNode(textoBoton); 161 a.appendChild(txt); 162 163 a.className = "btn btn-default"; 164 a.id = "btnConsultarEntMun"; 165 a.style.color = "#fff"; 166 a.style.backgroundColor = "#2279c0"; 167 a.onclick = function () { 168 _this.clicAgeo(); 169 }; 170 divC.appendChild(a); 171 172 var divEntidades = document.createElement("div"); 173 divEntidades.id = "cmb_Ent_" + _this.id; 174 divEntidades.style.display = "block"; 175 div1.appendChild(divEntidades); 176 177 var divMunicipios = document.createElement("div"); 178 divMunicipios.id = "cmb_Mun_" + _this.id; 179 divMunicipios.style.display = "none"; 180 div2.appendChild(divMunicipios); 181 182 document.getElementById(_this.id).appendChild(div1); 183 document.getElementById(_this.id).appendChild(div2); 184 document.getElementById(_this.id).appendChild(divC); 185 _this.goServicio("null", visualizacion, 1); 186 }, 187 188 goServicio: function (ent, visualizacion, inicio) { 189 var _this = this; 190 191 //Borrar elementos si existen del div municipios 192 var myNode = document.getElementById("cmb_Mun_" + _this.id); 193 while (myNode.firstChild) { 194 myNode.removeChild(myNode.firstChild); 195 } 196 if (ent === null && globalCatalogo.length > 0) { 197 _this.printEntidades(globalCatalogo, visualizacion); 198 } 199 else { 200 //var entText = (ent === "null" ? "0" : ent); 201 var entText = (ent === "null" ? "0" : ent); 202 203 //var tematicaTempo = (ent == null ? "1" : ""); 204 //var ruta = _this.servicio + '/API.svc/CatalogoAreaGeografica/' + ent + '/null/null/6/json/' + _this.tk + '?callback=?'; 205 var ruta = (_this.servicio + '/API.svc/CatalogoAreaGeograficaV3/' + entText + '/null/null/null/' + globalTem + '/1/json/' + _this.tk + '?callback=?'); 206 $.getJSON(ruta, null, function (data) { 207 if (ent === "null") { 208 globalCatalogo = data; 209 _this.printEntidades(data, visualizacion); 210 } 211 else { 212 //AMCR-09092019 213 //if (globalAgeo.length <= 8) { 214 // globalAgeo = ent; 215 // $('#selectMun_' + _this.id).val(ent).change(); 216 //} 217 _this.printMunicipios(data, visualizacion); 218 } 219 }); 220 } 221 }, 222 223 goAPILocalidades: function (cve, visualizacion) { 224 var _this = this; 225 226 //Borrar elementos si existen del div localidades 227 var myNode = document.getElementById("cmb_Loc_" + _this.id); 228 while (myNode.firstChild) { 229 myNode.removeChild(myNode.firstChild); 230 } 231 232 var ruta = _this.servicioLocalidades.replace("{ag}", cve); 233 $.getJSON(ruta, null, function (data) { 234 _this.printLocalidades(data, visualizacion); 235 }); 236 }, 237 238 validaGlobalAgeo: function (valor) { 239 var _this = this; 240 var result = globalAgeo; 241 242 if(valor ==="0" || valor ==="00"){ 243 result = valor; 244 }else if(valor.length===2){ 245 result = valor; 246 } 247 else{ 248 if (globalLocalidad) { 249 result = globalAgeo; 250 } 251 else { 252 result = ""; 253 } 254 } 255 256 // if (valor.length > 4) { 257 // result = valor.substring(0, 8); 258 // if (globalAgeo.substring(0, 8) === result) { 259 // result = globalAgeo; 260 // if (valor.length > 8) { 261 // result = globalAgeo; 262 // } 263 // else { 264 // if (globalLocalidad) { 265 // result = globalAgeo; 266 // } 267 // else { 268 // result = ""; 269 // } 270 // } 271 // } 272 // } 273 // else { 274 // result = ""; 275 // } 276 277 return result; 278 }, 279 280 printEntidades: function (data, visualizacion) { 281 var _this = this; 282 _this.createSelect("Ent", data, visualizacion); 283 284 //$(function () { 285 //$('#selectEnt_' + _this.id).comboSelect() 286 //$('#selectEnt_' + _this.id).change(function (e, v) { 287 // _this.clicCombo(e.target.value, visualizacion); 288 //}) 289 //}) 290 291 if (globalAgeo === "") { 292 //_this.registraEvento(_this.takeNameCmb(data[0].Nombre), "", data[0].Entidad, "2"); 293 $("#selectEnt_" + _this.id).find("option:selected").text('Estados Unidos Mexicanos').change(); 294 if (visualizacion === "h") { 295 _this.registraEventoMapa("Ent", "0"); 296 } 297 } 298 else { 299 _this.fijaCombo(globalAgeo, false); 300 } 301 }, 302 303 fijaCombo: function (cve, deMun) { 304 var _this = this; 305 var ent = ""; 306 307 if (cve !== "null") { 308 if (cve.length === 9) { 309 //por localidad 310 globalNLocalidad = globalAgeo; 311 var glba = globalAgeo.substring(5, 9);
312 var glbb = convertidorAreasGeo(_this.container).init(globalAgeo); 313 globalAgeo = glbb + glba; 314 ent = globalAgeo.substring(0, 8); 315 } 316 else { 317 if(cve.length===2){ 318 //entidades nuevas claves 319 ent = cve; 320 }else{ 321 if (cve.length === 1) { 322 ent = cve; 323 } 324 else if (cve.length === 5) { 325 ent = cve.substring(0, 2); 326 } 327 else if (cve.length === 12) { 328 ent = cve.substring(0, 8); 329 } 330 else if (cve.length === 8) { 331 ent = cve.substring(0, 8); 332 } 333 else if (cve.length === 4) { 334 ent = cve; 335 } 336 else if (cve.length === 16) { 337 ent = cve.substring(0, 8); 338 } 339 } 340 } 341 } 342 else { 343 ent = "0"; 344 } 345 346 if (deMun) { 347 if (document.getElementById("selectMun_" + _this.id) === null) { 348 $('#selectEnt_' + _this.id).val(ent).change(); 349 setTimeout(function () { 350 $('#selectMun_' + _this.id).val(cve).change(); 351 }, 1500); 352 } 353 else { 354 var entSeleccionada = $('#selectEnt_' + _this.id).val(); 355 if (entSeleccionada === ent) { 356 if (cve.length === 16) { 357 var cve_mun = cve.substring(0, 12); 358 $('#selectMun_' + _this.id).val(cve_mun).change(); 359 } 360 else { 361 $('#selectMun_' + _this.id).val(cve).change(); 362 } 363 } 364 else { 365 $('#selectEnt_' + _this.id).val(ent).change(); 366 setTimeout(function () { 367 $('#selectMun_' + _this.id).val(cve).change(); 368 }, 1500); 369 } 370 } 371 } 372 else { 373 $('#selectEnt_' + _this.id).val(ent).change(); 374 } 375 }, 376 377 fijaLocalidad: function (cve, visualizacion) { 378 var _this = this; 379 var localidad = cve.substring(12, 16); 380 $('#selectLoc_' + _this.id).val(localidad).change(); 381 382 383 var nombre_ent = $("#selectEnt_" + _this.id + " option:selected").text(); 384 var nombre_mun = $("#selectMun_" + _this.id + " option:selected").text(); 385 var nombre_loc = $("#selectLoc_" + _this.id + " option:selected").text(); 386 387 if (visualizacion === "v") { 388 _this.registraEvento(_this.takeNameCmb(nombre_ent), _this.takeNameCmb(nombre_mun), nombre_loc, globalNLocalidad, "3"); 389 } 390 391 392 }, 393 394 fijaCombo_PRO: function (cve, deMun) { 395 var _this = this; 396 var ent = ""; 397 398 if (cve !== "null") { 399 if(cve.length===2){ 400 ent = cve; 401 }else{ 402 if (cve.length === 1) { 403 ent = cve; 404 } 405 else if (cve.length === 5) { 406 ent = cve.substring(0, 2); 407 } 408 else if (cve.length === 12) { 409 ent = cve.substring(0, 8); 410 } 411 else if (cve.length === 8) { 412 ent = cve.substring(0, 8); 413 } 414 else if (cve.length === 4) { 415 ent = cve; 416 } 417 } 418 } 419 else { 420 ent = "0"; 421 } 422 423 if (deMun) { 424 if (document.getElementById("selectMun_" + _this.id) === null) { 425 $('#selectEnt_' + _this.id).val(ent).change(); 426 setTimeout(function () { 427 $('#selectMun_' + _this.id).val(cve).change(); 428 }, 1500); 429 } 430 else {
431 var entSeleccionada = $('#selectEnt_' + _this.id).val(); 432 if (entSeleccionada === ent) { 433 $('#selectMun_' + _this.id).val(cve).change(); 434 } 435 else { 436 $('#selectEnt_' + _this.id).val(ent).change(); 437 setTimeout(function () { 438 $('#selectMun_' + _this.id).val(cve).change(); 439 }, 1500); 440 } 441 } 442 } 443 else { 444 $('#selectEnt_' + _this.id).val(ent).change(); 445 } 446 }, 447 448 fijaComboSearch: function (cve, deMun) { 449 var _this = this; 450 var ent = ""; 451 globalDeSearch = deMun; 452 if (cve !== "null") { 453 if(cve.length === 2){ 454 ent = cve; 455 }else{ 456 if (cve.length === 1) { 457 ent = cve; 458 } 459 else if (cve.length === 5) { 460 ent = cve.substring(0, 2); 461 } 462 else if (cve.length === 12) { 463 ent = cve.substring(0, 8); 464 } 465 else if (cve.length === 8) { 466 ent = cve.substring(0, 8); 467 } 468 else if (cve.length === 4) { 469 ent = cve; 470 } 471 } 472 } 473 else { 474 ent = "0"; 475 } 476 477 if (deMun) { 478 if (document.getElementById("selectMun_" + _this.id) === null) { 479 $('#selectEnt_' + _this.id).val(ent).change(); 480 setTimeout(function () { 481 $('#selectMun_' + _this.id).val(cve).change(); 482 }, 1500); 483 } 484 else { 485 var entSeleccionada = $('#selectEnt_' + _this.id).val(); 486 if (entSeleccionada === ent) { 487 $('#selectMun_' + _this.id).val(cve).change(); 488 } 489 else { 490 $('#selectEnt_' + _this.id).val(ent).change(); 491 setTimeout(function () { 492 $('#selectMun_' + _this.id).val(cve).change(); 493 }, 1500); 494 } 495 } 496 } 497 else { 498 $('#selectEnt_' + _this.id).val(ent).change(); 499 } 500 }, 501 502 clicCombo: function (id, visualizacion, alias) { 503 var _this = this; 504 var param_gbAgeo = _this.validaGlobalAgeo(id); 505 globalAgeo = param_gbAgeo; 506 var nombre_ent = $("#selectEnt_" + _this.id + " option:selected").text(); 507 if (id === "0") { 508 _this.estadosCombos(false); 509 if (visualizacion === "v") { 510 _this.registraEvento(_this.takeNameCmb(nombre_ent), "", "", id, "2"); 511 } 512 else { 513 _this.registraEventoMapa(alias, id); 514 } 515 } 516 else { 517 if (alias === "Mun") { 518 //pinta svg municipal 519 520 //Se agrega funcionalidad Localidades 521 522 var cveAgeo = id.length === 4 ? "00" : id.substring(6, 8) + id.substring(9, id.length); 523 524 var id_ag = id; 525 var nombre_mun = $("#selectMun_" + _this.id + " option:selected").text(); 526 527 if (visualizacion === "h") { 528 _this.registraEventoMapa(alias, id); 529 } 530 531 } 532 else if (alias === "Ent") { 533 if (visualizacion === "v") { 534 $("#cmb_Loc_" + _this.id).hide(); 535 $("#span_titleLoc").hide(); 536 } 537 538 //AMCR-09092019 539 _this.goServicio(id, visualizacion); 540 541 var idSelect = "#selectMun" + "_" + _this.id; 542 if ($(idSelect + ' option').length === 0) { 543 if (alias !== "Ent") { 544 _this.goServicio(id, visualizacion); 545 } 546 } 547 548 if (globalAgeo === "" || globalAgeo.length <= 4) { 549 if (visualizacion === "v") { 550 if (!globalDeSearch) { 551 _this.registraEvento(_this.takeNameCmb(nombre_ent), _this.takeNameCmb("Estatal"), "", id, "2"); 552 } 553 } 554 555 else { 556 _this.registraEventoMapa("Ent", id); 557 } 558 } 559 } 560 else { 561 var total = globalIdioma === "es" ? "Total municipal" : "Total municipality"; 562 var cve = $("#selectLoc_" + _this.id + " option:selected").text() === total ? id : (($("#selectMun_" + _this.id + " option:selected").val().length === 4 ? "00" : $("#selectMun_" + _this.id + " option:selected").val().substring(6, 8) + $("#selectMun_" + _this.id + " option:selected").val().substring(9, $("#selectMun_" + _this.id + " option:selected").val().length)) + $("#selectLoc_" + _this.id + " option:selected").val()).toString(); 563 var nombre_mun = $("#selectMun_" + _this.id + " option:selected").text(); 564 var nombre_loc = $("#selectLoc_" + _this.id + " option:selected").text() === total ? "" : $("#selectLoc_" + _this.id + " option:selected").text(); 565 566 if (visualizacion === "v") { 567 _this.registraEvento(_this.takeNameCmb(nombre_ent), _this.takeNameCmb(nombre_mun), nombre_loc, cve, "3"); 568 } 569 570 } 571 } 572 }, 573 574 takeNameCmb: function (name) { 575 var _this = this; 576 var nombreAgeo = name; 577 switch (name.trim()) { 578 case "Estatal": 579 nombreAgeo = globalIdioma === "es" ? "Total estatal" : "Total state"; 580 break; 581 582 case "Estados Unidos Mexicanos": 583 nombreAgeo = globalIdioma === "es" ? "Estados Unidos Mexicanos" : "United Mexican States"; 584 break; 585 default: 586 nombreAgeo = name; 587 } 588 return nombreAgeo; 589 }, 590 591 estadosCombos: function (hayMunicipal) { 592 var _this = this; 593 if (hayMunicipal) { 594 document.getElementById("cmb_Ent_" + _this.id).style.display = "block"; 595 document.getElementById("cmb_Mun_" + _this.id).style.display = "block"; 596 if (document.getElementById("span_titleMun") !== null) { 597 document.getElementById("span_titleMun").style.display = "block"; 598 } 599 if (document.getElementById("cmb_Loc_" + _this.id) !== null) { 600 document.getElementById("cmb_Loc_" + _this.id).style.display = "block"; 601 document.getElementById("span_titleLoc").style.display = "block"; 602 } 603 } 604 else { 605 document.getElementById("cmb_Ent_" + _this.id).style.display = "block"; 606 document.getElementById("cmb_Mun_" + _this.id).style.display = "none"; 607 if (document.getElementById("span_titleMun") !== null) { 608 document.getElementById("span_titleMun").style.display = "none"; 609 } 610 611 if (document.getElementById("cmb_Loc_" + _this.id) !== null) { 612 document.getElementById("cmb_Loc_" + _this.id).style.display = "none"; 613 document.getElementById("span_titleLoc").style.display = "none"; 614 } 615 } 616 }, 617 618 printMunicipios: function (data, visualizacion) { 619 var _this = this; 620 _this.createSelect("Mun", data, visualizacion); 621 document.getElementById("cmb_Mun_" + _this.id).style.display = "block"; 622 if (document.getElementById("span_titleMun") !== null) { 623 document.getElementById("span_titleMun").style.display = "block"; 624 } 625 626 $('#selectMun_' + _this.id).comboSelect(); 627 $(function () { 628 //$('#selectMun_' + _this.id).comboSelect(); 629 $('#selectMun_' + _this.id).change(function (e, v) { 630 _this.clicCombo(e.target.value, visualizacion, "Mun"); 631 }) 632 }) 633 634 //AMCR-11092019 635 if (globalAgeo !== "") { 636 _this.fijaCombo(globalAgeo, true); 637 } 638 }, 639 printLocalidades: function (data, visualizacion) { 640 var _this = this; 641 _this.createSelect("Loc", data, visualizacion); 642 document.getElementById("cmb_Loc_" + _this.id).style.display = "block"; 643 document.getElementById("span_titleLoc").style.display = "block"; 644 645 646 647 //AMCR-11092019 648 if (globalAgeo.length === 16) { 649 _this.fijaLocalidad(globalAgeo, visualizacion); 650 } 651 652 653 $('#selectLoc_' + _this.id).comboSelect(); 654 $(function () { 655 //$('#selectMun_' + _this.id).comboSelect(); 656 $('#selectLoc_' + _this.id).change(function (e, v) { 657 _this.clicCombo(e.target.value, visualizacion, "Loc"); 658 }) 659 }) 660 }, 661 createSelect: function (alias, data, visualizacion) { 662 var _this = this; 663 var nombre = ""; 664 var entra = false; 665 var select = document.createElement("select"); 666 select.id = "select" + alias + "_" + _this.id; 667 select.className = "js-select"; 668 669 if (alias !== "Loc") { 670 var datos = data[0].AREAS_GEOGRAFICAS_DEPENDIENTES.sort(_this.ordenaJson("NOMBRE")); 671 for (var e = -1; e < datos.length; e++) { 672 entra = false; 673 var option = document.createElement("option"); 674 if (alias === "Ent") { 675 if (e === -1) { 676 entra = true; 677 option.setAttribute("value", data[0].AREA_GEOGRAFICA); 678 nombre = data[0].NOMBRE; 679 } else { 680 if (datos[e].DESGLOSE_GEOGRAFICO === 1 || datos[e].DESGLOSE_GEOGRAFICO === 2) { 681 entra = true; 682 option.setAttribute("value", datos[e].AREA_GEOGRAFICA); 683 nombre = datos[e].NOMBRE; 684 } 685 } 686 } 687 //Municipios "Mun" 688 else { 689 if (e === -1) { 690 entra = true; 691 option.setAttribute("value", data[0].AREA_GEOGRAFICA); 692 nombre = data[0].NOMBRE_DESGLOSE_GEOGRAFICO; 693 } else { 694 if (datos[e].DESGLOSE_GEOGRAFICO === 3) { 695 entra = true; 696 option.setAttribute("value", datos[e].AREA_GEOGRAFICA); 697 nombre = datos[e].NOMBRE; 698 } 699 } 700 } 701 if (entra) { 702 var txt = document.createTextNode(_this.takeNameCmb(nombre)); 703 txt.className = "notranslate"; 704 option.appendChild(txt); 705 select.appendChild(option); 706 } 707 } 708 } 709 else { 710 //Se agrega total municipal
711 var cveTot = convertidorAreasGeo(_this.container).init(data[0].cveEnt + data[0].cveMun); 712 var option = document.createElement("option"); 713 option.setAttribute("value", cveTot); 714 nombre = globalIdioma === "es" ? "Total municipal" : "Total municipality"; 715 var txt = document.createTextNode(nombre); 716 txt.className = "notranslate"; 717 option.appendChild(txt); 718 select.appendChild(option); 719 720 for (var loc = 0; loc < data.length; loc++) { 721 var option = document.createElement("option"); 722 option.setAttribute("value", data[loc].cveLoc); 723 nombre = data[loc].nomLoc; 724 var txt = document.createTextNode(nombre); 725 txt.className = "notranslate"; 726 option.appendChild(txt); 727 select.appendChild(option); 728 } 729 } 730 document.getElementById("cmb_" + alias + "_" + _this.id).appendChild(select); 731 document.getElementById("cmb_" + alias + "_" + _this.id).className = "classDiv"; 732 //if (alias === "Mun") { 733 // var comboM = document.getElementById("selectMun_" + _this.id); 734 // comboM.options[0].selected = true; 735 //} 736 737 $(function () { 738 $('#select' + alias + '_' + _this.id).comboSelect() 739 $('#select' + alias + '_' + _this.id).change(function (e, v) { 740 if (alias !== "Mun" && alias !== "Loc") { 741 _this.clicCombo(e.target.value, visualizacion, alias); 742 } 743 }) 744 }); 745 746 //$('#select' + alias + '_' + _this.id).comboSelect(); 747 //select.addEventListener("change", function (e) { _this.clicCombo(e.target.value, visualizacion, alias) }); 748 }, 749 750 clicAgeo: function () { 751 var _this = this; 752 _this.registraEventoMunicipal(); 753 }, 754 755 evento: function () { 756 var registra = "newEventocmbMapa"; 757 if (document.addEventListener) { 758 document.addEventListener(registra, onCliCmbMapa, false); 759 } 760 else { 761 document.attachEvent("onclick", onCliCmbMapa); 762 } 763 }, 764 765 registraEvento: function (nentidad, nmunicipio, nlocalidad, id, desglose) { 766 var _this = this; 767 var name = nmunicipio === "" ? nentidad : ((nmunicipio.toLowerCase().indexOf("estatal") !== -1) ? nentidad : nmunicipio + ", " + nentidad); 768 var idMunicipio = ""; 769 var tempid = id; 770 //AMCR-09092019 771 //var mapa = id.length == 4 ? (("MX-" + _this.getMapa(id)).toString()) : id !== undefined ? "MX-" + (_this.getMapa(id.substring(0, 8))).toString() : "MX-" + (_this.getMapa(id.substring(0, 8))); 772 var mapa = (id); 773 var registra = "newEventocmbMapa"; 774 var event = ""; 775 event = document.createEvent("CustomEvent"); 776 event.initCustomEvent(registra, false, false, { 777 'id': tempid, 778 'idMapa': mapa, 779 'entidad': nentidad, 780 'municipio': nmunicipio, 781 'localidad': nlocalidad, 782 'desglose': desglose, 783 'titulo': name, 784 'seleccion': nmunicipio !== "" ? (id.length === 2 ? nentidad : (idMunicipio === "000" ? nentidad : (nlocalidad !== "" ? (nlocalidad + ", " + nmunicipio + ", " + nentidad) : (nmunicipio + ", " + nentidad)))) : nentidad 785 //'seleccion': nmunicipio !== "" ? (id.length === 2 ? nentidad : (idMunicipio === "000" ? nentidad : (nmunicipio + ", " + nentidad))) : nentidad 786 }); 787 document.dispatchEvent(event); 788 }, 789 790 eventocmb: function () { 791 var _this = this; var container = _this.container; 792 var registra = "newEventoMunicipal" + container; 793 if (document.addEventListener) { 794 document.addEventListener(registra, onCmbMunicipal, false); 795 } 796 else { 797 document.attachEvent("onclick", onCmbMunicipal); 798 } 799 }, 800 801 registraEventoMunicipal: function () { 802 var _this = this; var container = _this.container; 803 804 var id = $("#selectEnt_" + _this.id + " option:selected").val(); 805 var municipio = $("#selectMun_" + _this.id + " option:selected").val(); 806 var nombre_ent = $("#selectEnt_" + _this.id + " option:selected").text(); 807 var mapa = id; 808 809 //AMCR-11092019 810 var idTemp = municipio === undefined ? id : esMunicipal === true ? municipio : id; 811 globalAgeo = idTemp; 812 813 var registra = "newEventoMunicipal" + container; 814 var event = ""; 815 event = document.createEvent("CustomEvent"); 816 event.initCustomEvent(registra, false, false, { 817 'idMapa': mapa, 818 'nombre': nombre_ent, 819 'cve': idTemp 820 }); 821 document.dispatchEvent(event); 822 }, 823 824 eventoMapa: function () { 825 var _this = this; var container = _this.container; 826 var registra = "newEventoMapa" + container; 827 if (document.addEventListener) { 828 document.addEventListener(registra, onCmbMapa, false); 829 } 830 else { 831 document.attachEvent("onclick", onCmbMapa); 832 } 833 }, 834 835 registraEventoMapa: function (alias, ky) { 836 var _this = this; var container = _this.container; 837 var ent = $("#selectEnt_" + _this.id + " option:selected").val() === undefined ? "0" : $("#selectEnt_" + _this.id + " option:selected").val(); 838
839 //if (alias === "Mun" && ky.length > 8) { 840 // $("#muniComponent").show(); 841 // $("#mapaComponent").hide(); 842 //} 843 //else { 844 $("#muniComponent").hide(); 845 $("#mapaComponent").show(); 846 mapaComponent(_this.mapa).outSeleccionMapa(ent, ky); 847 //} 848 }, 849 850 cargaLibrerias: function () { 851 var _this = this; 852 //var lib = document.domain === "localhost" ? "http://desarrollowww.inegi.org.mx/componentes/biinegi/" : "/componentes/biinegi/"; 853 //_this.librerias(lib + "cmbselect/mapa/mapaComponentV2.min.js?v.1.0", "js", "cmbselv2_4"); 854 //_this.librerias(lib + "cmbselect/mapa/resources/ammap/core.min.js?v.1.0", "js", "cmbselv2_1"); 855 //_this.librerias(lib + "cmbselect/mapa/resources/ammap/maps.min.js?v.1.0", "js", "cmbselv2_2"); 856 //_this.librerias(lib + "cmbselect/mapa/resources/ammap/mexicoLow.min.js?v.1.0", "js", "cmbselv2_3"); 857 858 859 _this.librerias(globalRecursos + "jquery.combo.select.js?v.1.0", "js", "cmbselv2_5"); 860 _this.librerias(globalRecursos + "combo.select.css?v.1.0", "css", "cmbselv2_6"); 861 _this.librerias(document.domain === "localhost" ? "http://desarrollowww.inegi.org.mx/componentes/biinegi/convertidorAreasGeo.min.js" : "/componentes/biinegi/convertidorAreasGeo.min.js", "js", "cmbselv2_7"); 862 }, 863 librerias: function (libreria, ty, id) { 864 var cssId = id; 865 var link = ""; 866 if (!document.getElementById(cssId)) { 867 var head = document.getElementsByTagName('head')[0]; 868 if (ty === "css") { 869 link = document.createElement('link'); 870 link.rel = 'stylesheet'; 871 link.type = 'text/css'; 872 link.id = cssId; 873 link.href = libreria; 874 if ($('link[href="' + libreria + '"]').length === 0) { 875 head.appendChild(link); 876 } 877 } 878 else { 879 link = document.createElement('script'); 880 link.type = 'text/javascript'; 881 link.id = cssId; 882 link.src = libreria; 883 if ($('script[src="' + libreria + '"]').length === 0) { 884 head.appendChild(link); 885 } 886 } 887 } 888 }, 889 getMapa: function (id) { 890 var _this = this; 891 for (var im = 0; im < entAcromino.length; im++) { 892 if (id === entAcromino[im].id) { 893 return entAcromino[im].name; 894 //break; 895 } 896 } 897 }, 898 ordenaJson: function (property) { 899 var sortOrder = 1; 900 if (property[0] === "-") { 901 sortOrder = -1; 902 property = property.substr(1); 903 } 904 return function (a, b) { 905 var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0; 906 return result * sortOrder; 907 } 908 } 909 }; 910 if (!window.cmbSelect) { 911 window.cmbSelect = cmbSelect; 912 } 913})();
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.