]> git.dabkitsch.com - m29-web-sfp.git/commitdiff
num_regions is handled more elegantly
authorequilet <2237372+equilet@users.noreply.github.com>
Wed, 20 Mar 2024 07:15:41 +0000 (02:15 -0500)
committerequilet <2237372+equilet@users.noreply.github.com>
Wed, 20 Mar 2024 07:15:41 +0000 (02:15 -0500)
app.js

diff --git a/app.js b/app.js
index c15f50109b92acddce25d39a80737e3579ee7a5d..d70b4dea695a3262f9cf03f76d04135949b1f576 100644 (file)
--- a/app.js
+++ b/app.js
@@ -41,12 +41,13 @@ document.addEventListener('DOMContentLoaded', function(){
 
 
 function add_one_region() {
+
     const dur = ws.getDuration();
     const pad = 0.2;
     const currtime = ws.getCurrentTime();
-
     //let randstart = (Math.random() * dur) - pad;
     //let randend = randstart + 3;
+    num_regions++;
 
     wsr.addRegion({
         channelIdx: num_regions, 
@@ -58,21 +59,22 @@ function add_one_region() {
         loop: false, 
         color: 'hsla(184, 32%, 72%, 0.1)'
     });
-    num_regions++;
+
 }
+
 function add_3_regions() {
     const dur = ws.getDuration();
     const pad = 0.2;
 
-    for(let i=0; i<3; i++){
+    for(let i = 1; i < 4; i++){
 
+        //this should be clipped
         let randstart = (Math.random() * dur) - pad;
         let randend = randstart + 3;
 
         wsr.addRegion({
             channelIdx: i, 
             content: "region" + i + "text",
-            //id: "cue " + i, 
             id: 'region',
             start: randstart, 
             end: randend, 
@@ -87,15 +89,10 @@ function buttons_reset() {
         btn_tp_reset();
         btn_r_reset();
         btn_m_reset();
-        marker_reset();
-}
-
-function marker_add() {
-    num_regions++;
-
+        marker_view_reset();
 }
 
-function marker_reset(){
+function marker_view_reset(){
     curr_region = -1;
     text_input.value = "no marker selected";
 }
@@ -256,6 +253,7 @@ function initialize(){
             call_action: function () {
                 console.log("generate button clicked");
                 wsr.clearRegions();
+                num_regions = 0;
                 add_3_regions();
             },
         }, 
@@ -265,7 +263,7 @@ function initialize(){
             clicked: false, 
             call_action: function () {
                 wsr.clearRegions();
-                num_regions = -1;
+                num_regions = 0;
             },
         }
     ];