From 7f1393ea607b5b6652542785f0bd5352362c1d3b Mon Sep 17 00:00:00 2001 From: Pierre Ranwez <pierre.ranwez.etu@univ-lille.fr> Date: Thu, 24 Feb 2022 22:40:41 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20CSSLSD=20without=20paramete?= =?UTF-8?q?rs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 5 ++++- main.js | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index bf1c26a..9bfe2ba 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,8 @@ You need to use a custom CSS template, like below to map your audio or MIDI even 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>]`. +You can use without CSSLSD code without any parameters, use same template like above. How to use : `[<type> <option> <audio or midi control>]`. + Code example: ```css @@ -84,8 +86,9 @@ body { background-color:[couleur #000:#fff]; } h1 { - /* Simple parameter usage */ + /* Simple parameter usage */ opacity: [opacité]; + font-size:[0:20 d loud]; color: #000000; } ``` diff --git a/main.js b/main.js index 642e5f2..dcbe92f 100644 --- a/main.js +++ b/main.js @@ -56,8 +56,8 @@ function setAutocompleteParameters() { function loadEditor() { editor = ace.edit("editor", { autoScrollEditorIntoView: true, - maxLines: 40, - minLines: 2 + maxLines: 40, + minLines: 2 }); editor.setTheme("ace/theme/tomorrow_night_blue"); editor.session.setMode("ace/mode/css"); @@ -180,6 +180,7 @@ function saveParameters() { } function analyseAll() { + var isParameter = false; chrome.storage.local.get(['parameters', 'css'], function (result) { var all = []; var parser = new CSSParser(); @@ -193,23 +194,27 @@ function analyseAll() { count = css.valueText.split("[").length; if (count > 1) { for (let index = 0; index < count - 1; index++) { + isParameter = false; template = cssValue.substring( cssValue.indexOf("[") + 1, cssValue.indexOf("]") ); + console.log(template); cssValue = cssValue.replace("[" + template + "]", ""); var parameters = JSON.parse(result.parameters); parameters.forEach(p => { templateSplited = template.split(' '); if (p[1] == templateSplited[0]) { + isParameter = true; + console.log(isParameter); if (p[4] != "") { p[4].split(' ').forEach(midiE => { var obj = { type: '', name: templateSplited[0], templateFull: template, - eventType: templateSplited.length > 3 ? (templateSplited[3].includes(':')?templateSplited[3].split(':')[0]:templateSplited[3]) : '', - eventName: templateSplited.length > 3 ? (templateSplited[3].includes(':')?templateSplited[3].split(':')[1]:'') : '', + 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] : '') : '', @@ -237,8 +242,8 @@ function analyseAll() { type: '', name: templateSplited[0], templateFull: template, - eventType: templateSplited.length > 3 ? (templateSplited[3].includes(':')?templateSplited[3].split(':')[0]:templateSplited[3]) : '', - eventName: templateSplited.length > 3 ? (templateSplited[3].includes(':')?templateSplited[3].split(':')[1]:'') : '', + 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] : '') : '', @@ -262,7 +267,27 @@ function analyseAll() { } } }); - + if (isParameter == false) { + if (templateSplited.length > 2) { + if (templateSplited[2].includes('cc') || templateSplited[2].includes('note') || templateSplited[2].includes('pb')) { + var audioOrMidi = 'midi'; + } else { + var audioOrMidi = 'audio'; + } + var obj = { + type: audioOrMidi, + name: templateSplited[0], + templateFull: template, + eventType: templateSplited.length > 2 ? (templateSplited[2].includes(':') ? templateSplited[2].split(':')[0] : templateSplited[2]) : '', + eventName: templateSplited.length > 2 ? (templateSplited[2].includes(':') ? templateSplited[2].split(':')[1] : '') : '', + options: templateSplited.length > 1 ? (templateSplited[1]) : '', + array: templateSplited.length > 0 ? (templateSplited[0].includes(';') ? templateSplited[0].split(';') : '') : '', + min: templateSplited.length > 0 ? (templateSplited[0].includes(':') ? templateSplited[0].split(':')[0] : '') : '', + max: templateSplited.length > 0 ? (templateSplited[0].includes(':') ? templateSplited[0].split(':')[1] : '') : '', + } + templates.push(obj); + } + } } } else { templates.push({ -- GitLab