121
| <![CDATA[<script type="text/javascript">
$(function () {
var linha, estacao, estacaoLinha, nomeClasse;
$.ajax({
type: "GET",
url: "/app/trajeto/xt/estacoesTipoXML.asp",
dataType: "xml",
success: function (xml) {
$(xml).find("estacoes").each(function () {
$(this).find('estacao').each(function () {
linha = $(this).attr("tipo") + " - Linha " + $(this).attr("linha");
var codigoLinha = 0;
codigoLinha = $(this).attr("linha").split('-')[0];
nomeClasse = "linha" + codigoLinha;
var estacaoId = $(this).attr("estacaoId");
estacaoLinha = $(this).attr("nome") + " <span class='" + nomeClasse + "'>(" + linha + ")</span>";
estacao = $(this).attr("nome");
$("#embarque")[0].options[$("#embarque")[0].options.length] = new Option(estacaoLinha, estacaoId);
$("#desembarque")[0].options[$("#desembarque")[0].options.length] = new Option(estacaoLinha, estacaoId);
});
});
}
});
});
(function ($) {
$.widget("ui.combobox", {
_create: function () {
var self = this,
select = this.element.hide(),
selected = select.children(":selected"),
value = selected.val() ? selected.text() : "";
var input = this.input = $("<input>")
.insertAfter(select)
.val(value)
.autocomplete({
delay: 0,
minLength: 0,
source: function (request, response) {
var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
response(select.children("option").map(function () {
var text = $(this).text();
if (this.value && (!request.term || matcher.test(text)))
return {
label: text.replace(
new RegExp(
"(?![^&;]+;)(?!<[^<>]*)(" +
$.ui.autocomplete.escapeRegex(request.term) +
")(?![^<>]*>)(?![^&;]+;)", "gi"
), "<strong>$1</strong>"),
value: text.replace(/<[^>]*>/g, ""),
option: this
};
}));
},
select: function (event, ui) {
ui.item.option.selected = true;
self._trigger("selected", event, {
item: ui.item.option
});
},
change: function (event, ui) {
if (!ui.item) {
var matcher = new RegExp("^" + $.ui.autocomplete.escapeRegex($(this).val()) + "$", "i"),
valid = false;
select.children("option").each(function () {
if ($(this).text().match(matcher)) {
this.selected = valid = true;
return false;
}
});
if (!valid) {
$(this).val("");
select.val("");
input.data("autocomplete").term = "";
//alert("XML"+select.children(":selected").val()+"-"+selected.text());
return false;
}
}
}
})
.addClass("ui-widget ui-widget-content ui-corner-left");
input.data("autocomplete")._renderItem = function (ul, item) {
return $("<li></li>")
.data("item.autocomplete", item)
.append("<a>" + item.label + "</a>")
.appendTo(ul);
};
this.button = $("<button type='button'> ;</button>")
.attr("tabIndex", -1)
.attr("title", "Todas as estações")
.insertAfter(input)
.button({
icons: {
primary: "ui-icon-triangle-1-s"
},
text: false
})
.removeClass("ui-corner-all")
.addClass("ui-corner-right ui-button-icon")
.click(function () {
if (input.autocomplete("widget").is(":visible")) {
input.autocomplete("close");
return;
}
$(this).blur();
input.autocomplete("search", "");
input.focus();
});
},
destroy: function () {
this.input.remove();
this.button.remove();
this.element.show();
$.Widget.prototype.destroy.call(this);
}
});
})(jQuery);
$(function () {
$("#embarque, #desembarque").combobox();
$("#toggle").click(function () {
$("#embarque, #desembarque").toggle();
});
});
function enviar() {
var origemId = $("#embarque").val();
var destinoId = $("#desembarque").val();
if (destinoId != "0" && origemId != "0") {
if (origemId == destinoId) {
alert("The place of landing must be different from the place of embarkation");
} else {
document.location.href = "trajeto.aspx?origemId=" + origemId + "&destinoId=" + destinoId;
}
} else {
alert("Selecione os locais de embarque e desembarque");
}
}
function exibeMapa() {
$("#buscaMapa").toggle();
}
</script>]]>
|
919
| <![CDATA[<script type="text/javascript">
$(function () {
var linha, estacao, estacaoLinha, xmlEstacao;
var caminhoXml = '/app/trajeto/xt/estacoesTipoXML.asp';
$.ajax({
type: "GET",
url: caminhoXml,
dataType: "xml",
success: function (xml) {
$(xml).find("estacoes").each(function () {
$(this).find("estacao").each(function () {
linha = $(this).attr("tipo") + " - Linha " + $(this).attr("linha");
estacao = $(this).attr("nome");
estacaoId = $(this).attr("estacaoId");
xmlEstacao = this;
$("#selectEmbarque")[0].options[$("#selectEmbarque")[0].options.length] = new Option(estacao + ' (' + linha + ')', estacaoId);
$("#selectDesembarque")[0].options[$("#selectDesembarque")[0].options.length] = new Option(estacao + ' (' + linha + ')', estacaoId);
});
});
$("#selectEmbarque").change(function () {
estacaoLinha = $(this).val();
if (estacaoLinha != 0) {
$(xml).find("linha").each(function () {
$(this).find("estacao").each(function () {
xmlEstacao = this;
if (estacaoLinha == $(xmlEstacao).attr('estacaoId')) {
selecionado();
}
});
});
}
});
$("#selectDesembarque").change(function () {
estacaoLinha = $(this).val();
if (estacaoLinha != 0) {
$(xml).find("linha").each(function () {
$(this).find("estacao").each(function () {
xmlEstacao = this;
if (estacaoLinha == $(xmlEstacao).attr('estacaoId')) {
selecionado();
}
});
});
}
});
}
});
});
var alertaDisparado = false;
function selecionado() {
var embarque = document.getElementById('selectEmbarque');
var desembarque = document.getElementById('selectDesembarque');
if (desembarque.value != "0" && embarque.value != "0") {
if (desembarque.value == embarque.value) {
if (!alertaDisparado) {
alert("The place of Arrival must be different from the place of boarding");
alertaDisparado = true;
} else {
alertaDisparado = false;
}
} else {
window.location.href = "/en/your-trip/where-are-you-going/trajeto.aspx?origemId=" + embarque.value + "&destinoId=" + desembarque.value;
}
}
}
var slDesembarque = document.getElementById('selectDesembarque');
var slEmbarque = document.getElementById('selectEmbarque');
if (window.addEventListener) {
slDesembarque.addEventListener('change', selecionado, false);
slEmbarque.addEventListener('change', selecionado, false);
} else {
slDesembarque.attachEvent('onchange', selecionado);
slEmbarque.attachEvent('onchange', selecionado);
}
</script>]]>
|