Perform book metadata lookups on openlibrary.org. Like other frontend adapters, it is shallow and does not care for language, authorship, or other details.

Hierarchy (View Summary)

Constructors

Properties

ac?: default<any>

After AbstractAutocompleteAdapter#setupAutocomplete is run, holds a reference to the autocomplete widget used by this instance.

acCSSPrefix: string = 'ac-adapter-'

CSS prefix for the autocomplete widget.

acDelay: number = 300

Delay in milliseconds before performing a search.

acPrimaryTextKey: string = 'label'

Key (into the row objects retrieved via the request handler) that determines which value is used as the main text in the autocomplete widget.

'label' corresponds to what the main application expects, but if you want to show something different than what gets passed to the application, you may want to change it.

acSecondaryTextKey: string = 'description'

Default row key for the optional secondary, smaller text shown in the autocomplete widget below each result.

limit: number
searchBoxSelector: string
sourceID?: string

Canonical identifier for this source. Lower-case string, no whitespace.

supportedPattern?: RegExp

RegExp for URLs this adapter can handle.

updateCallback: Function | UpdateCallback

Callback to run after a successful lookup

Methods

  • Query the Open Library's main search endpoint for this search string, store the results in the instance of the autocomplete widget, and render them.

    Fires off two requests per query to perform both a stemmed search and a wildcard search. Optionally also supports author searches if split off from main query string with ";".

    Parameters

    • this: default<AutocompleteRow>
    • query: string

      the unescaped query string

    Returns void

  • Pass along row data we can handle to the main application. Will also query lib.reviews itself (through the native adapter) for the URL, so we can give preferential treatment to an existing native record for the review subject.

    Parameters

    • row: { description?: string; label?: string; subtitle?: string; url?: string }

      row data object. All properties except "url" are only used for display purposes, since the server performs its own lookup on the URL.

    • event: Event

      the click or keyboard event which triggered this row selection.

    Returns void

  • Merge results from two Open Library search queries into a single array. The overall size will not exceed this.limit.

    Parameters

    • results: OpenLibrarySearchResult[]

      set of results from two or more search queries

    Returns OpenLibrarySearchResult

    de-duplicated result array

  • Perform an in-place sort on results from a search query, putting any exact matches against the query first

    Parameters

    • docs: OpenLibrarySearchDoc[]

      "docs" array from the Open Library JSON search API

    • query: string

      original query text that yielded this result

    Returns void