// Copyright (c) 2010-2022 Quadralay Corporation. All rights reserved.
//
// ePublisher 2022.1
//
// IMPORTANT: global variables are modified by search.xsl and should not be changed.
var GLOBAL_MINIMUM_WORD_LENGTH = 3;
var GLOBAL_STOP_WORDS_ARRAY = 'a about after all also am an and another any are as at be because been before being between both but by came can come copyright corp corporation could did do does each etc for from get goes got had has have he her here him himself his how if in inc into is it its let like make many me might more most much must my never nor not now of off on one only or other our out over own reserved rights said same see set shall she should since so some still such take than that the their them then there these they this those though through to too under us use very was way we well were what when where which while who why will with would yes yet you your'.split(' ');
var GLOBAL_NO_SEARCH_RESULTS_CONTAINER_HTML = '
');
if (pageUri) {
var fileTypeIcons, resultTitleClasses;
fileTypeIcons = '';
resultTitleClasses = 'search_result_title';
// Build HTML according to what type of search result this is
//
switch (pageType) {
case 'internal-html':
resultTitleClasses += ' search_result_internal_html';
fileTypeIcons = '
';
break;
case 'internal-pdf':
resultTitleClasses += ' search_result_internal_pdf';
fileTypeIcons = '
';
break;
case 'external-html':
resultTitleClasses += ' search_result_external_html';
fileTypeIcons = '
' +
'
';
break;
case 'external-pdf':
resultTitleClasses += ' search_result_external_html';
fileTypeIcons = '
' +
'
';
break;
case 'content-page':
default:
resultTitleClasses += ' search_result_content_page';
break;
}
buffer.push('
');
}
if (page[2].length > 0) {
buffer.push('
' + SearchClient.EscapeHTML(page[2]) + '
');
}
if (groupTitle !== '' && groupTitle !== undefined && groupTitle !== null) {
buffer.push('
' + groupTitle + '
');
}
buffer.push('
');
}
}
container = window.document.getElementById('search_results_container');
Search.WriteSearchStateMessage(pages_array.length);
if (buffer.length === 0) {
container.innerHTML = GLOBAL_NO_SEARCH_RESULTS_CONTAINER_HTML;
} else {
container.innerHTML = buffer.join('\n');
}
this_reference.search_complete.method.call(this_reference.search_complete.object, this_reference.search_complete.object, null);
});
};
this.clearAllResults = function () {
var container, data, search_results_count_container;
container = window.document.getElementById('search_results_container');
container.innerHTML = '';
search_results_count_container = window.document.getElementById('search_results_count_container');
if (search_results_count_container !== null) {
search_results_count_container.style.display = 'none';
}
data = {
'action': 'search_complete',
'query': Search.query,
'dimensions': Browser.GetWindowContentWidthHeight(Search.window)
};
Message.Post(Search.window.parent, data, Search.window);
};
this.performAfterDelay = function (param_function) {
if (!Search.cancel && Search.query.length > 0) {
setTimeout(param_function);
} else {
Search.executing = false;
Search.cancel = false;
}
};
};
Search.Execute = function (param_query) {
'use strict';
var search_input;
// Check for a search query string and execute it
//
if (Search.control.is_done) {
// Update search words
//
if (Search.executing && (Search.query !== param_query)) {
Search.cancel = true;
}
if (param_query !== undefined) {
Search.query = param_query;
}
if (Search.query !== '') {
if (Search.executing) {
// Try again while search cancels
//
setTimeout(function () {
Search.Execute(Search.query);
});
} else {
// Search!
//
Search.control.execute(Search.query);
Search.cancel = false;
Search.executing = false;
}
} else {
Search.control.clearAllResults();
}
}
else {
Search.control.loadDataQueue();
}
};
Search.Listen = function (param_event) {
'use strict';
if (Search.dispatch === undefined) {
Search.dispatch = {
'search_load': function (param_data) {
Search.Load();
},
'search_get_page_size': function (param_data) {
var data;
data = {
'action': 'search_page_size',
'dimensions': Browser.GetWindowContentWidthHeight(Search.window),
'stage': param_data.stage
};
Message.Post(Search.window.parent, data, Search.window);
},
'search_connect_info': function (param_data) {
var data;
if (!Search.ready) {
Search.Load();
} else {
Search.connect_info = param_data;
delete Search.connect_info['action'];
// Load filter message
//
if (Search.connect_info.search_scope_selection_titles !== undefined) {
if (Search.connect_info.search_scope_map !== undefined) {
document.getElementById('search_filter_message_container').style.display = 'block';
document.getElementById('search_filter_by_groups').innerHTML = Search.connect_info.search_scope_selection_titles
}
else {
document.getElementById('search_filter_message_container').style.display = 'none';
}
}
// Load Group titles to object for Search Results
//
if (Search.connect_info.search_scopes !== undefined) {
Search.CreateGroupTitlesObject(Search.connect_info.search_scopes);
}
Search.Execute(param_data.query);
}
}
};
}
try {
// Dispatch
//
Search.dispatch[param_event.data.action](param_event.data);
} catch (ignore) {
// Keep on rolling
//
}
};
Search.SearchQueryHighlight = function (param_search_query) {
'use strict';
var search_results_container, expressions, html_elements, require_whitespace;
// Locate search results container
//
search_results_container = window.document.getElementById('search_results_container');
// Remove highlights
//
Highlight.RemoveFromHierarchy(Search.window.document, search_results_container, 'search_result_highlight');
// Highlight words
//
if (param_search_query !== undefined && param_search_query !== '') {
// Convert search query into expressions
//
expressions = SearchClient.SearchQueryToExpressions(param_search_query, Search.control.all_synonyms, Search.control.minimum_word_length, Search.control.stop_words);
// Apply highlights
//
require_whitespace = true;
html_elements = Search.window.document.getElementsByTagName('html');
if (html_elements.length > 0) {
require_whitespace = (html_elements[0].getAttribute('data-highlight-require-whitespace') === 'true');
}
Highlight.ApplyToHierarchy(Search.window.document, search_results_container, 'search_result_highlight', expressions, require_whitespace);
}
};
Search.SearchResultCount = function (param_result_count) {
'use strict';
// Hide search loading container and show search result count container
//
var search_results_count_container, search_results_loading_container, count_span, count_formatted, has_all_elements;
search_results_count_container = window.document.getElementById('search_results_count_container');
search_results_loading_container = window.document.getElementById('search_results_loading_container');
count_span = window.document.getElementById('search_results_count');
has_all_elements = search_results_count_container && search_results_loading_container && count_span;
if (has_all_elements && !isNaN(param_result_count)) {
search_results_loading_container.style.display = 'none';
search_results_count_container.style.display = 'block';
count_formatted = param_result_count.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
count_span.innerHTML = count_formatted;
}
};
Search.SearchResultLoading = function () {
'use strict';
// Hide search result count container and show search loading container
//
var search_results_count_container, search_results_loading_container, has_all_elements;
search_results_count_container = window.document.getElementById('search_results_count_container');
search_results_loading_container = window.document.getElementById('search_results_loading_container');
has_all_elements = search_results_count_container && search_results_loading_container;
if (has_all_elements) {
search_results_count_container.style.display = 'none';
search_results_loading_container.style.display = 'block';
}
};
Search.WriteSearchStateMessage = function (param_result_count) {
'use strict';
if (Search.control.is_done) {
Search.SearchResultCount(param_result_count);
} else {
Search.SearchResultLoading();
}
};
Search.CreateGroupTitlesObject = function (param_search_scopes) {
'use strict';
var search_scopes, search_scope, scope_context, scope_title;
search_scopes = param_search_scopes;
if (typeof search_scopes !== 'undefined') {
for (var i = 0; i < search_scopes.length; i++) {
search_scope = search_scopes[i];
if (typeof search_scope['title'] !== 'undefined' &&
typeof search_scope['id'] !== 'undefined') {
scope_context = search_scope['id'];
scope_title = search_scope['title'];
Search.group_titles[scope_context] = scope_title;
}
if (typeof search_scope['children'] !== 'undefined') {
Search.CreateGroupTitlesObject(search_scope['children']);
}
}
}
};
Search.SendWindowClicked = function () {
'use strict';
var data;
data = {
'action': 'search_page_clicked'
};
Message.Post(Search.window.parent, data, Search.window);
};
Search.SendSearchHelpfulButtonClick = function (param_value) {
var data, helpful_rating_object, search_query;
helpful_rating_object = Browser.GetLocalStorageItem('search_helpful_rating');
if (helpful_rating_object !== null) {
search_query = Search.query.replace(/\s+/g, " ").trim();
if (!helpful_rating_object.hasOwnProperty(search_query) || helpful_rating_object[search_query] !== param_value) {
helpful_rating_object[search_query] = param_value;
try {
Browser.UpdateLocalStorageItem('search_helpful_rating', helpful_rating_object);
} catch (e) {
helpful_rating_object = {};
helpful_rating_object[search_query] = param_value;
Browser.DeleteLocalStorageItem('search_helpful_rating');
Browser.CreateLocalStorageItem('search_helpful_rating', helpful_rating_object);
}
Search.SetSelectedStateForHelpfulButton(param_value);
data = {
'action': 'search_helpful_button_click',
'helpful': param_value,
'href': Search.window.document.location.href
};
Message.Post(Search.window.parent, data, Search.window);
} else {
//do nothing
}
}
};
Search.Load = function () {
'use strict';
var onSearchLinkClick, onSearchLinkClickInBaggage, onSearchLinkClickInExternalBaggage, onSearchComplete, search_page_load_data, helpful_button, unhelpful_button, helpful_rating;
// Define callbacks
//
onSearchLinkClick = function (param_event) {
var data;
data = {
'action': 'search_display_link',
'href': this.href,
'title': this.innerText,
'minimum_word_length': Search.control.minimum_word_length,
'stop_words': Search.control.stop_words
};
Message.Post(Search.window.parent, data, Search.window);
return false;
};
onSearchLinkClickInBaggage = function (param_event) {
var data, require_whitespace, html_elements;
require_whitespace = true;
html_elements = Search.window.document.getElementsByTagName('html');
if (html_elements.length > 0) {
require_whitespace = (html_elements[0].getAttribute('data-highlight-require-whitespace') === 'true');
}
data = {
'wwr_a': 'search_display_link',
'wwr_rws': require_whitespace,
'wwr_q': Search.query,
'wwr_s': Search.control.all_synonyms,
'wwr_mwl': Search.control.minimum_word_length,
'wwr_sw': Search.control.stop_words
};
window.localStorage['wwreverbsearch'] = JSON.stringify(data);
window.open(this.href);
return false;
};
onSearchLinkClickInExternalBaggage = function (param_event) {
var params, require_whitespace, html_elements;
require_whitespace = true;
html_elements = Search.window.document.getElementsByTagName('html');
if (html_elements.length > 0) {
require_whitespace = (html_elements[0].getAttribute('data-highlight-require-whitespace') === 'true');
}
params = "wwr_a=search_display_link" +
"&wwr_rws=" + Browser.EncodeURIComponentIfNotEncoded(require_whitespace) +
"&wwr_q=" + Browser.EncodeURIComponentIfNotEncoded(Search.query) +
"&wwr_s=" + Browser.EncodeURIComponentIfNotEncoded(Search.control.synonyms) +
"&wwr_mwl=" + Browser.EncodeURIComponentIfNotEncoded(Search.control.minimum_word_length) +
"&wwr_sw=" + Browser.EncodeURIComponentIfNotEncoded("");
// NOTE: sending empty dictionary of stop words -- too long
if (this.href.indexOf('?') === -1) {
params = '?' + params;
}
else {
params = '&' + params;
}
window.open(this.href + params);
return false;
};
onSearchComplete = function (param_search_control, param_searcher) {
var index, link, search_uri, encoded_search_uri, data;
// Intercept search result links
//
for (index = 0; index < window.document.links.length; index += 1) {
link = window.document.links[index];
if (link.target === 'connect_page') {
// Same hierarchy?
//
if (Browser.SameHierarchy(Search.connect_info.base_url, link.href)) {
// Verify parcel is known
//
if ((Search.KnownParcelURL(link.href)) && (!Search.KnownParcelBaggageURL(link.href))) {
// Handle via Connect run-time
//
link.onclick = onSearchLinkClick;
} else {
// Open in a new window
//
link.target = '_blank';
// Assigning the new function to the onclick event
//
link.onclick = onSearchLinkClickInBaggage;
}
} else {
// Open in a new window
//
link.target = '_blank';
// Assigning the new function to the onclick event even when it's not of the SameHierarchy but it could be an External URL
//
link.onclick = onSearchLinkClickInExternalBaggage;
}
}
}
Browser.CreateLocalStorageItem('search_helpful_rating', {});
helpful_button = document.getElementById('helpful_thumbs_up');
unhelpful_button = document.getElementById('helpful_thumbs_down');
if (helpful_button !== null && unhelpful_button !== null) {
helpful_button.onclick = function () { Search.SendSearchHelpfulButtonClick('yes'); };
unhelpful_button.onclick = function () { Search.SendSearchHelpfulButtonClick('no'); };
helpful_rating = Search.GetHelpfulRating();
if (helpful_rating !== undefined) {
Search.SetSelectedStateForHelpfulButton(helpful_rating);
} else {
Search.ResetSelectedStateForHelpfulButtons();
}
}
// Highlight search words and phrases
//
Search.SearchQueryHighlight(Search.query);
// Notify parent
//
data = {
'action': 'search_complete',
'query': Search.query,
'synonyms': Search.control.all_synonyms,
'dimensions': Browser.GetWindowContentWidthHeight(Search.window)
};
Message.Post(Search.window.parent, data, Search.window);
Search.executing = false;
Search.cancel = false;
};
// Search control settings
//
Search.control = new Search.InBrowser_Object();
Search.control.setSearchCompleteCallback(this, onSearchComplete);
Search.control.setLinkTarget('connect_page');
Browser.TrackDocumentChanges(Search.window, Search.window.document, Search.ContentChanged);
Search.window.onresize = Search.ContentChanged;
Search.ready = true;
// Ready to search
//
search_page_load_data = {
'action': 'search_page_load_data',
'dimensions': Browser.GetWindowContentWidthHeight(Search.window)
};
Message.Post(Search.window.parent, search_page_load_data, Search.window);
};
Search.GetHelpfulRating = function () {
var helpful_rating, helpful_rating_object, search_query;
helpful_rating = null;
search_query = Search.query.replace(/\s+/g, " ").trim();
helpful_rating_object = Browser.GetLocalStorageItem('search_helpful_rating');
if (helpful_rating_object !== null) {
if (helpful_rating_object.hasOwnProperty(search_query)) {
helpful_rating = helpful_rating_object[search_query];
}
}
return helpful_rating;
};
Search.SetSelectedStateForHelpfulButton = function (param_helpful_rating) {
'use strict';
var helpful_button, unhelpful_button;
helpful_button = document.getElementById("helpful_thumbs_up");
unhelpful_button = document.getElementById("helpful_thumbs_down");
helpful_button.className = Browser.ReplaceClass(helpful_button.className, 'ww_skin_was_this_helpful_button_selected', 'ww_skin_was_this_helpful_button');
unhelpful_button.className = Browser.ReplaceClass(unhelpful_button.className, 'ww_skin_was_this_helpful_button_selected', 'ww_skin_was_this_helpful_button');
if (param_helpful_rating == 'yes') {
helpful_button.className = Browser.ReplaceClass(helpful_button.className, 'ww_skin_was_this_helpful_button', 'ww_skin_was_this_helpful_button_selected');
} else if (param_helpful_rating == 'no') {
unhelpful_button.className = Browser.ReplaceClass(unhelpful_button.className, 'ww_skin_was_this_helpful_button', 'ww_skin_was_this_helpful_button_selected');
}
};
Search.ResetSelectedStateForHelpfulButtons = function () {
var helpful_button, unhelpful_button;
helpful_button = document.getElementById("helpful_thumbs_up");
unhelpful_button = document.getElementById("helpful_thumbs_down");
helpful_button.className = Browser.ReplaceClass(helpful_button.className, 'ww_skin_was_this_helpful_button_selected', 'ww_skin_was_this_helpful_button');
unhelpful_button.className = Browser.ReplaceClass(unhelpful_button.className, 'ww_skin_was_this_helpful_button_selected', 'ww_skin_was_this_helpful_button');
};
Search.ContentChanged = function () {
"use strict";
var data;
data = {
action: "search_page_size",
dimensions: Browser.GetWindowContentWidthHeight(Search.window)
};
Message.Post(Search.window.parent, data, Search.window);
return true;
};
Search.HandleRedirect = function () {
'use strict';
if (Search.window === Search.window.top && Search.window.navigator.userAgent.indexOf('bot/') === -1) {
// Redirect
//
var event_or_redirect_url;
if (document.getElementById('search_onload_url')) {
event_or_redirect_url = document.getElementById('search_onload_url').value;
}
if (event_or_redirect_url && typeof event_or_redirect_url === 'string') {
var redirect_url;
redirect_url = event_or_redirect_url;
if (Search.window.document.location.hash.length > 1) {
// Sanitize and append it
//
search_hash = Search.window.document.location.hash.substring(1);
search_hash = search_hash.replace(/[\\<>:;"']|%5C|%3C|%3E|%3A|%3B|%22|%27/gi, '');
redirect_url += '#' + search_hash;
}
Search.window.document.location.replace(redirect_url);
}
}
};
// Handle load
//
//Search.OnLoad = function () {
// 'use strict';
//
// if (!Search.loading) {
// Search.loading = true;
// Search.Load();
// }
//};
// Start running as soon as possible
//
if (window.addEventListener !== undefined) {
window.addEventListener('load', Search.HandleRedirect, false);
} else if (window.attachEvent !== undefined) {
window.attachEvent('onload', Search.HandleRedirect);
}
window.onclick = function (event) {
Search.SendWindowClicked();
};
// Setup for listening
//
Message.Listen(window, function (param_event) {
Search.Listen(param_event);
});