72
| <![CDATA[<script>
$(document).ready(function(){
$(function () {
$('[data-toggle="tooltip"]').tooltip();
})
});
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var urlBase="https://intranet.unasus.gov.br/statistics/";
_paq.push(["setTrackerUrl", urlBase+"piwik.php"]);
_paq.push(["setSiteId", "6"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=urlBase+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>]]>
|
112
| <![CDATA[<script type="text/javascript">
let availableValuesForFields = new Map();
function buildNewSelectWithOptions(selectedField, isAnActivatedField, identifier) {
let inputFilterQueryAsSelect = '';
if (isAnActivatedField) {
inputFilterQueryAsSelect += '<select id="filterquery-selection_' + identifier + '" class="form-control pull-left" style="width: 100%"';
} else {
inputFilterQueryAsSelect = '<select id="filterquery-selection" class="form-control pull-left" style="width: 100%"';
}
inputFilterQueryAsSelect += '>';
availableValuesForFields.get(selectedField).forEach(result => inputFilterQueryAsSelect += ('<option value="' + result + '">' + result + '</option>'));
inputFilterQueryAsSelect += '</select>';
return inputFilterQueryAsSelect;
}
function handleMultivaluedOption(selectedField, fieldValue = "#filterquery", fieldValueSelector = "#filterquery-selection", joinTypeField = "#filtertype", isAnActivatedField = false, identifier) {
$(joinTypeField).prop('selectedIndex', 0);
$(fieldValueSelector).remove();
$(fieldValue).hide();
let inputFilterQueryAsSelect = buildNewSelectWithOptions(selectedField, isAnActivatedField, identifier);
$(fieldValue).after(inputFilterQueryAsSelect);
if (isAnActivatedField) {
let currentValue = $(fieldValue).val();
$(fieldValueSelector + " option[value='" + $(fieldValue).val() + "']").attr('selected', 'selected');
} else {
$(fieldValue).val($(fieldValueSelector).children("option:selected").val());
}
$(fieldValueSelector).click(function () {
$(fieldValue).val($(fieldValueSelector).children("option:selected").val())
});
}
function commonHandleDynamicFields()
{
let identifier = $(this).prop('id');
let currentIndex = identifier.split("_")[2];
let selectedField = $(this).val();
if (availableValuesForFields.get(selectedField))
{
handleMultivaluedOption($("#" + identifier).val(), "#filter_value_" + currentIndex,
"#filterquery-selection_" + currentIndex, "#filter_type_" + currentIndex, true, currentIndex);
}
else
{
$.ajax({
method: "GET",
url: "/acervo/json/discovery/controlledvalues",
data: {selectedField: selectedField}
})
.done(function (results) {
if (results) {
availableValuesForFields.set(selectedField, results);
handleMultivaluedOption($("#" + identifier).val(), "#filter_value_" + currentIndex,
"#filterquery-selection_" + currentIndex, "#filter_type_" + currentIndex, true, currentIndex);
}
else {
$("#filterquery-selection_" + currentIndex).remove();
$("#filter_value_" + currentIndex).val('');
$("#filter_value_" + currentIndex).show();
}
});
}
}
function doFilterChange() {
let selectedField = $(this).val();
if (availableValuesForFields.get(selectedField)) {
handleMultivaluedOption(selectedField, "#filterquery", "#filterquery-selection", "#filtertype");
} else {
$.ajax({
method: "GET",
url: "/acervo/json/discovery/controlledvalues",
data: {selectedField: selectedField}
})
.done(function (results) {
if (results) {
availableValuesForFields.set(selectedField, results);
handleMultivaluedOption(selectedField, "#filterquery", "#filterquery-selection", "#filtertype");
} else {
$("#filterquery-selection").remove();
$("#filterquery").val('');
$("#filterquery").show();
}
});
}
}
$(document).ready(function () {
$('.ui-autocomplete-input').autocomplete({appendTo: '#main-container'});
$('select[id^="filter_field_"]').each(function () {
commonHandleDynamicFields.call(this);
});
$('select[id^="filter_field_"]').change(function () {
commonHandleDynamicFields.call(this);
});
$("#filtername").change(function () {
doFilterChange.call(this);
});
doFilterChange.call($("#filtername"));
$("#spellCheckQuery").click(function () {
$("#query").val($(this).attr('data-spell'));
$("#main-query-submit").click();
});
$("#filterquery")
.autocomplete({
source: function (request, response) {
$.ajax({
url: "/acervo/json/discovery/autocomplete?query=",
dataType: "json",
cache: false,
data: {
auto_idx: $("#filtername").val(),
auto_query: request.term,
auto_sort: 'count',
auto_type: $("#filtertype").val(),
location: 'ARES/2916'
},
success: function (data) {
response($.map(data.autocomplete, function (item) {
var tmp_val = item.authorityKey;
if (tmp_val == null || tmp_val == '') {
tmp_val = item.displayedValue;
}
return {
label: item.displayedValue + " (" + item.count + ")",
value: tmp_val
};
}))
}
})
}
});
});
function validateFilters() {
let isValid = document.getElementById("filterquery").value.length > 0;
return isValid;
}
</script>]]>
|