<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>JS on Dripline Documentation</title><link>https://matrix86.github.io/driplane/en/doc/filters/js/</link><description>Recent content in JS on Dripline Documentation</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 16 Sep 2020 22:38:02 +0200</lastBuildDate><atom:link href="https://matrix86.github.io/driplane/en/doc/filters/js/index.xml" rel="self" type="application/rss+xml"/><item><title>Basics</title><link>https://matrix86.github.io/driplane/en/doc/filters/js/basics/</link><pubDate>Wed, 16 Sep 2020 22:38:02 +0200</pubDate><guid>https://matrix86.github.io/driplane/en/doc/filters/js/basics/</guid><description>&lt;h2 id="js"&gt;JS&lt;/h2&gt;
&lt;p&gt;This filter allows to extend the basic &lt;code&gt;driplane&lt;/code&gt;&amp;rsquo;s filter, defining Javascript scripts. It is based on &lt;a href="https://github.com/evilsocket/islazy" target="_blank"&gt;islazy/plugin&lt;/a&gt; which in turn is based on &lt;a href="https://github.com/robertkrimen/otto" target="_blank"&gt;robertkrimen/otto&lt;/a&gt;.&lt;br /&gt;
Defining a JS file with our custom logic, it is possible create a complex filter.&lt;/p&gt;
&lt;h3 id="parameters"&gt;Parameters&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Parameter&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Default&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;path&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;STRING&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;empty&lt;/td&gt;
&lt;td&gt;path of the Javascript file (it can contains multiple functions)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;function&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;em&gt;STRING&lt;/em&gt;&lt;/td&gt;
&lt;td&gt;empty&lt;/td&gt;
&lt;td&gt;name of the function in the JS file to call when a &lt;code&gt;Message&lt;/code&gt; is received&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;div class="notices info" data-title="Example"&gt;
&lt;code&gt;... | js(path=&amp;quot;script.js&amp;quot;, function=&amp;quot;MyFunction&amp;quot;) | ...&lt;/code&gt;
&lt;/div&gt;
&lt;h3 id="output"&gt;Output&lt;/h3&gt;
&lt;p&gt;The output &lt;code&gt;Message&lt;/code&gt; of this filter depends on the return value of the JS function itself.&lt;/p&gt;</description></item><item><title>Entrypoint</title><link>https://matrix86.github.io/driplane/en/doc/filters/js/entrypoint/</link><pubDate>Wed, 16 Sep 2020 22:38:02 +0200</pubDate><guid>https://matrix86.github.io/driplane/en/doc/filters/js/entrypoint/</guid><description>&lt;h2 id="entrypoint"&gt;Entrypoint&lt;/h2&gt;
&lt;p&gt;The JS file consists of one or more functions, and they can be used in different filters or in combination between them.&lt;br /&gt;
The function must respect some constraints:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the function&amp;rsquo;s name contained in the &lt;code&gt;function&lt;/code&gt; parameter of the filter has to start with a capital letter;&lt;/li&gt;
&lt;li&gt;the function prototype must 3 variables;&lt;/li&gt;
&lt;li&gt;the function must return a JS object with at least the &lt;code&gt;filtered&lt;/code&gt; field;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="functions-prototype"&gt;Function&amp;rsquo;s prototype&lt;/h3&gt;
&lt;p&gt;The function&amp;rsquo;s name specified in the &lt;code&gt;function&lt;/code&gt; parameter of the filter, receives 3 input parameters:&lt;/p&gt;</description></item><item><title>Plugin Packages</title><link>https://matrix86.github.io/driplane/en/doc/filters/js/packages/</link><pubDate>Wed, 16 Sep 2020 22:38:02 +0200</pubDate><guid>https://matrix86.github.io/driplane/en/doc/filters/js/packages/</guid><description>&lt;h2 id="packages"&gt;Packages&lt;/h2&gt;
&lt;p&gt;Since the JS doesn&amp;rsquo;t have all the useful functions to perform operations like on file manipulation or http request (see &lt;a href="https://godoc.org/github.com/robertkrimen/otto" target="_blank"&gt;otto docs&lt;/a&gt; for more info), &lt;code&gt;driplane&lt;/code&gt; maps and export to the JS environment some Go functions as packages.&lt;/p&gt;
&lt;div class="alert alert-warning" role="alert" data-dir="ltr"&gt;These mapped functions are not definitive and they could change over time.&lt;/div&gt;
&lt;h3 id="file"&gt;File&lt;/h3&gt;
&lt;p&gt;This package contains functions for manipulating files.&lt;/p&gt;
&lt;h4 id="return"&gt;Return&lt;/h4&gt;
&lt;p&gt;The return value will be a JS object containing 2 fields:&lt;/p&gt;</description></item></channel></rss>