Help › Website plugin 1.0

The JavaScript API

The script declares one global, ScriptureTips.

run(selector, options?)

Links the references in what the selector matches, and in what is added there later. The options are read the first time it is called; later calls add areas.

rescan(element?)

Looks again now: at one element, or at every area. Content added to a linked area is picked up by itself, so this is only needed when text changes in place.

ScriptureTips.rescan(document.querySelector("#preview"));

setPreferences({ translation })

Tells the plugin the translation this visitor prefers, for a site that knows (from an account, say). It is used after the visitor's own choice for a link and after a translation the text names, and before your site's default. It may be called before run.

ScriptureTips.setPreferences({ translation: "leb" });

on(event, handler)

Listens for an event, and returns a function that stops listening. It may be called before run.

EventWhenThe handler receives
tooltip-openA tooltip opened{ reference, translation }
translation-changeA visitor chose another translation in a tooltip{ reference, translation }
scanReferences were found and linked{ linked }, how many
const stop = ScriptureTips.on("tooltip-open", (e) => {
  console.log(e.reference, e.translation); // "John.3.16", "eng-kjv"
});
stop();

reference is the passage in OSIS form (John.3.16, Rom.5.8-Rom.5.10).