From aff1587d8d997ccf89310cdbbbfa8ede5ead8ae2 Mon Sep 17 00:00:00 2001 From: Scott Anderson Date: Thu, 2 Feb 2023 09:45:06 -0700 Subject: [PATCH] hotfix: fix js bug for code controls --- assets/js/code-controls.js | 4 ++-- assets/js/get-started-timestamps.js | 30 +++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/assets/js/code-controls.js b/assets/js/code-controls.js index 7ff99df0a..76589de43 100644 --- a/assets/js/code-controls.js +++ b/assets/js/code-controls.js @@ -28,11 +28,11 @@ $(document).click(function() { // Click the code controls toggle to open code controls $('.code-controls-toggle').click(function() { - $(this).parent().toggleClass('open'); + $(this).parent('.code-controls').toggleClass('open'); }) // Stop event propagation for clicks inside of the code-controls div -$(".code-controls").click(function(e) { +$('.code-controls').click(function(e) { e.stopPropagation(); }); diff --git a/assets/js/get-started-timestamps.js b/assets/js/get-started-timestamps.js index cd200de8e..4b05c804e 100644 --- a/assets/js/get-started-timestamps.js +++ b/assets/js/get-started-timestamps.js @@ -82,9 +82,18 @@ function updateTimestamps(newStartDate) { } }) - $('.get-started-timestamps').each(function() { + var updateBlockElWhitelist = [ + '.get-started-timestamps pre', + '.get-started-timestamps li', + '.get-started-timestamps p', + '.get-started-timestamps table' + ] + + $(updateBlockElWhitelist.join()).each(function() { var wrapper = $(this)[0] + console.log(wrapper) + times.forEach(function(x) { oldDatePart = datePart(x.rfc3339.replace(/T.*$/, "")) newDatePart = datePart(x.rfc3339_new.replace(/T.*$/, "")) @@ -96,9 +105,26 @@ function updateTimestamps(newStartDate) { .replaceAll(x.unix, x.unix_new) .replaceAll(rfc3339Regex, rfc3339Repl) }) - console.log(times) }) + $('span.get-started-timestamps').each(function() { + var wrapper = $(this)[0] + + console.log(wrapper) + + times.forEach(function(x) { + oldDatePart = datePart(x.rfc3339.replace(/T.*$/, "")) + newDatePart = datePart(x.rfc3339_new.replace(/T.*$/, "")) + rfc3339Regex = new RegExp(`${oldDatePart.year}-${oldDatePart.month}-${oldDatePart.day}`, 'g') + rfc3339Repl = `${newDatePart.year}-${newDatePart.month}-${newDatePart.day}` + + wrapper.innerHTML = + wrapper.innerHTML + .replaceAll(x.unix, x.unix_new) + .replaceAll(rfc3339Regex, rfc3339Repl) + }) + }) + // Create a new seed times array with new start time for next change times = times.map(x => { var newStartTimestamp = x.rfc3339.replace(/^.*T/, newStartDate + "T")