search.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT
  2. // IT'S ALL JUST JUNK FOR OUR DOCS!
  3. // ++++++++++++++++++++++++++++++++++++++++++
  4. (function () {
  5. 'use strict'
  6. var inputElement = document.getElementById('search-input')
  7. if (!window.docsearch || !inputElement) {
  8. return
  9. }
  10. function getOrigin() {
  11. var location = window.location
  12. var origin = location.origin
  13. if (!origin) {
  14. var port = location.port ? ':' + location.port : ''
  15. origin = location.protocol + '//' + location.hostname + port
  16. }
  17. return origin
  18. }
  19. window.docsearch({
  20. apiKey: 'c8948afa20e6437a6e829f7e87b9ac11',
  21. indexName: 'bootstrap-v3',
  22. inputSelector: '#search-input',
  23. transformData: function (hits) {
  24. return hits.map(function (hit) {
  25. var siteurl = getOrigin()
  26. var urlRE = /^https?:\/\/getbootstrap\.com/
  27. // When in production, return the result as is,
  28. // otherwise remove our url from it.
  29. hit.url = siteurl.match(urlRE) ? hit.url : hit.url.replace(urlRE, '')
  30. // Prevent jumping to first header
  31. if (hit.anchor === 'content') {
  32. hit.url = hit.url.replace(/#content$/, '')
  33. hit.anchor = null
  34. }
  35. return hit
  36. })
  37. },
  38. debug: false // Set debug to true if you want to inspect the dropdown
  39. })
  40. }())