From bc1f0d771121da9469475b63cf0ccac0aa8bcaed Mon Sep 17 00:00:00 2001
From: Pierre Ranwez <pierre.ranwez.etu@univ-lille.fr>
Date: Tue, 1 Feb 2022 16:52:48 +0100
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20bug:=20bug=20bounty=20after=20re?=
 =?UTF-8?q?factor?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 content.js | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/content.js b/content.js
index f61a5bf..2e17f11 100644
--- a/content.js
+++ b/content.js
@@ -17,7 +17,7 @@ var audioSample = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
 function parseCSS(cssObj) {
     var parser = new CSSParser();
     var sheet = parser.parse(cssObj, false, true);
-    var audioVars = ['loud', 'low', 'lomi', 'mid', 'mihi', 'hi', 'attack'];
+    var audioVars = ['loud', 'low', 'lomi', 'mid', 'mihi', 'hi', 'attack', 'onset'];
     var midiVars = ['cc', 'note'];
     chrome.runtime.sendMessage({ type: 'updateUi', data: true });
     sheet.cssRules.forEach(element => {
@@ -84,9 +84,9 @@ function templateToDict(string) {
             });
         }
         else {
-            if (string.includes(':')) {
-                eventType = string.split(':')[0];
-                eventName = string.split(':')[1];
+            if (template.includes(':')) {
+                eventType = template.split(':')[0];
+                eventName = template.split(':')[1];
             }
             else {
                 eventType = eventString;
@@ -102,6 +102,7 @@ function templateToDict(string) {
         }
         string = string.replace('[' + template + ']', '');
     }
+    console.log(returnValue);
     return returnValue;
 }
 
@@ -458,7 +459,7 @@ function audioEvent() {
                 volume = meter.volume * 1.4;
                 value = value.replace('[' + template['templateFull'] + ']', (meter.volume * 1.4 < 1 ? parseInt(template['min']) + Math.round((template['max'] - template['min']) * volume) : 0));
             }
-            if (template['eventType'] == 'note' && template['eventName'] == note) {
+            if (template['eventType'] == 'onset' && template['eventName'] == noteStrings[note % 12]) {
                 eventIn = true;
                 value = value.replace('[' + template['templateFull'] + ']', '');
             }
@@ -490,6 +491,7 @@ function onMessage({ type, data }) {
         case 'update': {
             const css = data.cssStr;
             audioEvents = [];
+            midiEvents = [];
             parseCSS(css)
             break;
         }
-- 
GitLab