Adding a search
A search with no setup
Add the script, then put an empty element with the class st-search where you want the search:
<script src="https://scripture.tips/widget/scripturetips.js"></script>
<div class="st-search"></div>
The plugin builds a search field in it. Your visitors can type a passage (John 3:16), some words (so loved the world) or a Strong's number (G26), and the results appear under the field. Picking a passage opens the reader in that same place, in place of the results; typing again goes back to the results.
As they type, the field suggests books and words (the live demo shows it). Nothing needs configuring and no JavaScript needs writing.
Settings in the markup
Set the search's options as data- attributes on the element:
| Attribute | Sets |
|---|---|
data-translations | Which translations to search, by id, separated by spaces or commas, in order of preference. Every translation that may be shown on other sites if left out. |
data-kinds | What to search: reference, text, original (Hebrew and Greek words). All three if left out. |
data-limit | How many verses to fetch at a time (1 to 50). More come as the visitor scrolls. |
data-more | How a long list goes on: scroll (the default: the next page loads as the visitor nears the end), button (a Show more button) or none (the list stops at data-limit). |
data-placeholder | The words in the empty field. |
data-search-on-type | true to search as the visitor types, once typing pauses, instead of waiting for Enter. |
<div class="st-search" data-translations="eng-kjv eng-web" data-limit="10"></div>
The same from JavaScript
ScriptureTips.search does the same, and takes more options (all the search options):
ScriptureTips.search({ element: "#find", translations: ["eng-kjv"] });
It answers with a promise of the search, or null when the page has no such element.
The credit
A search carries one small, muted line at its foot, Powered by ScriptureTips, that links to https://scripture.tips. It is words only and takes the search's muted color. Translate it with the poweredBy string of the strings option.
Only loaded when used
The search's code is a separate file, loaded from beside the plugin's script when the page has a search. Pages that only link references don't download it.
See it working in the live demos.