Skip to content

JavaScript API

Initialization

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
(function(w, d, s) {
    w.NeuvolaInit = function(n) {
        w.Neuvola = new n({
            debug: true,
            url: "https://covid.neuvola.com/YOUR-LOCATION"
        }, d);
        // You can block the initialization here until needed
        w.Neuvola.init(); // Synchronous initialization
        // You can run your code here after the widged has loaded
        // w.Neuvola, window.Neuvola or just Neuvola will provide the JS API functions.
    };
    var h = d.getElementsByTagName(s)[0],
        j = d.createElement(s);
    j.async = true; // Script will be loaded asynchronously.
    j.src = 'https://js.neuvola.com/widget/v1.js'; // v1 contains the latest major version. Breaking changes will get a new major version number.
    h.parentNode.insertBefore(j, h);
})(window, document, 'script'); // This anonymous function can be configured if the window, codument or script element must be changed.

Calls

1
Neuvola.inject(forceStyle: boolean = false);

Reinjects the widget. forceStyle can be used to re-insert the CSS styles.

1
Neuvola.open();

Opens the popup. Make sure this is triggered synchronously on user input to avoid popup blockers.