Week 17

Week of January 6, 2019

Fixing some stuff

1-6-2019

Now that all the slideshows and exercises work, all that’s left is to fix a couple things. First, I went back to the copy-restore exercise and added instructions for the restore step. It works identically to how the instructions change in the by-name exercise.

Next I wanted to tackle this weird bug that affects the parameter passing page in the book. Refreshing on the page causes the parameter passing slideshows to grow taller and taller with each refresh. I noticed this early on, but I wasn’t sure what to do about it. Dr. Naps suggested setting the slideshows height to a fixed value. The problem with that approach is that the problems are randomly generated and the height varies. I ended up writing a script that would resize the slideshow based on the height of it’s JSAV pseudocode element. Here’s what that looks like:

$(window).load(function() {
  var canvases = $('.jsavcanvas');
  for(var i=0; i<canvases.length; i++){
    var canvas = $('svg', canvases[i]);
    var jsavcode = $('.jsavcode', canvases[i]);
    canvas.css('height', (jsavcode.height() + 12) + 'px');
    $(canvases[i]).css('min-height', (jsavcode.height() + 24) + 'px')
  }
})

Not exactly sure what causes the issue, but I’m pretty sure it’s JSAV.

Anyway, here and here are my commits.