From 5016e55e4e7d7f2bae2fcb5d5ea7d58d9df65883 Mon Sep 17 00:00:00 2001 From: John Bachir Date: Thu, 24 Mar 2022 19:46:05 -0400 Subject: [PATCH] support multiple tours with some not run before this, if a tour was encountered where tourMayStart was false, then subsequent tours were not attempted now, all incomplete tours are looped through until the first runable one is run for...in is used because it is the most compatible --- app/assets/javascripts/abraham/index.js | 7 ++++--- app/views/application/_abraham.html.erb | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/abraham/index.js b/app/assets/javascripts/abraham/index.js index 0a539eb..e028878 100644 --- a/app/assets/javascripts/abraham/index.js +++ b/app/assets/javascripts/abraham/index.js @@ -11,9 +11,10 @@ Abraham.startTour = function(tourName) { } }; Abraham.startNextIncompleteTour = function() { - if (Abraham.incompleteTours.length) { - Abraham.tours[Abraham.incompleteTours[0]].checkAndStart(); - } + for (const i in Abraham.incompleteTours) { + var tour_did_run = Abraham.tours[Abraham.incompleteTours[i]].checkAndStart(); + if(tour_did_run){ break; }; + }; }; document.addEventListener("DOMContentLoaded", Abraham.startNextIncompleteTour); diff --git a/app/views/application/_abraham.html.erb b/app/views/application/_abraham.html.erb index 05dac9f..058f3ec 100644 --- a/app/views/application/_abraham.html.erb +++ b/app/views/application/_abraham.html.erb @@ -69,6 +69,9 @@ if (tourMayStart) { start(); + return true; + } else { + return false; } } }(Abraham.tours["<%= tour_name %>"].start)