The JSDoc for the novomind iAGENT public Javascript APIs can be found here:
You can call the Javascript API by a requirejs call in a javascript file:
requirejs(["js/api-agent-chat"]);
Sample HTML:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:nmc="http://java.sun.com/jsf/composite/common/composites">
<f:view encoding="UTF-8" contentType="text/html">
<h:head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<nmc:jsapi script="js/tabs/javascriptApiChatInfoTab" />
</h:head>
<h:body>
<h:form id="jsApiForm">
<f:passThroughAttribute name="autocomplete" value="off" />
<c:set var="jsApiBean" value="#{vsb.get('JavascriptApiChatInfoTabBean')}" />
<p:panelGrid columns="1">
<p:inputText value="#{vsb.get('JavascriptApiChatInfoTabBean').text}" onkeypress="if (event.keyCode == 13) { return false; }">
<p:ajax event="keyup" update="@(.update-jsapi-button)" process="@this"/>
</p:inputText>
<p:commandButton value="Insert text" id="insertText" onclick="NM.api.chat.agent.chat.editor.insertText('#{jsApiBean.text}', false)" styleClass="update-jsapi-button" />
<p:commandButton value="Insert and select text" id="insertAndSelectText" onclick="NM.api.chat.agent.chat.editor.insertText('#{jsApiBean.text}', true)" styleClass="update-jsapi-button" />
<p:commandButton value="Insert HTML" id="insertHtml" onclick="NM.api.chat.agent.chat.editor.insertHtml('#{jsApiBean.text}', false)" styleClass="update-jsapi-button" />
<p:commandButton value="Insert and select HTML" id="insertAndSelectHtml" onclick="NM.api.chat.agent.chat.editor.insertHtml('#{jsApiBean.text}', true)" styleClass="update-jsapi-button" />
</p:panelGrid>
</h:form>
</h:body>
</f:view>
</html>
The respective Bean:
import com.novomind.ecom.common.api.frontend.CustomBean;
import com.novomind.ecom.common.api.frontend.CustomManagedBean;
@CustomManagedBean("JavascriptApiChatInfoTabBean")
public class JavascriptApiChatInfoTabBean implements CustomBean {
private String text;
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
}