Last active
October 4, 2018 18:27
-
-
Save mish15/6c973b0f7063931bd4ff6b93de816df0 to your computer and use it in GitHub Desktop.
TribLive priority install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Nav autosuggest box</h3> | |
<div id="nav-search-box"></div> | |
<hr> | |
<h3>Results Page</h3> | |
<div id="results-search-box"></div> | |
<div id="results-search-response"></div> | |
<script> | |
var getUrlParam = function(e){var t = new RegExp("[?&]" + e.replace(/[\[\]]/g, "\\$&") + "(=([^&#]*)|&|#|$)"),a = t.exec(window.location.href);return a && a[2] ? decodeURIComponent(a[2].replace(/\+/g, " ")) : ""}; | |
var setup = function(c,a,f){function g(){var a=[],b=function(){a.push(arguments)};b.arr=a;c.sajari=c.sajari||{};c.sajari.ui=c.sajari.ui||[];c.sajari.ui.push(b);return b}var e=a.createElement("script");e.async=!0;e.src=f;var d=a.createElement("link");d.as="script";d.rel="preload";d.crossorigin=!0;d.href=f;a.head.appendChild(d);a.head.appendChild(e);a=g();a.init=function(a){var b=g();b(a);return b};return a}; | |
var sajari = setup(window, document, "//cdn.sajari.net/js/integrations/website-search-1.4.js"); | |
var searchInterface = sajari.init({ | |
mode: "inline", | |
project: "1534384424562720477", // Set this to your project. | |
collection: "triblive-com", // Set this to your collection. | |
pipeline: "website", // Set the search pipeline. | |
instantPipeline: "autocomplete", // Set the instant pipeline. | |
attachSearchBox: document.getElementById("results-search-box"), // DOM element to render search box. | |
attachSearchResponse: document.getElementById("results-search-response"), // DOM element to render search results. | |
inputPlaceholder: "Search", // Placeholder text for the search box. | |
inputAutoFocus: false, // Focus the input element on render. | |
maxSuggestions: 5, // Maximum number of suggestions to show. | |
results: {"showImages": true }, // Configure the results. | |
values: {"q.override": true, "resultsPerPage": "10","q": getUrlParam("q"), "recent": true, "sort": "published-date", "fields": "title,description,image,url,author,category,published-date"}, // Set default values. | |
tabFilters: {defaultTab:"All",tabs:[{title:"All",filter:""},{title:"TribLive",filter:"domain='triblive.com'"},{title:"Sewickley Herald",filter:"domain='sewickley.triblive.com'"},{title:"High School Sports Network",filter:"domain='tribhssn.triblive.com'"}]}, // User selectable filters | |
styling: { theme: { colors: { brand: { primary: "#b32025" }}}} | |
}); | |
var searchBox = setup(window, document, "//cdn.sajari.net/js/integrations/website-search-1.4.js"); | |
var searchBox = sajari.init({ | |
mode: "search-box", | |
project: "1534384424562720477", // Set this to your project. | |
collection: "triblive-com", // Set this to your collection. | |
instantPipeline: "autocomplete", // Pipeline used as you type | |
inputPlaceholder: "Search", // Input element placeholder | |
maxSuggestions: 5, // Maximum number of suggestions to show | |
attachSearchBox: document.getElementById("nav-search-box") // DOM element to attach to | |
}); | |
searchBox("sub", "pipeline.search-sent", function (_, query) { | |
window.location = "/search/?q=" + encodeURIComponent(query.q); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment