sclass HDivWithVerticalExpandButton { int initialHeight; S expandButtonText = "Read more"; O contents; *(int *initialHeight, O *contents) {} S html() { ret div(contents, class := "expandable", style := "padding: 20px 10px; max-height: " + initialHeight + "px; overflow: hidden;") + "\n" + hbutton(expandButtonText, onclick := [[ $(this).prev('.expandable').css('max-height', 'none'); $(this).hide(); ]], onload := "console.log('onload'); function check() { $(this).toggle($(this).prev('.expandable').outerHeight() >= " + initialHeight + "); } " + "check(); setInterval(check, 5000);"); } bool needsJQuery() { true; } }