Load a java script library in captivate
Hello captivate-experts
,
I have now taught myself quite a bit about captivate and I still have one issue I cannot resolve.
I want to load a java script library (Fuse.js - JavaScript fuzzy-search library ) and call functions from this.
Unfortunately, I couldn't find any documentation online that describes how to include this .js library and call functions
from it (I want to call it after a learner clicks a button, from the regular javascript code window).
I've tried code like
import 'fuse.js';
and after that I've tried to call functions and deliver an output (see code at the end of this article).
I've also put the library into the folder: "assets\js\" of my published project. Moreover, I've tried to add it
via the Captivate GUI to my project, but the script file won't show in the gui.
I would appreciate it very much if someone could tell me whether it is possible to use java script libraries and call
their functions in captivate. And I would be even happier if someone could post me a link or give me a hint how to
tackle this challenging task.
Best regards & thank you
Max
PS: Here is the whole code I'm trying to run - please don't feel ablidged to read it, I would also be happy to get a general answer ![]()
The code gets a value from an text entry box, creates some variables and then searches for some text in the variables which it reports with an altert (later I will change the text that was searched for by the variable from the text entry box)
# latest stable
$ npm install fuse.js
import 'fuse.js';
var v_input;
var v_input = window.cpAPIInterface.getVariableValue("Text_Entry_Box_3");
var books = [{
'title': "Old Man's War",
'author': 'John Scalzi',
'tags': ['fiction']
}, {
'title': 'The Lock Artist',
'author': 'Steve',
'tags': ['thriller']
}]
var options = {
keys: ['author', 'tags']
};
var fuse = new Fuse(books, options);
fuse.search('tion');
alert(fuse);
