You are leaving uat.girlscouts.org
for a website operated by an external party. You will be subject to the
privacy and security policies of that website.
NTest_Algolia_Search
function safeUrl(url) {
if (url == null || typeof url !== 'string') return '#';
var u = url.trim().toLowerCase();
return (u.indexOf('http://') === 0 || u.indexOf('https://') === 0) ? url : '#';
}
function safeHref(url) {
var u = safeUrl(url);
if (u === '#') return '#';
return u.replace(/"/g, '"').replace(/'/g, ''').replace(/0) query = myQuery;
const url = 'https://'+ appId+'-dsn.algolia.net/1/indexes/'+indexName+'/query'; // Read operation URL
fetch(url, {
method: 'POST', // or 'GET' for simpler queries
headers: {
'X-Algolia-API-Key': apiKey,
'X-Algolia-Application-Id': appId,
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: query,
hitsPerPage: _resultsPerPage,
page: startIndex, // page starts at 0
highlightPreTag: '',
highlightPostTag: '',
attributesToSnippet: [
'content:80'
]
}) // Search parameters in the body
})
.then(response => response.json())
.then(data => {
SearchCompleted(data);
});
}
var this_response = null;
var paginationDone = false;
function SearchCompleted(response) {
$("#algolia-sr-output").removeClass('algolia-sr-output-disabled');
var html = "";
$("#algolia-sr-output").html(html);
$("#algolia-sr-status").html("");
if (response.hits == null || response.hits.length === 0) {
// $("#algolia-sr-pagination-output").html("");
// paginationDone = false;
$("#algolia-sr-status").html("No matching results found");
$("#algolia-sr-output").html("");
$(".algolia-load-more-btn").attr("hidden", true);
// startIndex = 0;
$('html, body').animate({
scrollTop: $(".algolia-searchresult-maindiv").offset().top - 180
}, 1000);
return;
}
var no_of_pages = Math.ceil((response.nbHits > (_totalPages *
_resultsPerPage) ? (_totalPages * _resultsPerPage > 100 ? 100 : _totalPages *
_resultsPerPage) : (response.nbHits > 100 ? 100 : response
.nbHits)) / _resultsPerPage);
if (response.nbHits == 0) {
$('.algolia-load-more-btn').attr('hidden', true);
$(".searchpage-pagination").css("display", "none");
}
$("#algolia-sr-status").html("About " + addCommas(response.nbHits > 100 ? 100 :
response.nbHits) + " results found");
$("[id*=sr-lblPageNumber]").removeClass("sr-current-page");
$("#sr-lblPageNumber" + _pageNumber).addClass("sr-current-page");
for (var i = 0; i < response.hits.length; i++) {
var item = response.hits[i];
var thumbnail = "";
if (item.url.match(".pdf$") != null) {
thumbnail = '/content/dam/gsusa-redesign/pdf.gif';
} else if (item.url.match(".doc$") != null || item.url.match(".docx$") != null) {
thumbnail = '/content/dam/gsusa-redesign/doc.gif';
} else if (item.url.match(".xls$") != null || item.url.match(".xlsx$") != null) {
thumbnail = '/content/dam/gsusa-redesign/xls.gif';
} else if (item.url.match(".ppt$") != null || item.url.match(".pptx$") != null) {
thumbnail = '/content/dam/gsusa-redesign/ppt.gif';
}
var headingClass = "heading-text" + (thumbnail.length == 0 ? " noicon" : "");
html += "
";
html += thumbnail.length > 0 ? "" : "";
html += "" + highlight(
q, item.title || '') + "";
html += "" + escapeHtml((item._highlightResult && item._highlightResult.url && item._highlightResult.url.value) ? item._highlightResult.url.value : item.url) + "";
html += "