Add extensions
An extension is an HTML file that adds something of yours to LessCode: styles or buttons for the designer, or code that runs with the flow.
On this page
Add one
- Choose Flows → Show the folder of the flows.
- Go to the folder above it. It has
index.jsandextensions.js. - Make a folder called
extensionsthere. - Put your file in it. Its name must end in
.html. - Choose Flows → Restart LessCode.
LessCode reads the folder when it starts. After you change, add or remove an extension, restart it again.
What goes in the file
The part inside <script total> runs once, when the flow starts. The rest goes to the page of the designer.
This one adds an address that says the name of the flow:
<script total>
ROUTE('GET /api/status/', $ => $.json({ name: exports.name, flow: exports.flow.id }));
</script>Save it as status.html, restart LessCode and open http://127.0.0.1:7230/api/status/ in your browser. Call your flow from other apps says how to see the port, if yours is another.
Extensions has a longer example and what the code can use.
With the updates
Updating the app leaves your extensions folder as it is. Do not change the other files of LessCode in that folder: an update puts its own in their place.
An extension can do on your computer all that you can do. Use only those that you have written, or that you have read.