Created
October 10, 2018 04:24
-
-
Save benhinchley/a30c13cc2a46e7a15176edd5ee10d606 to your computer and use it in GitHub Desktop.
updated integration code for triblive search results
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
<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 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); | |
}); | |
// new script for triblive search results integration | |
setup(window, document, "//cdn.sajari.net/js/integrations/client/triblive-search-integration.js"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment