1(function($) { 2 var tarifasData = null; 3 var valueComboOrigen = null; 4 var valueComboDestino = null; 5 6 $(document).ready(function(){ 7 $('#selectDestino').attr('style', 'display:none'); 8 $('#ContentTable').attr('style', 'display:none'); 9 10 cargarDatos(); 11 }); 12 13 function cargarDatos() { 14 $.ajax({ 15 url: itinere_vars.ajaxurl, 16 type: 'POST', 17 data: { 18 action: 'itinere_get_all_tariffs', 19 nonce: itinere_vars.nonce 20 }, 21 success: function(response) { 22 if (response.success) { 23 tarifasData = response.data; 24 25 var options = $('<option>', { 26 value: 'seleciona', 27 text: 'Seleccione origen...' 28 }); 29 30 $('#selectOrigen').empty().append(options); 31 32 for (var i = 0; i < tarifasData.origenes.length; i++) { 33 $('#selectOrigen').append( 34 $('<option>', { 35 value: tarifasData.origenes[i], 36 text: tarifasData.origenes[i] 37 }) 38 ); 39 } 40 } else { 41 $('#selectOrigen').empty().append( 42 $('<option>', { 43 value: 'seleciona', 44 text: 'Error al cargar datos' 45 }) 46 ); 47 console.error('Error:', response.data); 48 } 49 }, 50 error: function() { 51 $('#selectOrigen').empty().append( 52 $('<option>', { 53 value: 'seleciona', 54 text: 'Error de conexión' 55 }) 56 ); 57 } 58 }); 59 } 60 61 window.mostrarValoresOrigen = function(valorMostrar) { 62 valueComboOrigen = valorMostrar.value; 63 64 if (valueComboOrigen == 'seleciona') { 65 $('#selectDestino').attr('style', 'display:none'); 66 $('#ContentTable').attr('style', 'display:none'); 67 $('#selectDestino').empty().append( 68 $('<option>', { 69 value: 'seleciona', 70 text: 'Seleccione destino...' 71 }) 72 ); 73 } else { 74 $('#selectDestino').attr('style', 'display:block'); 75 $('#ContentTable').attr('style', 'display:block'); 76 77 var destinos = []; 78 for (var i = 0; i < tarifasData.tarifas.length; i++) { 79 if (tarifasData.tarifas[i].origen == valueComboOrigen) { 80 var destino = tarifasData.tarifas[i].destino; 81 if (destinos.indexOf(destino) === -1) { 82 destinos.push(destino); 83 } 84 } 85 } 86 87 destinos.sort(); 88 89 $('#selectDestino').empty().append( 90 $('<option>', { 91 value: 'seleciona', 92 text: 'Seleccione destino...' 93 }) 94 ); 95 96 for (var j = 0; j < destinos.length; j++) { 97 $('#selectDestino').append( 98 $('<option>', { 99 value: destinos[j], 100 text: destinos[j] 101 }) 102 ); 103 } 104 } 105 106 valueComboDestino = null; 107 $('#ContentTable').html(''); 108 }; 109 110 window.ValoresDestino = function(valorMostrar) { 111 valueComboDestino = valorMostrar.value; 112 113 if (valueComboDestino && valueComboDestino != 'seleciona') { 114 var resultado = null; 115 for (var i = 0; i < tarifasData.tarifas.length; i++) { 116 if (tarifasData.tarifas[i].origen == valueComboOrigen && 117 tarifasData.tarifas[i].destino == valueComboDestino) { 118 resultado = tarifasData.tarifas[i]; 119 break; 120 } 121 } 122 123 function escapeHtml(text) { 124 var div = document.createElement('div'); 125 div.textContent = text; 126 return div.innerHTML; 127 } 128 129 function formatearNumero(numero) {
130 return parseFloat(numero).toLocaleString('es-ES', { 131 minimumFractionDigits: 2, 132 maximumFractionDigits: 2 133 }); 134 } 135 136 if (resultado) { 137 var html = "<table cellpadding='0' cellspacing='0' class='tablaTarifas'>"; 138 html += "<tr class='trPrin'>"; 139 html += "<td class='tdPrin'>Origen</td>"; 140 html += "<td class='tdPrin'>Destino</td>"; 141 html += "<td class='tdPrin'>Ligeros</td>"; 142 html += "<td class='tdPrin'>Pesados 1</td>"; 143 html += "<td class='tdPrin tdlast'>Pesados 2</td>"; 144 html += "</tr>"; 145 html += "<tr>"; 146 html += "<td class='tdSecond'>" + escapeHtml(resultado.origen) + "</td>"; 147 html += "<td class='tdSecond'>" + escapeHtml(resultado.destino) + "</td>"; 148 html += "<td class='tdSecond'>" + formatearNumero(resultado.ligeros) + "</td>"; 149 html += "<td class='tdSecond'>" + formatearNumero(resultado.pesados1) + "</td>"; 150 html += "<td class='tdSecond tdlast'>" + formatearNumero(resultado.pesados2) + "</td>"; 151 html += "</tr>"; 152 html += "</table>"; 153 154 $('#ContentTable').html(html); 155 } else { 156 $('#ContentTable').html('No se encontró tarifa para esta ruta.'); 157 } 158 } 159 }; 160})(jQuery);
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.