Skip to content

Create widgets

rambousek edited this page Jun 22, 2021 · 4 revisions

It is possible to extend the XML editor in Lexonomy with widgets. For example, buttons to search the corpus and include results into the entry data structure are created as a widget. For more samples, have a look at the directory website/widgets.

There are two types of widgets: configure pages and extensions to the editor.

Configure pages

These widgets take are various dictionary settings, accessible from the Configure page. For example, Configure - Users page is created by widget users.js.

Each widget is JavaScript object with functions. For that reason, first line is

var Users={};

Each configuration widget must include two functions: render() and harvest().

Users.render=function(div, json){
}

Render function will receive configuration data in JSON format from the database in json variable, and create HTML form based on the data. The form is appended to div variable.

Users.harvest=function(div){
}

Harvest function is responsible for data collection. It must collect all relevant data from the form and return then as an object. In the next step, the data are converted to JSON format and stored in the database.

You may create more functions as needed, but render and harvest must be included always.