From: equilet <2237372+equilet@users.noreply.github.com> Date: Wed, 20 Mar 2024 07:15:41 +0000 (-0500) Subject: num_regions is handled more elegantly X-Git-Tag: v1.0~7 X-Git-Url: https://git.dabkitsch.com/?a=commitdiff_plain;h=17f94bd2cace295e975ba3f1844ab0b5ae854f49;p=m29-web-sfp.git num_regions is handled more elegantly --- diff --git a/app.js b/app.js index c15f501..d70b4de 100644 --- 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; }, } ];