From 601b1ff2e4a8bea4d2b0ec1bf16c00664623f737 Mon Sep 17 00:00:00 2001
From: Pierre Ranwez <pierre.ranwez.etu@univ-lille.fr>
Date: Thu, 24 Feb 2022 19:40:46 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20improve:=20code=20heritage?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 README.html |  3 ++-
 README.md   |  4 +++-
 main.js     | 32 ++++++++++++++++----------------
 3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/README.html b/README.html
index f3f4c4f..06badab 100644
--- a/README.html
+++ b/README.html
@@ -1430,7 +1430,8 @@ You can put &quot;element&quot; tab to bottom by right-clicking on it.
 For deported devtool, click on more (top-right) and then click on separate devtool dock.</p>
 <p><img src="file:///d:\Cours\M2S4\PFE\csslsd\doc\devtool.gif" alt="Devtool view"></p>
 <h3 id="csslsd-code">CSSLSD Code</h3>
-<p>You need to use a custom CSS template, like below to map your audio or MIDI events to some CSSLSD properties. All parameters are between <strong>square brackets</strong> you can extend parameter by heritage with a range like bellow (this is not mandatory). You can use multiple parameters in a line. You can also type pure CSS in code editor, this CSS wil be apply on code auto-save (each time your type something in editor).</p>
+<p>You need to use a custom CSS template, like below to map your audio or MIDI events to some CSSLSD properties. All parameters are between <strong>square brackets</strong>. You can use multiple parameters in a line. You can also type pure CSS in code editor, this CSS wil be apply on code auto-save (each time your type something in editor).</p>
+<p>You can extend parameter by heritage with template <code>[&lt;parameter&gt; &lt;type&gt; &lt;option&gt; &lt;audio or midi control&gt;]</code>. This is not mandatory to type all heritage, but you need to restect the direction. This is allowed : <code>[&lt;parameter&gt; &lt;type&gt; &lt;option&gt;]</code> or <code>[&lt;parameter&gt; &lt;type&gt;]</code>. This is <strong>not</strong> allowed : <code>[&lt;parameter&gt; &lt;audio or midi control&gt;]</code>.</p>
 <p>Code example:</p>
 <pre><code class="language-css"><div><span class="hljs-selector-tag">body</span> {
     <span class="hljs-comment">/* Tip : You can use comments */</span>
diff --git a/README.md b/README.md
index 14ff80e..bf1c26a 100644
--- a/README.md
+++ b/README.md
@@ -71,7 +71,9 @@ For deported devtool, click on more (top-right) and then click on separate devto
 
 ### CSSLSD Code
 
-You need to use a custom CSS template, like below to map your audio or MIDI events to some CSSLSD properties. All parameters are between **square brackets** you can extend parameter by heritage with a range like bellow (this is not mandatory). You can use multiple parameters in a line. You can also type pure CSS in code editor, this CSS wil be apply on code auto-save (each time your type something in editor).
+You need to use a custom CSS template, like below to map your audio or MIDI events to some CSSLSD properties. All parameters are between **square brackets**. You can use multiple parameters in a line. You can also type pure CSS in code editor, this CSS wil be apply on code auto-save (each time your type something in editor).
+
+You can extend parameter by heritage with template `[<parameter> <type> <option> <audio or midi control>]`. This is not mandatory to type all heritage, but you need to restect the direction. This is allowed : `[<parameter> <type> <option>]` or `[<parameter> <type>]`. This is **not** allowed : `[<parameter> <audio or midi control>]`.
 
 Code example:
 
diff --git a/main.js b/main.js
index b3482fe..642e5f2 100644
--- a/main.js
+++ b/main.js
@@ -208,23 +208,23 @@ function analyseAll() {
 													type: '',
 													name: templateSplited[0],
 													templateFull: template,
-													eventType: '',
-													eventName: '',
-													options: '',
+													eventType: templateSplited.length > 3 ? (templateSplited[3].includes(':')?templateSplited[3].split(':')[0]:templateSplited[3]) : '',
+													eventName: templateSplited.length > 3 ? (templateSplited[3].includes(':')?templateSplited[3].split(':')[1]:'') : '',
+													options: templateSplited.length > 2 ? (templateSplited[2]) : '',
 													array: templateSplited.length > 1 ? (templateSplited[1].includes(';') ? templateSplited[1].split(';') : '') : '',
 													min: templateSplited.length > 1 ? (templateSplited[1].includes(':') ? templateSplited[1].split(':')[0] : '') : '',
 													max: templateSplited.length > 1 ? (templateSplited[1].includes(':') ? templateSplited[1].split(':')[1] : '') : '',
 												}
 												obj.type = 'midi';
 												if (midiE.includes(':')) {
-													obj.eventType = midiE.split(':')[0];
-													obj.eventName = midiE.split(':')[1];
+													obj.eventType = ((obj.eventType == '') ? midiE.split(':')[0] : obj.eventType);
+													obj.eventName = ((obj.eventName == '') ? midiE.split(':')[1] : obj.eventName);
 												}
 												else {
-													obj.eventType = midiE;
-													obj.eventName = '';
+													obj.eventType = ((obj.eventType == '') ? midiE : obj.eventType);
+													obj.eventName = ((obj.eventName == '') ? '' : obj.eventName);
 												}
-												obj.options = p[3];
+												obj.options = ((obj.options == '') ? (p[3]) : obj.options);
 												obj.array = ((obj.array == '') ? (p[2].includes(';') ? p[2].split(';') : '') : obj.array);
 												obj.min = ((obj.min == '') ? (p[2].includes(':') ? p[2].split(':')[0] : 0) : obj.min);
 												obj.max = ((obj.max == '') ? (p[2].includes(':') ? p[2].split(':')[1] : 1) : obj.max);
@@ -237,23 +237,23 @@ function analyseAll() {
 													type: '',
 													name: templateSplited[0],
 													templateFull: template,
-													eventType: '',
-													eventName: '',
-													options: '',
+													eventType: templateSplited.length > 3 ? (templateSplited[3].includes(':')?templateSplited[3].split(':')[0]:templateSplited[3]) : '',
+													eventName: templateSplited.length > 3 ? (templateSplited[3].includes(':')?templateSplited[3].split(':')[1]:'') : '',
+													options: templateSplited.length > 2 ? (templateSplited[2]) : '',
 													array: templateSplited.length > 1 ? (templateSplited[1].includes(';') ? templateSplited[1].split(';') : '') : '',
 													min: templateSplited.length > 1 ? (templateSplited[1].includes(':') ? templateSplited[1].split(':')[0] : '') : '',
 													max: templateSplited.length > 1 ? (templateSplited[1].includes(':') ? templateSplited[1].split(':')[1] : '') : '',
 												}
 												obj.type = 'audio';
 												if (audioE.includes(':')) {
-													obj.eventType = audioE.split(':')[0];
-													obj.eventName = audioE.split(':')[1];
+													obj.eventType = ((obj.eventType == '') ? audioE.split(':')[0] : obj.eventType);
+													obj.eventName = ((obj.eventName == '') ? audioE.split(':')[1] : obj.eventName);
 												}
 												else {
-													obj.eventType = audioE;
-													obj.eventName = '';
+													obj.eventType = ((obj.eventType == '') ? audioE : obj.eventType);
+													obj.eventName = ((obj.eventName == '') ? '' : obj.eventName);
 												}
-												obj.options = p[3];
+												obj.options = ((obj.options == '') ? (p[3]) : obj.options);
 												obj.array = ((obj.array == '') ? (p[2].includes(';') ? p[2].split(';') : '') : obj.array);
 												obj.min = ((obj.min == '') ? (p[2].includes(':') ? p[2].split(':')[0] : 0) : obj.min);
 												obj.max = ((obj.max == '') ? (p[2].includes(':') ? p[2].split(':')[1] : 1) : obj.max);
-- 
GitLab